Sha256: e25228de0e700147bf804e3fa7cb38a26ea7740c66be267c516ffd98313ccda7

Contents?: true

Size: 1.52 KB

Versions: 32

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

describe GunBroker::Feedback do

  let(:attrs) { JSON.parse(response_fixture('feedback')) }

  let(:user_id) { 123 }
  let(:endpoint) { [GunBroker::API::ROOT_URL, "/Feedback/#{user_id}"].join }
  let(:summary_endpoint) { [GunBroker::API::ROOT_URL, "/Feedback/Summary/#{user_id}"].join }

  context '.all' do
    it 'returns an array of the user feedback' do
      stub_request(:get, endpoint)
        .with(headers: headers)
        .to_return(body: response_fixture('feedback'))

      feedback = GunBroker::Feedback.all(user_id)
      expect(feedback.first).to be_a(GunBroker::Feedback)
    end
  end

  context '.summary' do
    it 'returns an array of the user feedback' do
      stub_request(:get, summary_endpoint)
        .with(headers: headers)
        .to_return(body: response_fixture('feedback-summary'))

      summary = GunBroker::Feedback.summary(user_id)
      expect(summary).to be_a(GunBroker::Response)
    end
  end

  context '#item' do
    let(:item_id) { attrs['results'].first['itemID'] }
    let(:item_endpoint) { [GunBroker::API::ROOT_URL, "/Items/#{item_id}"].join }

    it 'should have an Item' do
      stub_request(:get, endpoint)
        .with(headers: headers)
        .to_return(body: response_fixture('feedback'))

      stub_request(:get, item_endpoint)
        .with(headers: headers)
        .to_return(body: response_fixture('item'))

      all_feedback = GunBroker::Feedback.all(user_id)
      feedback = all_feedback.first

      expect(feedback.item).to be_a(GunBroker::Item)
    end
  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
gun_broker-1.4.8 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.7 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.6 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.5 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.4 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.3 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.2 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.1 spec/gun_broker/feedback_spec.rb
gun_broker-1.4.0 spec/gun_broker/feedback_spec.rb
gun_broker-1.3.2 spec/gun_broker/feedback_spec.rb
gun_broker-1.3.1 spec/gun_broker/feedback_spec.rb
gun_broker-1.3.0 spec/gun_broker/feedback_spec.rb
gun_broker-1.2.1.1 spec/gun_broker/feedback_spec.rb
gun_broker-1.2.1 spec/gun_broker/feedback_spec.rb
gun_broker-1.2.0 spec/gun_broker/feedback_spec.rb
gun_broker-1.1.3.1 spec/gun_broker/feedback_spec.rb
gun_broker-1.1.2 spec/gun_broker/feedback_spec.rb
gun_broker-1.1.1 spec/gun_broker/feedback_spec.rb
gun_broker-1.1.0 spec/gun_broker/feedback_spec.rb
gun_broker-1.0.0 spec/gun_broker/feedback_spec.rb