Sha256: e47c61e96fa3773ec38caadf95cb9a8a32af4f764fe594e3699e48c2faf90202

Contents?: true

Size: 1.87 KB

Versions: 5

Compression:

Stored size: 1.87 KB

Contents

describe 'Animal Endpoint', :type => :request do

  context :v1 do

    let(:first_animal) { Animal.new name: 'Cow', description: 'Are the most common type of large domesticated ungulates. They are a prominent modern member of the subfamily Bovinae', phylum: 'Chordata', diet: 'vegetarian' }
    let(:second_animal) { Animal.new name: 'Capybara', description: 'is the largest rodent in the world. Its closest relatives are guinea pigs and rock cavies', phylum: 'Chordata', diet: 'vegetarian' }

    context 'GET' do
      describe '/foo' do
        before(:each){ allow(::Animal).to receive(:all) { [first_animal, second_animal] } }
        
        it 'gets all animals with default transformation' do
          expected_response = "[{\"name\":\"Cow\",\"description\":\"Are the most common type of large domesticated ungulates. They are a prominent modern member of the subfamily Bovinae\",\"phylum\":\"Chordata\",\"diet\":\"vegetarian\"},{\"name\":\"Capybara\",\"description\":\"is the largest rodent in the world. Its closest relatives are guinea pigs and rock cavies\",\"phylum\":\"Chordata\",\"diet\":\"vegetarian\"}]"      
          get '/api/v1/animals/foo'
          expect(response.status).to eq 200
          expect(response.body).to match expected_response
          #RSpec::Mocks.space.proxy_for(::User).reset # It is not necessary
        end

      end
      describe '/bar/:id' do
        before(:each){ allow(::Animal).to receive(:find) { first_animal } }

        it 'gets specific animal with default transformation' do
          expected_response = "{\"name\":\"Cow\",\"description\":\"Are the most common type of large domesticated ungulates. They are a prominent modern member of the subfamily Bovinae\"}"
          get '/api/v1/animals/bar/0'
          expect(response.status).to eq 200
          expect(response.body).to match expected_response
        end

      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-transformations-0.0.5 spec/api/animal_spec.rb
grape-transformations-0.0.4 spec/api/animal_spec.rb
grape-transformations-0.0.3 spec/api/animal_spec.rb
grape-transformations-0.0.2 spec/api/animal_spec.rb
grape-transformations-0.0.1 spec/api/animal_spec.rb