Permalink
Browse files

Initial commit

  • Loading branch information...
agenteo committed May 24, 2017
0 parents commit e1bebbe59387473cc001d6c8228f8c0b96bae0c1
Showing with 207 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 .ruby-gemset
  3. +1 −0 .ruby-version
  4. +8 −0 Gemfile
  5. +82 −0 Gemfile.lock
  6. +5 −0 README.md
  7. +1 −0 Rakefile
  8. +16 −0 app.rb
  9. +8 −0 concourse_api_contract_tests.sh
  10. +14 −0 concourse_api_contract_tests.yml
  11. +4 −0 config.ru
  12. +24 −0 reports/pacts/help.md
  13. +24 −0 spec/service_consumers/pact_helper.rb
  14. +11 −0 views/offers.json.erb
  15. +6 −0 views/token.json.erb
@@ -0,0 +1,2 @@
.idea
.log
@@ -0,0 +1 @@
spring-boot-pact-consumer
@@ -0,0 +1 @@
2.4.0
@@ -0,0 +1,8 @@
source "http://rubygems.org"
gem "rake"
gem "puma"
gem "sinatra"
gem "rspec"
gem 'pact'
@@ -0,0 +1,82 @@
GEM
remote: http://rubygems.org/
specs:
awesome_print (1.7.0)
diff-lcs (1.3)
find_a_port (1.0.1)
json (2.1.0)
mustermann (1.0.0)
pact (1.12.0)
json (> 1.8.5)
pact-mock_service (~> 2.0)
pact-support (~> 1.0)
rack-test (~> 0.6.2)
randexp (~> 0.1.7)
rspec (>= 2.14)
term-ansicolor (~> 1.0)
thor
webrick
pact-mock_service (2.1.0)
find_a_port (~> 1.0.1)
json
pact-support (~> 1.0)
rack
rack-test (~> 0.6.2)
rspec (>= 2.14)
term-ansicolor (~> 1.0)
thor
webrick
pact-support (1.0.1)
awesome_print (~> 1.1)
find_a_port (~> 1.0.1)
json
rack-test (~> 0.6.2)
randexp (~> 0.1.7)
rspec (>= 2.14)
term-ansicolor (~> 1.0)
thor
puma (3.8.2)
rack (2.0.3)
rack-protection (2.0.0)
rack
rack-test (0.6.3)
rack (>= 1.0)
rake (12.0.0)
randexp (0.1.7)
rspec (3.6.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
sinatra (2.0.0)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.0)
tilt (~> 2.0)
term-ansicolor (1.6.0)
tins (~> 1.0)
thor (0.19.4)
tilt (2.0.7)
tins (1.13.3)
webrick (1.3.1)
PLATFORMS
ruby
DEPENDENCIES
pact
puma
rake
rspec
sinatra
BUNDLED WITH
1.15.0
@@ -0,0 +1,5 @@
# Ruby Sinatra Pact Provider
This is an example API application providing two static endpoints: oauth token, offers.
The purpose is to test the pacts consumer driven test framework.
@@ -0,0 +1 @@
require 'pact/tasks'
16 app.rb
@@ -0,0 +1,16 @@
require 'sinatra'
class MyApp < Sinatra::Base
before do
content_type 'application/json; charset=utf-8'
end
get '/api/v1/offers' do
erb :"offers.json"
end
post '/oauth/token' do
erb :"token.json"
end
end
@@ -0,0 +1,8 @@
#!/bin/bash
echo "Copying latest API contracts..."
mkdir -p consumer_contracts
cp ../api-contracts/*.json consumer_contracts
gem install bundler
bundle
bundle exec rake pact:verify
@@ -0,0 +1,14 @@
---
platform: linux
image_resource:
type: docker-image
source: { repository: ruby, tag: '2.4-onbuild' }
inputs:
- name: sourcecode
- name: api-contracts
run:
path: ./concourse_api_contract_tests.sh
dir: sourcecode
@@ -0,0 +1,4 @@
require 'bundler/setup'
require_relative 'app'
run MyApp
@@ -0,0 +1,24 @@
# For assistance debugging failures
* The pact files have been stored locally in the following temp directory:
/Users/pivotal/workspace/ruby-sinatra-pact-provider/tmp/pacts
* The requests and responses are logged in the following log file:
/Users/pivotal/workspace/ruby-sinatra-pact-provider/log/pact.log
* Add BACKTRACE=true to the `rake pact:verify` command to see the full backtrace
* If the diff output is confusing, try using another diff formatter.
The options are :unix, :embedded and :list
Pact.configure do | config |
config.diff_formatter = :embedded
end
See https://github.com/realestate-com-au/pact/blob/master/documentation/configuration.md#diff_formatter for examples and more information.
* Check out https://github.com/realestate-com-au/pact/wiki/Troubleshooting
* Ask a question in the google users' group https://groups.google.com/forum/#!forum/pact-support
@@ -0,0 +1,24 @@
require 'pact/provider/rspec'
Pact.provider_states_for "aggregator_app" do
provider_state "OAuth endpoints" do
set_up do
# Your set up code goes here
end
end
provider_state "There are available travel offers" do
set_up do
# Your set up code goes here
end
end
end
Pact.service_provider "Seal_API" do
honours_pact_with 'aggregator_app' do
pact_uri 'consumer_contracts/aggregator_app-seal_API.json'
end
end
@@ -0,0 +1,11 @@
[
{
"uuid": "c5195583-ff66-454f-babb-77d8d8b6e463",
"destination_name": "Mantova",
"operator_name": "Ocean",
"status": "OK",
"price": 2000.09,
"offer_start_date": "2014-07-01 03:59:59",
"offer_end_date": "2014-07-01 03:59:59"
}
]
@@ -0,0 +1,6 @@
{
"access_token": "087d1a8c6eb2aef7fb814c8a1f483490ad5e97a6c3f028f61b5c15ed7f87a95c",
"created_at": 1490894849,
"expires_in": 7200,
"token_type": "Bearer"
}

0 comments on commit e1bebbe

Please sign in to comment.