class RSpec::ArelMatchers::Matchers::HaveWhereClause

Public Class Methods

new(cls, left, operator, right) click to toggle source
# File lib/rspec/arel_matchers/matchers/have_where_clause.rb, line 7
def initialize(cls, left, operator, right)
  @cls = cls
  # left operant is converted by active_record to a string in some cases, but not all
  @left = indifferent_string left
  @operator = operator
  @right = right
end

Public Instance Methods

expected() click to toggle source
# File lib/rspec/arel_matchers/matchers/have_where_clause.rb, line 20
def expected
  @cls.arel_table[@left].send(@operator, @right)
end
failure_message() click to toggle source
# File lib/rspec/arel_matchers/matchers/have_where_clause.rb, line 24
def failure_message
  "expected\n#{PP.pp actual.where_values, ''}\nto contain\n" \
  "#{PP.pp expected, ''}"
end
failure_message_when_negated() click to toggle source
# File lib/rspec/arel_matchers/matchers/have_where_clause.rb, line 29
def failure_message_when_negated
  "expected\n#{PP.pp actual.where_values, ''}\nto not contain\n" \
  "#{PP.pp expected, ''}"
end
matches?(actual) click to toggle source
# File lib/rspec/arel_matchers/matchers/have_where_clause.rb, line 15
def matches?(actual)
  @actual = actual
  actual.where_values.any? { |v| expected == v }
end