This is a demonstration project for using the Swift Pact library.
The application uses Carthage for building library dependencies. If you are not familiar with carthage, see Carthage for more details.
- Install the pact mock service gem (required for running the iOS Pact tests).
gem install pact-mock_service -v 0.9.0
NB: if you are using the system ruby, you will need to install the gem using sudo. Better options would be to use something like rbenv / rvm / chruby.
- Download and compile the iOS library dependencies:
CatKit $ carthage bootstrap --no-use-binaries --platform iOS
(Execute from the CatKit directory)
- Run the iOS unit tests. (can be done from within XCode if you prefer)
CatKit $ xcodebuild -project CatKit.xcodeproj -scheme CatKit clean test -sdk iphonesimulator
This will run the unit tests (Pact Tests). After the pact tests run successfully the generated pact files should live in the CatKit/tmp/pacts/
directory. A log of the pact test interactions can be found here CatKit/tmp/pact.log
. If the tests fail, try looking in here for details as to why.
Copy over the generated pact file from the iOS project, to the ruby server.
catkit-server $ cp ../CatKit/tmp/pacts/catkit_ios_app-catkit_service.json pacts/ios-app/
(Execute from the catkit-server directory)
Run the pact verification to verify that the server conforms to the CatKit client.
catkit-server $ bundle exec rake pact:verify
NB: to run the catkit-server:
catkit-server $ bundle exec rackup config.ru
- Swift Pact library
- The original pact library, with lots of background and guidelines Pact
- The pact mock server that the Swift library uses under the hood Pact mock service
- A pact broker for managing the generated pact files (so you don't have to manually copy them around!) Pact broker