Object
@private
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 236 def description message_finder.allow_description(allowed_values) end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 226 def failure_message "Did not expect #{expectation}, got error: #{matched_error}" end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 231 def failure_message_when_negated "Expected #{expectation}, got #{error_description}" end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 185 def for(attribute) self.attribute_to_set = attribute self.attribute_to_check_message_against = attribute self end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 216 def matches?(instance) self.instance = instance values_to_match.none? do |value| self.value = value set_value(value) errors_match? end end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 191 def on(context) @context = context self end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 207 def strict self.message_finder_factory = ExceptionMessageFinder self end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 196 def with_message(message, options={}) self.options[:expected_message] = message self.options[:expected_message_values] = options.fetch(:values, {}) if options.key?(:against) self.attribute_to_check_message_against = options[:against] end self end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 296 def allowed_values if values_to_match.length > 1 "any of [#{values_to_match.map(&:inspect).join(', ')}]" else values_to_match.first.inspect end end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 318 def default_attribute_message default_error_message( options[:expected_message], default_attribute_message_values ) end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 325 def default_attribute_message_values defaults = { model_name: model_name, instance: instance, attribute: attribute_to_set, } defaults.merge(options[:expected_message_values]) end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 314 def default_expected_message message_finder.expected_message_from(default_attribute_message) end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 292 def error_description message_finder.messages_description end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 288 def error_source message_finder.source_description end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 267 def errors_for_attribute message_finder.messages end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 259 def errors_for_attribute_match? if expected_message self.matched_error = errors_match_regexp? || errors_match_string? else errors_for_attribute.compact.any? end end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 251 def errors_match? has_messages? && errors_for_attribute_match? end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 271 def errors_match_regexp? if Regexp === expected_message errors_for_attribute.detect { |e| e =~ expected_message } end end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 277 def errors_match_string? if errors_for_attribute.include?(expected_message) expected_message end end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 283 def expectation includes_expected_message = expected_message ? "to include #{expected_message.inspect}" : '' [error_source, includes_expected_message, "when #{attribute_to_set} is set to #{value.inspect}"].join(' ') end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 304 def expected_message if options.key?(:expected_message) if Symbol === options[:expected_message] default_expected_message else options[:expected_message] end end end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 255 def has_messages? message_finder.has_messages? end
# File lib/shoulda/matchers/active_model/allow_value_matcher.rb, line 339 def message_finder message_finder_factory.new(instance, attribute_to_check_message_against, context) end
Generated with the Darkfish Rdoc Generator 2.