Skip to content
Browse files

Improve tests based on recent changes

  • Loading branch information...
1 parent 3683a62 commit 1977a1efca0debc345348b5eb01a5e888e6a35e6 @ripienaar committed Jun 11, 2011
Showing with 6 additions and 9 deletions.
  1. +6 −9 spec/unit/backend/yaml_backend_spec.rb
View
15 spec/unit/backend/yaml_backend_spec.rb
@@ -20,22 +20,19 @@ module Backend
describe "#lookup" do
it "should look for data in all sources" do
- Backend.expects(:datadir).returns("/nonexisting").twice
Backend.expects(:datasources).multiple_yields(["one"], ["two"])
- File.expects(:exist?).with("/nonexisting/one.yaml").returns(false)
- File.expects(:exist?).with("/nonexisting/two.yaml").returns(false)
+ Backend.expects(:datafile).with(:yaml, {}, "one", "yaml").returns(nil)
+ Backend.expects(:datafile).with(:yaml, {}, "two", "yaml").returns(nil)
@backend.lookup("key", {}, nil, :priority)
end
it "should pick data earliest source that has it for priority searches" do
- Backend.expects(:datadir).returns("/nonexisting")
Backend.expects(:datasources).multiple_yields(["one"], ["two"])
- File.expects(:exist?).with("/nonexisting/one.yaml").returns(true)
+ Backend.expects(:datafile).with(:yaml, {}, "one", "yaml").returns("/nonexisting/one.yaml")
+ Backend.expects(:datafile).with(:yaml, {}, "two", "yaml").returns(nil).never
YAML.expects(:load_file).with("/nonexisting/one.yaml").returns({"key" => "answer"})
- File.expects(:exist?).with("/nonexisting/two.yaml").never
-
@backend.lookup("key", {}, nil, :priority).should == "answer"
end
@@ -52,11 +49,11 @@ module Backend
end
it "should parse the answer for scope variables" do
- Backend.expects(:datadir).returns("/nonexisting")
Backend.expects(:datasources).yields("one")
- File.expects(:exist?).with("/nonexisting/one.yaml").returns(true)
+ Backend.expects(:datafile).with(:yaml, {"rspec" => "test"}, "one", "yaml").returns("/nonexisting/one.yaml")
YAML.expects(:load_file).with("/nonexisting/one.yaml").returns({"key" => "test_%{rspec}"})
+
@backend.lookup("key", {"rspec" => "test"}, nil, :priority).should == "test_test"
end
end

0 comments on commit 1977a1e

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