类: RSpec::Matchers::BuiltIn::StartOrEndWith 私有
- 继承
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::StartOrEndWith
- 定义在
- lib/rspec/matchers/built_in/start_or_end_with.rb
概述
此类属于私有 API 部分。 应尽可能避免使用此类,因为它可能会在将来被移除或更改。
end_with
和 start_with
匹配器的基类。不建议直接实例化。
常量摘要
从 BaseMatcher 继承的常量
实例方法摘要 折叠
- #description ⇒ String 私有
- #failure_message ⇒ String 私有
-
#initialize(*expected) ⇒ StartOrEndWith 构造函数 私有
StartOrEndWith 的新实例。
从 BaseMatcher 继承的方法
#diffable?, #expects_call_stack_jump?, #match_unless_raises, #matches?, #supports_block_expectations?
从 BaseMatcher::DefaultFailureMessages 包含的方法
从 Composable 包含的方法
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
构造函数详细信息
#initialize(*expected) ⇒StartOrEndWith
此方法属于私有 API 部分。 应尽可能避免使用此方法,因为它可能会在将来被移除或更改。
返回 StartOrEndWith 的新实例。
8 9 10 11 |
# File 'lib/rspec/matchers/built_in/start_or_end_with.rb', line 8 def initialize(*expected) @actual_does_not_have_ordered_elements = false @expected = expected.length == 1 ? expected.first : expected end |
实例方法详细信息
#description ⇒String
此方法属于私有 API 部分。 应尽可能避免使用此方法,因为它可能会在将来被移除或更改。
27 28 29 30 31 32 |
# File 'lib/rspec/matchers/built_in/start_or_end_with.rb', line 27 def description return super unless Hash === expected english_name = EnglishPhrasing.split_words(self.class.matcher_name) description_of_expected = surface_descriptions_in(expected).inspect "#{english_name} #{description_of_expected}" end |
#failure_message ⇒String
此方法属于私有 API 部分。 应尽可能避免使用此方法,因为它可能会在将来被移除或更改。
15 16 17 18 19 20 21 22 23 |
# File 'lib/rspec/matchers/built_in/start_or_end_with.rb', line 15 def super.tap do |msg| if @actual_does_not_have_ordered_elements msg << ", but it does not have ordered elements" elsif !actual.respond_to?(:[]) msg << ", but it cannot be indexed using #[]" end end end |