Sha256: 858c91a6d1c8e1c332d43cd00f3d6b27bdcf4c2d0de20a49869e7b3fca3d4373

Contents?: true

Size: 1.85 KB

Versions: 16

Compression:

Stored size: 1.85 KB

Contents

module JsonapiHelper

  shared_context "jsonapi" do

    def app
      Flapjack::Gateways::JSONAPI
    end

    let(:contact)      { double(Flapjack::Data::Contact, :id => '21') }
    let(:contact_core) {
      {'id'         => contact.id,
       'first_name' => "Ada",
       'last_name'  => "Lovelace",
       'email'      => "ada@example.com",
       'tags'       => ["legend", "first computer programmer"]
      }
    }

    let(:redis)           { double(::Redis) }

    let(:semaphore) {
      double(Flapjack::Data::Semaphore, :resource => 'folly',
             :key => 'semaphores:folly', :expiry => 30, :token => 'spatulas-R-us')
    }

    let(:jsonapi_post_env) {
      {'CONTENT_TYPE' => 'application/json',
       'HTTP_ACCEPT'  => 'application/json; q=0.8, application/vnd.api+json'}
    }

    let(:jsonapi_patch_env) {
      {'CONTENT_TYPE' => 'application/json-patch+json',
       'HTTP_ACCEPT'  => 'application/json; q=0.8, application/vnd.api+json'}
    }

    before(:all) do
      Flapjack::Gateways::JSONAPI.class_eval {
        set :raise_errors, true
      }
    end

    before(:each) do
      expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
      Flapjack::Gateways::JSONAPI.instance_variable_set('@config', {})
      Flapjack::Gateways::JSONAPI.instance_variable_set('@logger', @logger)
      Flapjack::Gateways::JSONAPI.start
    end

    after(:each) do
      if last_response.status >= 200 && last_response.status < 300
        expect(last_response.headers.keys).to include('Access-Control-Allow-Methods')
        expect(last_response.headers['Access-Control-Allow-Origin']).to eq("*")
        unless last_response.status == 204
          expect(Oj.load(last_response.body)).to be_a(Enumerable)
          expect(last_response.headers['Content-Type']).to eq(Flapjack::Gateways::JSONAPI::JSONAPI_MEDIA_TYPE)
        end
      end
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
flapjack-0.9.6 spec/support/jsonapi_helper.rb
flapjack-0.9.5 spec/support/jsonapi_helper.rb
flapjack-0.9.4 spec/support/jsonapi_helper.rb
flapjack-1.1.0 spec/support/jsonapi_helper.rb
flapjack-1.0.0 spec/support/jsonapi_helper.rb
flapjack-1.0.0rc6 spec/support/jsonapi_helper.rb
flapjack-1.0.0rc5 spec/support/jsonapi_helper.rb
flapjack-0.9.3 spec/support/jsonapi_helper.rb
flapjack-1.0.0rc3 spec/support/jsonapi_helper.rb
flapjack-1.0.0rc2 spec/support/jsonapi_helper.rb
flapjack-0.9.2 spec/support/jsonapi_helper.rb
flapjack-0.9.1 spec/support/jsonapi_helper.rb
flapjack-1.0.0rc1 spec/support/jsonapi_helper.rb
flapjack-0.9.0 spec/support/jsonapi_helper.rb
flapjack-0.8.12 spec/support/jsonapi_helper.rb
flapjack-0.8.11 spec/support/jsonapi_helper.rb