Sha256: 67f703162b658ea07f6f2e3c647e556d302696eba1ecf732f8a46775eee1ebfc

Contents?: true

Size: 1.34 KB

Versions: 23

Compression:

Stored size: 1.34 KB

Contents

require 'agile_proxy/model/request_spec'
describe AgileProxy::RequestSpec do
  let(:response_class) do
    Class.new do
      def initialize(config = {})
        @config = config
      end
      attr_accessor :config

    end
  end
  let(:mock_response) { response_class.new }
  before :each do
    stub_const('AgileProxy::Response', response_class)
  end
  it 'Should allow a nested response' do
    subject.should accept_nested_attributes_for(:response)
  end
  it 'Should belong to a user' do
    expect(subject).to belong_to(:user)
  end
  it 'Should belong to an application' do
    expect(subject).to belong_to(:application)
  end
  it 'Should belong to a response' do
    expect(subject).to belong_to(:response)
  end

  describe 'Interface for the stub handler' do
    context '#call (without #and_return)' do
      let(:subject) { AgileProxy::RequestSpec.new(url: 'url') }
      it 'returns a 204 empty response' do
        expect(subject).to receive(:response).and_return nil
        expect(subject.call({}, {}, nil)).to eql [204, { 'Content-Type' => 'text/plain' }, '']
      end
    end
    context '#call With conditions' do
      let(:subject) { AgileProxy::RequestSpec.new(url: 'url', conditions: '{"a": 1, "b": 2}') }
      it 'returns a the correct json' do
        expect(subject.conditions_json).to eql('a' => 1, 'b' => 2)
      end

    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
agile-proxy-0.1.26 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-jruby-0.1.26-jruby spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-jruby-0.1.25-jruby spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.25 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.24 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.23 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.22 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.21 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.20 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.19 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.18 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.13 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.12 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.11 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.10 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.9 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.8 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.7 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.6 spec/unit/agile_proxy/model/request_spec_spec.rb
agile-proxy-0.1.5 spec/unit/agile_proxy/model/request_spec_spec.rb