0.01
No commit activity in last 3 years
No release in over 3 years
Contracto for RSpec
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 10.0
~> 3.2

Runtime

~> 0.4
~> 0.13
 Project Readme

Contracto/RSpec

EL Passion

Installation

Add this line to your application's Gemfile:

gem 'contracto-rspec'

And then execute:

$ bundle

Usage

  • Add following lines in your rails_helper.rb:
require 'contracto/rspec'

RSpec.configure do |config|
  Contracto::RSpec.start!(git: 'https://github.com/{github_user}/{contract_repository_name}.git')
  #...
end

- Test your API request by comparing its responses to contract responses:
require 'rails_helper'

RSpec.describe 'Users', type: :request do
  describe 'GET /users' do
    it do
      get users_path
      compare_json_with_contract!(ignore: [:id])
    end
  end

  describe 'GET /users/:id' do
    it do
      get user_path(User.first)
      compare_json_with_contract!(ignore: [:created_at, :updated_at])
    end
  end
end

Contributing

  1. Fork it ( https://github.com/[my-github-username]/contracto-rspec/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request