Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

52 lines (44 sloc) 1.246 kB
require 'rest-core/test'
describe RC::JsonResponse do
describe 'app' do
def app
@app ||= RC::JsonResponse.new(RC::Dry.new, true)
end
should 'do nothing' do
expected = {RC::RESPONSE_BODY => nil,
RC::REQUEST_HEADERS => {'Accept' => 'application/json'}}
app.call({}){ |response| response.should.eq(expected) }
end
should 'decode' do
expected = {RC::RESPONSE_BODY => {},
RC::REQUEST_HEADERS => {'Accept' => 'application/json'}}
app.call(RC::RESPONSE_BODY => '{}'){ |response|
response.should.eq(expected)
}
end
end
describe 'client' do
def client
@client ||= RC::Builder.client do
use RC::JsonResponse, true
run Class.new{
def call env
yield(env.merge(RC::RESPONSE_BODY => '{}'))
end
}
end
end
should 'do nothing' do
expected = '{}'
client.new(:json_response => false).get(''){ |response|
response.should.eq(expected)
}.get('').should.eq(expected)
end
should 'decode' do
expected = {}
client.new.get(''){ |response|
response.should.eq(expected)
}.get('').should.eq(expected)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.