Sha256: 4964c6fea41acc34aa829cf0de6f7fc6c0dcb12402983324f0da27168ef24f70
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' describe API::V1::Monkeys do describe 'GET /monkeys/:id/bananas' do let(:monkey) { FactoryGirl.create(:monkey_with_bananas) } it 'succeeds' do req :get, "/monkeys/#{monkey.id}/bananas" expect(response.status).to eql 200 end it 'returns the bananas in an array with key `bananas`' do req :get, "/monkeys/#{monkey.id}/bananas" expect(json_result.has_key?(:bananas)).to eql(true), "JSON expected to have key :bananas but it did not" expect(json_result[:bananas].size).to eql(monkey.bananas.size) end end describe "GET /monkeys/:id" do let(:monkey) { FactoryGirl.create(:monkey) } it "requires a version header" do get "/monkeys/#{monkey.id}", {}, { 'Content-Type' => 'application/json' } json = MultiJson.load(response.body, symbolize_keys: true) expect(json_error[:code]).to eql "UNAUTHORIZED" expect(json_error[:message]).to eql "[UNAUTHORIZED] Cannot determine API version from header info." expect(response.status).to eql 401 end it "returns a single monkey by id, using the ActiveModelSerializers" do req :get, "/monkeys/#{monkey.id}" expect(response.status).to eql 200 expect(json_result[:monkeys].size).to eql 1 expect(json_result[:monkeys].first[:name]).to eql "Frank the Monkey" end end describe "GET /monkeys" do it "returns multiple monkeys, using the ActiveModelSerializers" do 3.times { FactoryGirl.create :monkey } req :get, "/monkeys" expect(response.status).to eql 200 expect(json_result[:monkeys].size).to eql 3 end end describe "GET /nothings" do it "returns proper empty array [], using the ActiveModelSerializers" do 3.times { FactoryGirl.create :monkey } req :get, "/nothing_monkeys" expect(response.status).to eql 200 expect(json_result[:nothing_monkeys]).to eql([]) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape_ape_rails-0.9.13 | spec/requests/v1/monkeys_spec.rb |
grape_ape_rails-0.9.12 | spec/requests/v1/monkeys_spec.rb |
grape_ape_rails-0.9.11 | spec/requests/v1/monkeys_spec.rb |