Class: RSpec::Matchers::BuiltIn::Change Private

Inherits:
Object
  • Object
show all
Includes:
Composable
Defined in:
lib/rspec/matchers/built_in/change.rb

Overview

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

Provides the implementation for change. Not intended to be instantiated directly.

Instance Method Summary (collapse)

Methods included from Composable

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

Instance Method Details

- (Object) by(expected_delta)

Specifies the delta of the expected change.



12
13
14
15
16
# File 'lib/rspec/matchers/built_in/change.rb', line 12

def by(expected_delta)
  ChangeRelatively.new(@change_details, expected_delta, :by) do |actual_delta|
    values_match?(expected_delta, actual_delta)
  end
end

- (Object) by_at_least(minimum)

Specifies a minimum delta of the expected change.



20
21
22
23
24
# File 'lib/rspec/matchers/built_in/change.rb', line 20

def by_at_least(minimum)
  ChangeRelatively.new(@change_details, minimum, :by_at_least) do |actual_delta|
    actual_delta >= minimum
  end
end

- (Object) by_at_most(maximum)

Specifies a maximum delta of the expected change.



28
29
30
31
32
# File 'lib/rspec/matchers/built_in/change.rb', line 28

def by_at_most(maximum)
  ChangeRelatively.new(@change_details, maximum, :by_at_most) do |actual_delta|
    actual_delta <= maximum
  end
end

- (String) description

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:

  • (String)


67
68
69
# File 'lib/rspec/matchers/built_in/change.rb', line 67

def description
  "change #{@change_details.message}"
end

- (String) failure_message

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:

  • (String)


55
56
57
# File 'lib/rspec/matchers/built_in/change.rb', line 55

def failure_message
  "expected #{@change_details.message} to have changed, but is still #{description_of @change_details.actual_before}"
end

- (String) failure_message_when_negated

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:

  • (String)


61
62
63
# File 'lib/rspec/matchers/built_in/change.rb', line 61

def failure_message_when_negated
  "expected #{@change_details.message} not to have changed, but did change from #{description_of @change_details.actual_before} to #{description_of @change_details.actual_after}"
end

- (Object) from(value)

Specifies the original value.



42
43
44
# File 'lib/rspec/matchers/built_in/change.rb', line 42

def from(value)
  ChangeFromValue.new(@change_details, value)
end

- (Object) to(value)

Specifies the new value you expect.



36
37
38
# File 'lib/rspec/matchers/built_in/change.rb', line 36

def to(value)
  ChangeToValue.new(@change_details, value)
end