spec/unit/dialect/test_evaluate.rb in wlang-2.0.0.beta vs spec/unit/dialect/test_evaluate.rb in wlang-2.0.0
- old
+ new
@@ -1,41 +1,49 @@
require 'spec_helper'
module WLang
- class Dialect
- describe Evaluation, "evaluate" do
- include Evaluation
+ describe Dialect, 'evaluate' do
- let(:struct){ Struct.new(:who) }
+ let(:struct){ Struct.new(:who) }
- it 'works with a hash' do
- with_scope({:who => "World"}) do
- evaluate("who").should eq("World")
- evaluate(:who).should eq("World")
- end
- end
+ let(:dialect){ Dialect.new }
- it 'works with a struct' do
- with_scope(struct.new("World")) do
- evaluate("who").should eq("World")
- evaluate(:who).should eq("World")
- end
+ def with_scope(*args, &bl)
+ dialect.with_scope(*args, &bl)
+ end
+
+ def evaluate(*args, &bl)
+ dialect.evaluate(*args, &bl)
+ end
+
+ it 'works with a hash' do
+ with_scope({:who => "World"}) do
+ evaluate("who").should eq("World")
+ evaluate(:who).should eq("World")
end
+ end
- it 'uses the hash in priority' do
- with_scope({:keys => [1,2,3]}) do
- evaluate("keys").should eq([1,2,3])
- end
+ it 'works with a struct' do
+ with_scope(struct.new("World")) do
+ evaluate("who").should eq("World")
+ evaluate(:who).should eq("World")
end
+ end
- it 'falls back to send' do
- with_scope({:who => "World"}) do
- evaluate("keys").should eq([:who])
- end
+ it 'uses the hash in priority' do
+ with_scope({:keys => [1,2,3]}) do
+ evaluate("keys").should eq([1,2,3])
end
+ end
- it 'raises a NameError when not found' do
- lambda{ evaluate("who") }.should raise_error(NameError)
+ it 'falls back to send' do
+ with_scope({:who => "World"}) do
+ evaluate("keys").should eq([:who])
end
+ end
- end # describe Evaluation, "evaluate"
- end # class Dialect
-end # module WLang
\ No newline at end of file
+ it 'raises a NameError when not found' do
+ lambda{ evaluate("who") }.should raise_error(NameError)
+ end
+
+ end # describe Dialect, 'evaluate'
+end # module WLang
+