Created
May 4, 2012 08:36
-
-
Save nilcolor/2593338 to your computer and use it in GitHub Desktop.
API spec sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Currency catalog API" do | |
let(:token) { create(:user).authentication_token } | |
before(:all) do | |
2.times { create :currency } | |
end | |
describe 'fetch the list of currencies' do | |
let(:url) { "/currencies" } | |
before(:all) do | |
get url, nil, { | |
'HTTP_ACCEPT' => "application/json", | |
'X-AUTH-TOKEN' => token | |
} | |
@response = response | |
end | |
context 'response' do | |
subject { @response } | |
it { should be_success } | |
end | |
context 'response body' do | |
subject { @response.body } | |
it { should have_json_path('message') } | |
it { should have_json_path('errors') } | |
it { should have_json_path('resource') } | |
context 'message' do | |
it { should have_json_type(:nil).at_path 'message' } | |
end | |
context 'errors' do | |
it { should have_json_type(:nil).at_path 'errors' } | |
end | |
context 'resource' do | |
subject { parse_json(@response.body)['resource'] } | |
it { subject.to_json.should be_json_eql( | |
%({"id":"1", "name":"Currency 1", "iso_code":"CR1", "iso_number":"000"}) | |
).at_path('0') } | |
it { should have(2).currencies } | |
end | |
end | |
end | |
describe 'fetch a currency' do | |
it { pending 'Yet no tests...' } | |
end | |
describe 'create new currency' do | |
it { pending 'Yet no tests...' } | |
end | |
describe 'modify currency' do | |
it { pending 'Yet no tests...' } | |
end | |
describe 'delete a currency' do | |
it { pending 'Yet no tests...' } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment