Class: RSpec::Rails::Matchers::BeValid

Inherits:
Matchers::BuiltIn::Be
  • Object
show all
Defined in:
lib/rspec/rails/matchers/be_valid.rb

Instance Method Summary (collapse)

Constructor Details

- (BeValid) initialize(*args)

Returns a new instance of BeValid



3
4
5
# File 'lib/rspec/rails/matchers/be_valid.rb', line 3

def initialize(*args)
  @args = args
end

Instance Method Details

- (Object) failure_message_for_should

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
19
20
21
# File 'lib/rspec/rails/matchers/be_valid.rb', line 14

def failure_message_for_should
  message = "expected #{actual.inspect} to be valid"
  if actual.respond_to?(:errors)
    message << ", but got errors: #{actual.errors.full_messages.join(', ')}"
  end

  message
end

- (Object) failure_message_for_should_not

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/rails/matchers/be_valid.rb', line 24

def failure_message_for_should_not
  "expected #{actual.inspect} not to be valid"
end

- (Boolean) matches?(actual)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/rspec/rails/matchers/be_valid.rb', line 8

def matches?(actual)
  @actual = actual
  actual.valid?(*@args)
end