Skip to content

Commit

Permalink
Merge branch 'master' into webhook-status
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 6, 2017
2 parents 5d16330 + 5fb16b6 commit a0a7c1b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ Use the HAL browser to view documentation as you browse.
### To have a play around on your local machine

* Install ruby 2.2.0 or later and bundler >= 1.12.0
* Windows users: get a Rails/Ruby installer from [RailsInstaller](http://railsinstaller.org/) and run it
* unix users just use your package manager
* Run `git clone git@github.com:pact-foundation/pact_broker.git && cd pact_broker/example`
* Run `bundle`
* Run `bundle install`
* Run `bundle exec rackup -p 8080`
* Open [http://localhost:8080](http://localhost:8080) and you should see a list containing the pact between the Zoo App and the Animal Service.
* Click on the arrow to see the generated HTML documentation.
Expand Down
11 changes: 5 additions & 6 deletions script/publish-new.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# set -x
set -e
BODY=$(ruby -e "require 'json'; j = JSON.parse(File.read('script/foo-bar.json')); j['interactions'][0]['providerState'] = 'it is ' + Time.now.to_s; puts j.to_json")
latest_url=$(curl http://localhost:9292/pacts/provider/Bar/consumer/Foo/latest | jq -r ._links.self.href)
next_version=$(echo ${latest_url} | ruby -e "require 'semver'; puts SemVer.parse(ARGF.read[/\d+\.\d\.\d+/]).tap{ | v| v.minor = v.minor + 1}.format('%M.%m.%p')")
echo ${BODY} >> tmp.json
curl -v -XPUT \-H "Content-Type: application/json" \
-d@tmp.json \
http://127.0.0.1:9292/pacts/provider/Bar/consumer/Foo/version/${next_version}
next_version=$(echo ${latest_url} | ruby -e "version = ARGF.read[/\d+\.\d+\.\d+/]; require 'semver'; puts SemVer.parse(version).tap{ | v| v.minor = v.minor + 1}.format('%M.%m.%p')")
echo ${BODY} > tmp.json
curl -v -XPUT \-H "Content-Type: application/json" -d@tmp.json \
http://localhost:9292/pacts/provider/Bar/consumer/Foo/version/${next_version}
rm tmp.json
echo ""
4 changes: 2 additions & 2 deletions script/seed.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env ruby

raise "Please supply database path" unless $1
raise "Please supply database path" unless ARGV[0]

$LOAD_PATH.unshift './lib'
$LOAD_PATH.unshift './spec'
ENV['RACK_ENV'] = 'development'
require 'sequel'
require 'logger'
DATABASE_CREDENTIALS = {logger: Logger.new($stdout), adapter: "sqlite", database: $1, :encoding => 'utf8'}
DATABASE_CREDENTIALS = {logger: Logger.new($stdout), adapter: "sqlite", database: ARGV[0], :encoding => 'utf8'}
connection = Sequel.connect(DATABASE_CREDENTIALS)
connection.timezone = :utc
require 'pact_broker'
Expand Down
6 changes: 6 additions & 0 deletions script/webhook-server.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
count = 0
run -> (env) {
count += 1
status = (count % 3 == 0) ? 200 : 500
puts "Received request"; [status, {}, ["Hello. This might be an error.\n"]]
}

0 comments on commit a0a7c1b

Please sign in to comment.