spec/expressive_spec.rb in expressive-0.0.27 vs spec/expressive_spec.rb in expressive-0.0.28
- 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 $sub get put post >= > < <= and or if date datetime lookup round $round $days_ago $hours_ago $minutes_ago $append $id $head $lookup $reverse $tail $hash $concat $split $sms) }
+ it { Expressive.all_symbols.should =~ %w(+ - * / = set sum $sub get put post >= > < <= and or if date datetime lookup round $round $days_ago $hours_ago $minutes_ago $append $id $head $lookup $reverse $tail $hash $concat $split $sms $hval) }
end
describe "understands booleans" do
it { Expressive.run("true").should eql true }
it { Expressive.run("false").should eql false }
@@ -260,13 +260,13 @@
end
it "using single set commands with if" do
@scope['vsi'] = 'oldvalue'
Expressive.run('(set vsi (if (= 1 2) "vsi1234", vsi))', @scope)
- @scope['vsi'].should eql 'oldvalue'
+ @scope['vsi'].should eql 'oldvalue'
Expressive.run('(set vsi (if (= 1 1) "vsi1234", vsi))', @scope).should eql "vsi1234"
- @scope['vsi'].should eql 'vsi1234'
+ @scope['vsi'].should eql 'vsi1234'
end
it "using multiple set commands" do
Expressive.run('(and (set vsi "vsi1234") (set vso "vso1234") (set vsbool true))', @scope).should eql true
@scope['vsi'].should eql 'vsi1234'
@@ -343,11 +343,11 @@
@scope['documents'] = []
Expressive.run('($append documents ($hash (test "value") (another_test 53.2) (and_a_date (date))))', @scope)
@scope['documents'].should == [{"test" => "value", "another_test" => 53.2, "and_a_date" => Time.parse(Date.today.to_s).utc}]
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
@@ -403,17 +403,17 @@
@scope['mobile_phone_no'] = "07968115250"
request = stub_request(:get, @base_url + "&to=447968115250&text=this%20is%20a%20test").to_return(body: {'goodbye' => 'srsly'})
Expressive.run('($sms "447968115250" "this is a test")', @scope)
assert_requested(request)
@scope['goodbye'].should eql 'srsly'
- end
+ end
it "should normalise international phone numbers" do
@scope['mobile_phone_no'] = "+447968115250"
request = stub_request(:get, @base_url + "&to=447968115250&text=this%20is%20a%20test").to_return(body: {'goodbye' => 'srsly'})
Expressive.run('($sms "447968115250" "this is a test")', @scope)
assert_requested(request)
@scope['goodbye'].should eql 'srsly'
- end
+ end
it "should encode data" do
@scope['mobile_phone_no'] = "+447968115250"
request = stub_request(:get, @base_url + "&to=447968115250&text=This%20is%20you%27re%20text%20-%20it%20%26%20the%20message%20should%20be%20encoded").to_return(body: {'goodbye' => 'srsly'})
Expressive.run('($sms "447968115250" "This is you\'re text - it & the message should be encoded")', @scope)
assert_requested(request)