Sha256: 86602939e9b496a7c8efe9d72a6d47b8f8085eab12c0cddf8b0fd3efa40e9d43

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

require File.expand_path('../../helper', __FILE__)

describe ActiveRecord::QueryMethods::WhereChain do
  describe :not_like do
    it "creates an Arel DoesNotMatch node in the relation" do
      relation = Post.where.not_like(title: '')

      relation.where_clause.send(:predicates).first.must_be_instance_of(Arel::Nodes::DoesNotMatch)
    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
        @first_bind       = relation.where_clause.send(:binds).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
        @first_bind.value.must_equal @value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-like-2.1 test/unit/not_like_test.rb
activerecord-like-2.0 test/unit/not_like_test.rb