spec/lang/expressions/var_name_spec.rb in gobstones-0.0.1.1 vs spec/lang/expressions/var_name_spec.rb in gobstones-0.0.2
- old
+ new
@@ -1,16 +1,28 @@
describe VarName do
- let(:context) { ExecutionContext.new }
- let(:var_name) { VarName.new 'var' }
+ let(:context) { clean_context }
+ let(:variable_name) { 'var'.to_var_name }
- it "should return the associated value if it was defined in the context" do
- context.set var_name, 42.to_gbs_num
- expect(var_name.evaluate(context)).to eq(42.to_gbs_num)
+ it "returns the associated value if it was defined in the context" do
+ context.set variable_name, 42.to_gbs_num
+ expect(variable_name.evaluate(context)).to eq(42.to_gbs_num)
end
- it "should raise an error if there is no definition in context" do
- expect { var_name.evaluate context }
+ it "raises an error if there is no definition in context" do
+ expect { variable_name.evaluate context }
.to raise_error(UndefinedVariableError)
end
-end
\ No newline at end of file
+ describe "#named?" do
+
+ it "is named 'var'" do
+ expect(variable_name.named? 'var').to be true
+ end
+
+ it "is not named 'blah'" do
+ expect(variable_name.named? 'blah').to be false
+ end
+
+ end
+
+end