类: RSpec::Matchers::BuiltIn::HaveAttributes 私有
- 继承
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::HaveAttributes
- 定义于
- lib/rspec/matchers/built_in/have_attributes.rb
概述
此类是私有 API 的一部分。 应尽可能避免使用此类,因为它可能在将来被移除或更改。
提供 have_attributes
的实现。不建议直接实例化。
常量摘要
从 BaseMatcher 继承的常量
实例方法摘要 折叠
- #description ⇒ String 私有
- #diffable? ⇒ Boolean 私有
- #does_not_match?(actual) ⇒ Boolean 私有
- #failure_message ⇒ String 私有
- #failure_message_when_negated ⇒ String 私有
-
#initialize(expected) ⇒ HaveAttributes 构造函数 私有
HaveAttributes 的新实例。
- #matches?(actual) ⇒ Boolean 私有
从 BaseMatcher 继承的方法
#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(expected) ⇒HaveAttributes
此方法是私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
返回 HaveAttributes 的新实例。
11 12 13 14 15 16 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 11 def initialize(expected) @expected = expected @values = {} @respond_to_failed = false @negated = false end |
实例方法详细信息
#description ⇒String
此方法是私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
43 44 45 46 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 43 def description described_items = surface_descriptions_in(expected) improve_hash_formatting "have attributes #{RSpec::Support::ObjectFormatter.format(described_items)}" end |
#diffable? ⇒Boolean
此方法是私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
50 51 52 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 50 def diffable? !@respond_to_failed && !@negated end |
#does_not_match?(actual) ⇒Boolean
此方法是私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
34 35 36 37 38 39 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 34 def does_not_match?(actual) @actual = actual @negated = true return false unless respond_to_attributes? perform_match(:none?) end |
#failure_message ⇒String
此方法是私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
56 57 58 59 60 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 56 def do "expected #{actual_formatted} to #{description} but had attributes #{ formatted_values }" end end |
#failure_message_when_negated ⇒String
此方法是私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
64 65 66 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 64 def { "expected #{actual_formatted} not to #{description}" } end |
#matches?(actual) ⇒Boolean
此方法是私有 API 的一部分。 应尽可能避免使用此方法,因为它可能在将来被移除或更改。
25 26 27 28 29 30 |
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 25 def matches?(actual) @actual = actual @negated = false return false unless respond_to_attributes? perform_match(:all?) end |