Skip to content

Commit

Permalink
adding specs around sessions/options
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurnn committed Jul 11, 2013
1 parent ffa8939 commit d164008
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions spec/mongoid/sessions/options_spec.rb
@@ -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

0 comments on commit d164008

Please sign in to comment.