spec/expressive_spec.rb in expressive-0.0.16 vs spec/expressive_spec.rb in expressive-0.0.17
- old
+ new
@@ -4,11 +4,11 @@
before(:each) do
@scope = Expressive::TopLevel.new
end
describe "all_symbols" do
- it { Expressive.all_symbols.should =~ %w(+ - * / = set sum get put post >= > < <= and or if date lookup round $days_ago $hours_ago $minutes_ago) }
+ it { Expressive.all_symbols.should =~ %w(+ - * / = set sum get put post >= > < <= and or if date lookup round $days_ago $hours_ago $minutes_ago $append $id) }
end
describe "understands booleans" do
it { Expressive.run("true").should eql true }
it { Expressive.run("false").should eql false }
@@ -139,9 +139,29 @@
end
Expressive.run('(set x_owned_by (lookup users "x_current"))', @scope)
@scope["owned_by_id"].should eql @user2.id
@scope["owned_by_type"].should eql "RSpec::Mocks::Mock"
+ end
+
+ end
+
+ describe "understands adding values to lists" do
+ it "add a single value to a list of values" do
+ Expressive.run('($append participating_teams 1)', @scope)
+ @scope['participating_teams'].should == [1]
+ end
+ it "append to a list values list of values" do
+ @scope['participating_teams'] = [0]
+ Expressive.run('($append participating_teams (1 2 3))', @scope)
+ @scope['participating_teams'].should == [0, 1, 2, 3]
+ end
+ end
+
+ describe "understands retrieving the id of an object" do
+ it do
+ @scope["an_object"] = mock(:an_object, id: 5)
+ Expressive.run('($id an_object)', @scope).should == 5
end
end
describe "understands time ranges" do
before do