Class: JsonMatchers::RSpec
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- JsonMatchers::RSpec
- Defined in:
- lib/json_matchers/rspec.rb
Instance Attribute Summary collapse
-
#schema_name ⇒ Object
readonly
Returns the value of attribute schema_name.
Instance Method Summary collapse
- #failure_message(response) ⇒ Object
- #failure_message_when_negated(response) ⇒ Object
-
#initialize(schema_name, **options) ⇒ RSpec
constructor
A new instance of RSpec.
- #schema_body ⇒ Object
- #schema_path ⇒ Object
Constructor Details
#initialize(schema_name, **options) ⇒ RSpec
Returns a new instance of RSpec.
7 8 9 10 11 |
# File 'lib/json_matchers/rspec.rb', line 7 def initialize(schema_name, **) @schema_name = schema_name super(JsonMatchers::Matcher.new(schema_path, )) end |
Instance Attribute Details
#schema_name ⇒ Object (readonly)
Returns the value of attribute schema_name.
5 6 7 |
# File 'lib/json_matchers/rspec.rb', line 5 def schema_name @schema_name end |
Instance Method Details
#failure_message(response) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/json_matchers/rspec.rb', line 13 def (response) <<-FAIL.strip_heredoc expected #{response.body} to match schema "#{schema_name}": #{schema_body} --- #{} FAIL end |
#failure_message_when_negated(response) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/json_matchers/rspec.rb', line 30 def (response) <<-FAIL.strip_heredoc expected #{response.body} not to match schema "#{schema_name}": #{schema_body} --- #{} FAIL end |
#schema_body ⇒ Object
51 52 53 |
# File 'lib/json_matchers/rspec.rb', line 51 def schema_body File.read(schema_path) end |
#schema_path ⇒ Object
47 48 49 |
# File 'lib/json_matchers/rspec.rb', line 47 def schema_path JsonMatchers.path_to_schema(schema_name) end |