Class: ApiPi::Dsl
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Instance Method Summary collapse
-
#initialize(response) ⇒ Dsl
constructor
A new instance of Dsl.
- #parse(url, block) ⇒ Object
-
#test(desc, &block) ⇒ Object
Test blocks are used to group similar assertions into readable units.
Constructor Details
#initialize(response) ⇒ Dsl
Returns a new instance of Dsl.
8 9 10 11 |
# File 'lib/api_pi/dsl.rb', line 8 def initialize response @tests = {} @response = Map.new(response) end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/api_pi/dsl.rb', line 6 def response @response end |
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
6 7 8 |
# File 'lib/api_pi/dsl.rb', line 6 def tests @tests end |
Instance Method Details
#parse(url, block) ⇒ Object
13 14 15 16 17 |
# File 'lib/api_pi/dsl.rb', line 13 def parse url, block self.instance_eval(&block) pi = ApiPi::Case.new(url, tests) pi.investigate end |
#test(desc, &block) ⇒ Object
Test blocks are used to group similar assertions into readable units.
For example, you may want to put your header tests into one test block:
get 'example.com/user.json' do
test 'Headers have correct data' do
# You header assertions...
end
end
Inside of the test block, you would then put your header assertions. onceyou run your tests, your test blocks are grouped together and pass/fail based on assertions in the test block.
33 34 35 |
# File 'lib/api_pi/dsl.rb', line 33 def test desc, &block @tests[desc] = block end |