Skip to content

Commit

Permalink
Added a test to parse a complicated set of operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Youch committed May 24, 2010
1 parent dd9d820 commit 429c04e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/models/user_segment_option_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,17 @@ def parse(text)
[nil, {:field => 'registered', :operation => 'is', :arguments => [true], :child => nil}]
]
end

it "should parse a complaticated set of operations" do
code = <<-CODE
created.since(1 , "days").born.before('yesterday')+ registered.is( true )
registered.is( true )
not test.is( false ) + product.purchased( 'computer' ).created.since( 1, 'day' )
CODE
parse(code).should == [
[nil, {:field => 'created', :operation => 'since', :arguments => [1, "days"], :child => {:field => 'born', :operation => 'before', :arguments => ['yesterday'], :child => nil}}, {:field => 'registered', :operation => 'is', :arguments => [true], :child => nil}],
[nil, {:field => 'registered', :operation => 'is', :arguments => [true], :child => nil}],
['not', {:field => 'test', :operation => 'is', :arguments => [false], :child => nil}, {:field => 'product', :operation => 'purchased', :arguments => ['computer'], :child => {:field => 'created', :operation => 'since', :arguments => [1, 'day'], :child => nil}}]
]
end
end

0 comments on commit 429c04e

Please sign in to comment.