Skip to content

Commit

Permalink
Fix all broken mongohq specs
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Oct 16, 2013
1 parent 5c44524 commit 44b6388
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
guard(
"rspec",
all_after_pass: false,
cli: "--fail-fast --tty --format documentation --colour") do
cmd: "rspec --fail-fast --tty --format documentation --colour") do

watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" }
Expand Down
1 change: 0 additions & 1 deletion lib/mongoid/sessions/storage_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def __evaluate__(name)
return nil unless name
name.respond_to?(:call) ? name.call.to_sym : name.to_sym
end

end
end
end
Expand Down
44 changes: 25 additions & 19 deletions spec/mongoid/sessions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
end

it "returns the default session" do
expect(single_session.options[:database]).to eq(ENV["MONGOHQ_SINGLE_NAME"])
expect(single_session.options[:database].to_s).to eq(ENV["MONGOHQ_SINGLE_NAME"])
end
end

Expand Down Expand Up @@ -344,8 +344,12 @@

shared_examples_for "an overridden session to a mongohq replica set" do

it "returns the default session" do
expect(replica_session.options[:database]).to eq(ENV["MONGOHQ_REPL_NAME"])
let(:seeds) do
replica_session.cluster.seeds.map{ |node| node.address.original }
end

it "returns the overridden session" do
expect(seeds).to eq([ ENV["MONGOHQ_REPL_1_URL"], ENV["MONGOHQ_REPL_2_URL"] ])
end
end

Expand Down Expand Up @@ -391,8 +395,12 @@
band.mongo_session
end

it "returns the default session" do
expect(repl_session.options[:database]).to eq(ENV["MONGOHQ_REPL_NAME"])
let(:seeds) do
repl_session.cluster.seeds.map{ |node| node.address.original }
end

it "returns the overridden session" do
expect(seeds).to eq([ ENV["MONGOHQ_REPL_1_URL"], ENV["MONGOHQ_REPL_2_URL"] ])
end
end

Expand Down Expand Up @@ -463,7 +471,7 @@
end

it "returns the default session" do
expect(session.options[:database]).to eq(ENV["MONGOHQ_SINGLE_NAME"])
expect(session.options[:database].to_s).to eq(ENV["MONGOHQ_SINGLE_NAME"])
end
end

Expand All @@ -477,8 +485,12 @@
Band.mongo_session
end

it "returns the default session" do
expect(repl_session.options[:database]).to eq(ENV["MONGOHQ_REPL_NAME"])
let(:seeds) do
repl_session.cluster.seeds.map{ |node| node.address.original }
end

it "returns the overridden session" do
expect(seeds).to eq([ ENV["MONGOHQ_REPL_1_URL"], ENV["MONGOHQ_REPL_2_URL"] ])
end
end

Expand Down Expand Up @@ -1037,27 +1049,21 @@

context "when the override is configured with a uri" do

let(:database_name) do
"mongoid_other"
end

let(:config) do
{ default: { uri: "mongodb://localhost:#{PORT}/#{database_id}" },
session1: { uri: "mongodb://localhost:#{PORT}/#{database_name}" }}
let(:file) do
File.join(File.dirname(__FILE__), "..", "config", "mongoid.yml")
end

before do
Mongoid::Threaded.sessions.clear
Mongoid.sessions = config
Mongoid.override_session(:session1)
Mongoid::Config.load!(file, :test)
Mongoid.override_session(:mongohq_repl_uri)
end

after do
Mongoid.override_session(nil)
end

it "has some database name on session" do
expect(Band.mongo_session.options[:database]).to eq(database_name)
expect(Band.mongo_session.options[:database]).to eq(:mongoid_test)
end
end

Expand Down

0 comments on commit 44b6388

Please sign in to comment.