Logo: Relish

  1. Sign in

Project: Rest-assured

create double

  • @ruby_api

As ruby developer
I want to be able to create doubles via client api
So that interactions with rest-assured server are completely hidden from me

Scenarios
default options
When
I create a double:
@double = RestAssured::Double.create(:fullpath => '/some/api')
Then
the following should be true:
@double.verb.should             == 'GET'
@double.response_headers.should == {}
@double.status.should           == 200
@double.content.should          == nil

get @double.fullpath
last_response.should be_ok
specify response headers
When
I create a double:
@double = RestAssured::Double.create(:fullpath => '/some/api', :response_headers => { 'Content-Type2' => 'text/html' })
Then
the following should be true:
@double.response_headers.should == { 'Content-Type2' => 'text/html' }

get @double.fullpath
last_response.headers['Content-Type2'].should == 'text/html'
specify content
When
I create a double:
@double = RestAssured::Double.create(:fullpath => '/some/api', :content => 'awesome')
Then
the following should be true:
@double.content = 'awesome'

get @double.fullpath
last_response.body == 'awesome'
specify verb
When
I create a double:
@double = RestAssured::Double.create(:fullpath => '/some/api', :verb => 'POST')
Then
the following should be true:
@double.verb = 'POST'

get @double.fullpath
last_response.should_not be_ok

post @double.fullpath
last_response.should be_ok
specify status
When
I create a double:
@double = RestAssured::Double.create(:fullpath => '/some/api', :status => 302)
Then
the following should be true:
@double.status = 302

get @double.fullpath
last_response.status == 302

Last published almost 7 years ago by artemave.