Class: RSpec::Undefined::Matchers::BeUndefined
- Inherits:
-
Object
- Object
- RSpec::Undefined::Matchers::BeUndefined
- Defined in:
- lib/rspec/undefined/matchers.rb
Constant Summary collapse
- LOCATION_SEARCH_DEPTH =
20
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#expected_recorded ⇒ Object
readonly
Returns the value of attribute expected_recorded.
-
#matcher_name ⇒ Object
readonly
Returns the value of attribute matcher_name.
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(inner: nil, expected_value: nil, expected_provided: false, category: nil) ⇒ BeUndefined
constructor
kwarg: :expected_provided で「キーワードが明示された」を示す(nil 期待値との区別).
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(inner: nil, expected_value: nil, expected_provided: false, category: nil) ⇒ BeUndefined
kwarg: :expected_provided で「キーワードが明示された」を示す(nil 期待値との区別)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rspec/undefined/matchers.rb', line 15 def initialize(inner: nil, expected_value: nil, expected_provided: false, category: nil) @matcher_name = "be_undefined" @inner = inner @expected_value = expected_value @expected_provided = expected_provided @category = category @expected_recorded = if @inner describe_inner(@inner) elsif @expected_provided @expected_value.respond_to?(:description) ? @expected_value.description : @expected_value else :__any__ end end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
12 13 14 |
# File 'lib/rspec/undefined/matchers.rb', line 12 def actual @actual end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
12 13 14 |
# File 'lib/rspec/undefined/matchers.rb', line 12 def category @category end |
#expected_recorded ⇒ Object (readonly)
Returns the value of attribute expected_recorded.
12 13 14 |
# File 'lib/rspec/undefined/matchers.rb', line 12 def expected_recorded @expected_recorded end |
#matcher_name ⇒ Object (readonly)
Returns the value of attribute matcher_name.
12 13 14 |
# File 'lib/rspec/undefined/matchers.rb', line 12 def matcher_name @matcher_name end |
Instance Method Details
#description ⇒ Object
52 53 54 55 |
# File 'lib/rspec/undefined/matchers.rb', line 52 def description suffix = category ? " [#{category}]" : "" "は未確定仕様#{suffix}である" end |
#does_not_match?(actual) ⇒ Boolean
38 39 40 41 |
# File 'lib/rspec/undefined/matchers.rb', line 38 def does_not_match?(actual) @actual = actual false end |
#failure_message ⇒ Object
43 44 45 46 |
# File 'lib/rspec/undefined/matchers.rb', line 43 def "undefined[#{matcher_name}] at #{location_summary}: " \ "category=#{category.inspect} expected=#{@expected_recorded.inspect} actual=#{@actual.inspect}" end |
#failure_message_when_negated ⇒ Object
48 49 50 |
# File 'lib/rspec/undefined/matchers.rb', line 48 def "undefined matcher は否定形では使えません" end |
#matches?(actual) ⇒ Boolean
31 32 33 34 35 36 |
# File 'lib/rspec/undefined/matchers.rb', line 31 def matches?(actual) @actual = actual matched = evaluate(actual) record(matched) !RSpec::Undefined.configuration.strict? end |