Sha256: 9056f8f70df5cac96d5114b16482b966130eadafacddb9b0f9371897f3864d95
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require File.expand_path('../../helper', __FILE__) describe ActiveRecord::QueryMethods::WhereChain do describe :like do it "creates an Arel Matches node in the relation" do relation = Post.where.like(title: '') _(relation.where_clause.send(:predicates).first).must_be_instance_of(Arel::Nodes::Matches) end describe "the Arel Node" do before do @attribute = "title" @value = '%value%' @relation = Post.where.like(@attribute => @value) @first_predicate = @relation.where_clause.send(:predicates).first end it "has the attribute as the left operand" do _(@first_predicate.left.name).must_equal @attribute end it "has the value as the right operand" do # Rails 5.0 & 5.1 first_bind = if @relation.where_clause.respond_to?(:binds) @relation.where_clause.send(:binds).first elsif @first_predicate.right.value.is_a?(String) # Rails 7.0+ @first_predicate.right else # Rails 5.2 @first_predicate.right.value end _(first_bind.value).must_equal @value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-like-7.0.1 | test/unit/like_test.rb |