类: RSpec::Matchers::BuiltIn::BeComparedTo 私有
- 继承
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::BeComparedTo
- 定义于
- lib/rspec/matchers/built_in/be.rb
概述
此类属于私有 API 的一部分。 应尽量避免使用此类,因为它可能会在将来被移除或更改。
提供 be <operator> value
的实现。不建议直接实例化。
常量摘要
从 BaseMatcher 继承的常量
RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED
实例方法摘要 折叠
- #description ⇒ String 私有
- #does_not_match?(actual) ⇒ Boolean 私有
- #failure_message ⇒ String 私有
- #failure_message_when_negated ⇒ String 私有
-
#initialize(operand, operator) ⇒ BeComparedTo 构造函数 私有
BeComparedTo 的新实例。
- #matches?(actual) ⇒ Boolean 私有
从 BaseMatcher 继承的方法
#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?
从 Composable 包含的方法
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
构造函数详情
#initialize(operand, operator) ⇒BeComparedTo
此方法属于私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被移除或更改。
返回 BeComparedTo 的新实例。
139 140 141 142 143 |
# File 'lib/rspec/matchers/built_in/be.rb', line 139 def initialize(operand, operator) @expected = operand @operator = operator @args = [] end |
实例方法详情
#description ⇒String
此方法属于私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被移除或更改。
178 179 180 |
# File 'lib/rspec/matchers/built_in/be.rb', line 178 def description "be #{@operator} #{expected_to_sentence}#{args_to_sentence}" end |
#does_not_match?(actual) ⇒Boolean
此方法属于私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被移除或更改。
151 152 153 154 155 |
# File 'lib/rspec/matchers/built_in/be.rb', line 151 def does_not_match?(actual) !perform_match(actual) rescue ArgumentError, NoMethodError false end |
#failure_message ⇒String
此方法属于私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被移除或更改。
159 160 161 162 |
# File 'lib/rspec/matchers/built_in/be.rb', line 159 def "expected: #{@operator} #{expected_formatted}\n" \ " got: #{@operator.to_s.gsub(/./, ' ')} #{actual_formatted}" end |
#failure_message_when_negated ⇒String
此方法属于私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被移除或更改。
166 167 168 169 170 171 172 173 174 |
# File 'lib/rspec/matchers/built_in/be.rb', line 166 def = "`expect(#{actual_formatted}).not_to " \ "be #{@operator} #{expected_formatted}`" if [:<, :>, :<=, :>=].include?(@operator) + " not only FAILED, it is a bit confusing." else end end |
#matches?(actual) ⇒Boolean
此方法属于私有 API 的一部分。 应尽量避免使用此方法,因为它可能会在将来被移除或更改。
145 146 147 148 149 |
# File 'lib/rspec/matchers/built_in/be.rb', line 145 def matches?(actual) perform_match(actual) rescue ArgumentError, NoMethodError false end |