Class: ElabsMatchers::Matchers::Allow::AllowMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/elabs_matchers/matchers/allow.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (AllowMatcher) initialize(values)

A new instance of AllowMatcher



10
11
12
# File 'lib/elabs_matchers/matchers/allow.rb', line 10

def initialize(values)
  @values = values
end

Instance Attribute Details

- (Object) attributes (readonly)

Returns the value of attribute attributes



8
9
10
# File 'lib/elabs_matchers/matchers/allow.rb', line 8

def attributes
  @attributes
end

- (Object) record (readonly)

Returns the value of attribute record



8
9
10
# File 'lib/elabs_matchers/matchers/allow.rb', line 8

def record
  @record
end

Instance Method Details

- (Object) as(*attributes)

Tell the matcher which attributes to check

Example: post.should allow("Elabs").as(:title)

Parameters:

  • attributes (*Array)

    The method name(s) that has the validation(s) attached to it



33
34
35
36
# File 'lib/elabs_matchers/matchers/allow.rb', line 33

def as(*attributes)
  @attributes = [*attributes]
  self
end

- (Boolean) does_not_match?(record)

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/elabs_matchers/matchers/allow.rb', line 19

def does_not_match?(record)
  @record = record
  errors.all? and correct_number_of_errors?
end

- (Object) failure_message_for_should



38
39
40
# File 'lib/elabs_matchers/matchers/allow.rb', line 38

def failure_message_for_should
  common_failure_message(:valid)
end

- (Object) failure_message_for_should_not



42
43
44
# File 'lib/elabs_matchers/matchers/allow.rb', line 42

def failure_message_for_should_not
  common_failure_message(:invalid)
end

- (Boolean) matches?(record)

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/elabs_matchers/matchers/allow.rb', line 14

def matches?(record)
  @record = record
  errors.none?
end