Class: Logux::Test::Matchers::ResponseChunks
- Defined in:
- lib/logux/test/matchers/response_chunks.rb
Instance Attribute Summary collapse
-
#excludes ⇒ Object
readonly
Returns the value of attribute excludes.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Attributes inherited from Base
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(meta:, includes:, excludes: []) ⇒ ResponseChunks
constructor
A new instance of ResponseChunks.
- #matches?(actual) ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(meta:, includes:, excludes: []) ⇒ ResponseChunks
Returns a new instance of ResponseChunks.
11 12 13 14 15 |
# File 'lib/logux/test/matchers/response_chunks.rb', line 11 def initialize(meta:, includes:, excludes: []) @meta = @includes = includes @excludes = excludes end |
Instance Attribute Details
#excludes ⇒ Object (readonly)
Returns the value of attribute excludes.
9 10 11 |
# File 'lib/logux/test/matchers/response_chunks.rb', line 9 def excludes @excludes end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
9 10 11 |
# File 'lib/logux/test/matchers/response_chunks.rb', line 9 def includes @includes end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
9 10 11 |
# File 'lib/logux/test/matchers/response_chunks.rb', line 9 def @meta end |
Instance Method Details
#failure_message ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/logux/test/matchers/response_chunks.rb', line 23 def data = "expected that #{pretty(@actual)} to has " \ "#{includes.join(', ')} chunks" !excludes.empty? && data += " and doesn't" \ " has #{excludes.join(', ')} chunks" data end |
#matches?(actual) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/logux/test/matchers/response_chunks.rb', line 17 def matches?(actual) @actual = JSON.parse(actual.body) match_includes? && match_excludes? end |