类: RSpec::Matchers::BuiltIn::Change 私有
- 继承自
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::Change
- 定义于
- lib/rspec/matchers/built_in/change.rb
概览
此类是私有 API 的一部分。 应尽量避免使用此类,因为它可能会在将来被删除或修改。
为 change
提供实现。不建议直接实例化。
常量摘要
从 BaseMatcher 继承的常量
实例方法摘要 折叠
-
#by(expected_delta) ⇒ Object
指定预期更改的增量。
-
#by_at_least(minimum) ⇒ Object
指定预期更改的最小增量。
-
#by_at_most(maximum) ⇒ Object
指定预期更改的最大增量。
- #description ⇒ String 私有
- #does_not_match?(event_proc) ⇒ Boolean 私有
- #failure_message ⇒ String 私有
- #failure_message_when_negated ⇒ String 私有
-
#from(value) ⇒ Object
指定原始值。
-
#to(value) ⇒ Object
指定您期望的新值。
从 BaseMatcher 继承的方法
#diffable?, #expects_call_stack_jump?, #match_unless_raises
从 Composable 包含的方法
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
实例方法详情
#by(expected_delta) ⇒Object
指定预期更改的增量。
10 11 12 13 14 |
# File 'lib/rspec/matchers/built_in/change.rb', line 10 def by(expected_delta) ChangeRelatively.new(change_details, expected_delta, :by) do |actual_delta| values_match?(expected_delta, actual_delta) end end |
#by_at_least(minimum) ⇒Object
指定预期更改的最小增量。
18 19 20 21 22 |
# File 'lib/rspec/matchers/built_in/change.rb', line 18 def by_at_least(minimum) ChangeRelatively.new(change_details, minimum, :by_at_least) do |actual_delta| actual_delta >= minimum end end |
#by_at_most(maximum) ⇒Object
指定预期更改的最大增量。
26 27 28 29 30 |
# File 'lib/rspec/matchers/built_in/change.rb', line 26 def by_at_most(maximum) ChangeRelatively.new(change_details, maximum, :by_at_most) do |actual_delta| actual_delta <= maximum end end |
#description ⇒String
此方法是私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被删除或修改。
71 72 73 |
# File 'lib/rspec/matchers/built_in/change.rb', line 71 def description "change #{change_details.value_representation}" end |
#does_not_match?(event_proc) ⇒Boolean
此方法是私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被删除或修改。
50 51 52 53 |
# File 'lib/rspec/matchers/built_in/change.rb', line 50 def does_not_match?(event_proc) raise_block_syntax_error if block_given? perform_change(event_proc) && !change_details.changed? end |
#failure_message ⇒String
此方法是私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被删除或修改。
57 58 59 60 |
# File 'lib/rspec/matchers/built_in/change.rb', line 57 def "expected #{change_details.value_representation} to have changed, " \ "but #{positive_failure_reason}" end |
#failure_message_when_negated ⇒String
此方法是私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被删除或修改。
64 65 66 67 |
# File 'lib/rspec/matchers/built_in/change.rb', line 64 def "expected #{change_details.value_representation} not to have changed, " \ "but #{negative_failure_reason}" end |
#from(value) ⇒Object
指定原始值。
40 41 42 |
# File 'lib/rspec/matchers/built_in/change.rb', line 40 def from(value) ChangeFromValue.new(change_details, value) end |
#to(value) ⇒Object
指定您期望的新值。
34 35 36 |
# File 'lib/rspec/matchers/built_in/change.rb', line 34 def to(value) ChangeToValue.new(change_details, value) end |