Skip to content
Browse files

Fix all broken mongohq specs

  • Loading branch information...
1 parent 5c44524 commit 44b63884da61299030c33097800b708a6f7d22db @durran durran committed Oct 16, 2013
Showing with 26 additions and 21 deletions.
  1. +1 −1 Guardfile
  2. +0 −1 lib/mongoid/sessions/storage_options.rb
  3. +25 −19 spec/mongoid/sessions_spec.rb
View
2 Guardfile
@@ -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" }
View
1 lib/mongoid/sessions/storage_options.rb
@@ -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
View
44 spec/mongoid/sessions_spec.rb
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit 44b6388

Please sign in to comment.
Something went wrong with that request. Please try again.