-
Notifications
You must be signed in to change notification settings - Fork 2
/
predicate_spec.rb
46 lines (38 loc) · 1.61 KB
/
predicate_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require File.join(File.dirname(__FILE__), 'spec_helper')
include SData
describe Predicate do
describe "when predicate string is valid" do
it "should parse predicate string correctly" do
@predicate = Predicate.parse("born_at gt 1900")
ConditionsBuilder.should_receive(:build_conditions).with('born_at', :gt, '1900')
@predicate.to_conditions
end
it "should strip wrapper quote marks" do
@predicate = Predicate.parse("born_at gt '1900'")
ConditionsBuilder.should_receive(:build_conditions).with('born_at', :gt, '1900')
@predicate.to_conditions
end
it "should accept non-alphanumeric characters as part of the value" do
@predicate = Predicate.parse("born_at gt '1`~!@\#$%^&*()_-+={[}]\|'\";:900'")
ConditionsBuilder.should_receive(:build_conditions).with('born_at', :gt, "1`~!@\#$%^&*()_-+={[}]\|'\";:900")
@predicate.to_conditions
end
it "should accept quote-marked empty string" do
@predicate = Predicate.parse("born_at gt ''")
ConditionsBuilder.should_receive(:build_conditions).with('born_at', :gt, "")
@predicate.to_conditions
end
end
describe "predicate string is invalid" do
it "should not accept unrecognized format" do
@predicate = Predicate.parse('blah-blah-blah')
ConditionsBuilder.should_not_receive :build_conditions
@predicate.to_conditions.should == []
end
it "should not accept non-quote-marked empty string" do
@predicate = Predicate.parse('born_at gt ')
ConditionsBuilder.should_not_receive :build_conditions
@predicate.to_conditions.should == []
end
end
end