Class: JsonExpressions::RSpec::Matchers::MatchJsonExpression
- Inherits:
-
Object
- Object
- JsonExpressions::RSpec::Matchers::MatchJsonExpression
- Defined in:
- lib/json_expressions/rspec/matchers/match_json_expression.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object (also: #failure_message)
- #failure_message_for_should_not ⇒ Object (also: #failure_message_when_negated)
-
#initialize(expected) ⇒ MatchJsonExpression
constructor
A new instance of MatchJsonExpression.
- #matches?(target) ⇒ Boolean (also: #===)
Constructor Details
#initialize(expected) ⇒ MatchJsonExpression
Returns a new instance of MatchJsonExpression.
8 9 10 11 12 13 14 |
# File 'lib/json_expressions/rspec/matchers/match_json_expression.rb', line 8 def initialize(expected) if JsonExpressions::Matcher === expected @expected = expected else @expected = JsonExpressions::Matcher.new(expected) end end |
Instance Method Details
#description ⇒ Object
32 33 34 |
# File 'lib/json_expressions/rspec/matchers/match_json_expression.rb', line 32 def description "should equal JSON expression #{@expected.inspect}" end |
#failure_message_for_should ⇒ Object Also known as: failure_message
22 23 24 |
# File 'lib/json_expressions/rspec/matchers/match_json_expression.rb', line 22 def "expected #{@target.inspect} to match JSON expression #{@expected.inspect}\n" + @expected.last_error end |
#failure_message_for_should_not ⇒ Object Also known as: failure_message_when_negated
27 28 29 |
# File 'lib/json_expressions/rspec/matchers/match_json_expression.rb', line 27 def "expected #{@target.inspect} not to match JSON expression #{@expected.inspect}" end |
#matches?(target) ⇒ Boolean Also known as: ===
16 17 18 19 |
# File 'lib/json_expressions/rspec/matchers/match_json_expression.rb', line 16 def matches?(target) @target = (String === target) ? JSON.parse(target) : target @expected =~ @target end |