Skip to content

Commit

Permalink
test: add spec for Accept */*
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Apr 4, 2019
1 parent d7aef28 commit 539e45f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions spec/integration/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
require 'db'

module PactBroker

describe App do

before do
TestDataBuilder.new.create_pact_with_hierarchy('Some Consumer', '1.0', 'Some Provider').and_return(:pact)
end
Expand Down Expand Up @@ -34,7 +32,6 @@ module PactBroker
subject { get path, '', env; last_response }

describe "a request for root" do

let(:path) { '/' }

it "returns the relationships page" do
Expand Down Expand Up @@ -102,7 +99,6 @@ module PactBroker

context "when the HALBrowser is enabled" do
context "when application/hal+json is also specified as an Accept" do

let(:env) { {'HTTP_ACCEPT' => 'text/html;application/hal+json'} }
let(:path) { '/something' }

Expand All @@ -115,7 +111,6 @@ module PactBroker

context "when the HALBrowser is not enabled" do
context "when application/hal+json is also specified as an Accept" do

let(:hal_browser_enabled) { false }
let(:env) { {'HTTP_ACCEPT' => 'text/html;application/hal+json'} }
let(:path) { '/something' }
Expand All @@ -127,7 +122,6 @@ module PactBroker
end

context "when a .csv extension is specified" do

let(:path) { '/groups/Some%20Consumer.csv' }

it "returns the CSV Content-Type" do
Expand All @@ -138,9 +132,24 @@ module PactBroker

end

context "when no Accept header is specified" do
context "when the Accept header is */* (default curl)" do
let(:env) { { 'HTTP_ACCEPT' => '*/*' } }

subject { get path, '', env; last_response }

describe "a request for root" do
let(:path) { "/" }

it "returns an API response" do
expect(subject.status).to eq 200
expect(subject.headers['Content-Type']).to include 'application/hal+json'
end
end
end

context "when no Accept header is specified" do
let(:env) { {} }

subject { get path, '', env; last_response }

describe "a request for root" do
Expand Down Expand Up @@ -169,7 +178,6 @@ module PactBroker
expect(subject.headers['Content-Type']).to include 'text/css'
end
end

end

context "when the diagnostic endpoints are enabled" do
Expand Down

0 comments on commit 539e45f

Please sign in to comment.