Class: AssertResponse::AssertJSON
- Inherits:
-
Object
- Object
- AssertResponse::AssertJSON
- Defined in:
- lib/assert-response.rb
Overview
to allow checking against a parsed json object the code is instance_exec’d in the context of this object. you may call the assert- methods here (even without assert- prefix and you have the json object by calling the json method
Instance Method Summary collapse
-
#initialize(test_obj, json_string) ⇒ AssertJSON
constructor
A new instance of AssertJSON.
- #json ⇒ Object
- #method_missing(meth, *args, &code) ⇒ Object
Constructor Details
#initialize(test_obj, json_string) ⇒ AssertJSON
Returns a new instance of AssertJSON.
11 12 13 14 |
# File 'lib/assert-response.rb', line 11 def initialize(test_obj, json_string) @test_obj = test_obj @json_obj = JSON.parse(json_string) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &code) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/assert-response.rb', line 20 def method_missing(meth, *args, &code) if @test_obj.respond_to? meth @test_obj.send meth, *args, &code elsif @test_obj.respond_to? :"assert_#{meth}" @test_obj.send :"assert_#{meth}", *args, &code else @test_obj.send :method_missing, *args.unshift(meth), &code end end |
Instance Method Details
#json ⇒ Object
16 17 18 |
# File 'lib/assert-response.rb', line 16 def json @json_obj end |