aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors
diff options
context:
space:
mode:
authorKeenan Brock <keenan@thebrocks.net>2015-12-05 20:23:12 -0500
committerKeenan Brock <keenan@thebrocks.net>2015-12-05 20:23:12 -0500
commitd2e6be1677b124b3eef5b3ebe0fd4a0d31d8a2bf (patch)
tree8715cc5153868d329596827edf97dc1443122e6b /test/visitors
parent4e7b4693b89d920e43f5c2c94b44957a3f392a80 (diff)
downloadrails-d2e6be1677b124b3eef5b3ebe0fd4a0d31d8a2bf.tar.gz
rails-d2e6be1677b124b3eef5b3ebe0fd4a0d31d8a2bf.tar.bz2
rails-d2e6be1677b124b3eef5b3ebe0fd4a0d31d8a2bf.zip
introduce predicate {does_not_}matches_regexp
Diffstat (limited to 'test/visitors')
-rw-r--r--test/visitors/test_postgres.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb
index 4209712e8e..5901c56968 100644
--- a/test/visitors/test_postgres.rb
+++ b/test/visitors/test_postgres.rb
@@ -114,21 +114,25 @@ module Arel
describe "Nodes::Regexp" do
it "should know how to visit" do
- node = Arel::Nodes::Regexp.new(@table[:name], Nodes.build_quoted('foo.*'))
+ node = @table[:name].matches_regexp('foo.*')
+ node.must_be_kind_of Nodes::Regexp
+ node.case_sensitive.must_equal(true)
compile(node).must_be_like %{
"users"."name" ~ 'foo.*'
}
end
it "can handle case insensitive" do
- node = Arel::Nodes::Regexp.new(@table[:name], Nodes.build_quoted('foo.*'), false)
+ node = @table[:name].matches_regexp('foo.*', false)
+ node.must_be_kind_of Nodes::Regexp
+ node.case_sensitive.must_equal(false)
compile(node).must_be_like %{
"users"."name" ~* 'foo.*'
}
end
it 'can handle subqueries' do
- subquery = @table.project(:id).where(Arel::Nodes::Regexp.new(@table[:name], Nodes.build_quoted('foo.*')))
+ subquery = @table.project(:id).where(@table[:name].matches_regexp('foo.*'))
node = @attr.in subquery
compile(node).must_be_like %{
"users"."id" IN (SELECT id FROM "users" WHERE "users"."name" ~ 'foo.*')
@@ -138,21 +142,24 @@ module Arel
describe "Nodes::NotRegexp" do
it "should know how to visit" do
- node = Arel::Nodes::NotRegexp.new(@table[:name], Nodes.build_quoted('foo.*'))
+ node = @table[:name].does_not_match_regexp('foo.*')
+ node.must_be_kind_of Nodes::NotRegexp
+ node.case_sensitive.must_equal(true)
compile(node).must_be_like %{
"users"."name" !~ 'foo.*'
}
end
it "can handle case insensitive" do
- node = Arel::Nodes::NotRegexp.new(@table[:name], Nodes.build_quoted('foo.*'), false)
+ node = @table[:name].does_not_match_regexp('foo.*', false)
+ node.case_sensitive.must_equal(false)
compile(node).must_be_like %{
"users"."name" !~* 'foo.*'
}
end
it 'can handle subqueries' do
- subquery = @table.project(:id).where(Arel::Nodes::NotRegexp.new(@table[:name], Nodes.build_quoted('foo.*')))
+ subquery = @table.project(:id).where(@table[:name].does_not_match_regexp('foo.*'))
node = @attr.in subquery
compile(node).must_be_like %{
"users"."id" IN (SELECT id FROM "users" WHERE "users"."name" !~ 'foo.*')