Sha256: 798b4bcde2b1e4b31b093ecc75c8906265e1675ba13771cbd262341dbdf3f6c1

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe API::V2::Widgets do
  describe 'GET /widgets' do
    before do
      3.times { FactoryGirl.create(:widget) }
      req :get, "/widgets", { version: 'v2' }
    end

    it 'returns a list of widgets' do
      expect(response.status).to eql 200
      expect(json_result[:widgets].size).to eql 3
      expect(json_result[:widgets].map{|w| w[:id]}.uniq.size).to eql 3
    end

    it 'still uses the V1 response structure' do
      widget = json_result[:widgets].first
      expect(widget[:radioactive]).to eql true
      expect(widget[:rads]).to eql 150
    end
  end

  describe "GET /widgets/:id" do
    let(:widget) { FactoryGirl.create(:widget) }
    before do
      req :get, "/widgets/#{widget.id}", { version: 'v2' }
    end
    it "returns a widget by id" do
      expect(response.status).to eql 200
      expect(json_result[:widgets].size).to eql 1
      expect(json_result[:widgets].first[:name]).to eql "Magical Widget Alpha"
    end

    it "includes the new V2 format for radioactive hash" do
      widget = json_result[:widgets].first
      expect(widget[:radioactive]).to eql({ rads: 150, per_day: 7 })
      expect(widget[:rads]).to eql 150
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
grape_ape_rails-0.9.13 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.12 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.11 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.10 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.9 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.8 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.7 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.6 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.5 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.4 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.3 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.2 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.9.1 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.5.1 spec/requests/v2/widgets_spec.rb
grape_ape_rails-0.5.0 spec/requests/v2/widgets_spec.rb