forked from mongodb/mongoid
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding specs around sessions/options
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require "spec_helper" | ||
|
||
describe Mongoid::Sessions::Options do | ||
|
||
# class Foo | ||
# include Mongoid::Sessions::Options | ||
# end | ||
|
||
describe "#with" do | ||
|
||
context "when passing some options" do | ||
|
||
let(:options) { { database: 'test' } } | ||
|
||
let(:klass) do | ||
Band.with(options) | ||
end | ||
|
||
it "sets the options into the class" do | ||
expect(klass.persistence_options).to eq(options) | ||
end | ||
|
||
it "sets the options into the instance" do | ||
expect(klass.new.persistence_options).to eq(options) | ||
end | ||
|
||
context "when calling .collection method" do | ||
|
||
before do | ||
klass.collection | ||
end | ||
|
||
it "keeps the options" do | ||
expect(klass.persistence_options).to eq(options) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe ".with" do | ||
|
||
let(:options) { { database: 'test' } } | ||
|
||
let(:instance) do | ||
Band.new.with(options) | ||
end | ||
|
||
it "sets the options into" do | ||
expect(instance.persistence_options).to eq(options) | ||
end | ||
|
||
it "passes down the options to collection" do | ||
Band.should_receive(:collection).with(options) | ||
instance.collection | ||
end | ||
end | ||
end |