Class: Remarkable::ActiveRecord::Matchers::EnsureValueInListMatcher

Inherits:
Matcher::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/remarkable/active_record/macros/validations/ensure_value_in_list_matcher.rb

Instance Method Summary collapse

Methods included from Helpers

#allow_blank, #allow_nil, #message

Methods included from Default::Helpers

#assert_contains, #assert_does_not_contain

Methods inherited from Matcher::Base

#negative, #spec

Methods included from Matcher::DSL

included, #matches?

Instance Method Details

#descriptionObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/remarkable/active_record/macros/validations/ensure_value_in_list_matcher.rb', line 12

def description
  values = @good_values.dup
  values << 'nil'   if @options[:allow_nil]
  values << 'blank' if @options[:allow_blank]

  if @behavior == :invalid
    "allow #{@attribute} to be set to #{values.to_sentence}"
  else
    "ensure #{@behavior} of #{values.to_sentence} in #{@attribute}"
  end
end

#failure_messageObject



24
25
26
# File 'lib/remarkable/active_record/macros/validations/ensure_value_in_list_matcher.rb', line 24

def failure_message
  "Expected to #{expectation} (#{@missing})"
end

#negative_failure_messageObject



28
29
30
# File 'lib/remarkable/active_record/macros/validations/ensure_value_in_list_matcher.rb', line 28

def negative_failure_message
  "Did not expect to #{expectation}"
end