spec/musterb/evaluator_spec.rb in musterb-0.0.1 vs spec/musterb/evaluator_spec.rb in musterb-0.0.2
- old
+ new
@@ -3,9 +3,24 @@
foo = "bar"
evaluator = Musterb::Evaluator.new Musterb::BindingExtractor.new(binding)
evaluator["foo"].should eq "bar"
end
+ it "pulls out values from ." do
+ evaluator = Musterb::Evaluator.new Musterb::ObjectExtractor.new(2, nil)
+ evaluator["."].should eq 2
+ end
+
+ it "can do nested values" do
+ evaluator = Musterb::Evaluator.new Musterb::ObjectExtractor.new(2, nil)
+ evaluator["next.to_s"].should eq "3"
+ end
+
+ it "does not barf when pulling out a value on nil" do
+ evaluator = Musterb::Evaluator.new Musterb::HashExtractor.new({:foo => nil}, nil)
+ evaluator["foo.bar"].should eq nil
+ end
+
context "block" do
it "yields to the block if a value is set" do
foo = "bar"
evaluator = Musterb::Evaluator.new Musterb::BindingExtractor.new(binding)
expect { |b| evaluator.block("foo", &b) }.to yield_control
\ No newline at end of file