cross_spec_rails

Adds http endpoint for requesting factories and other goodies


License
MIT
Install
gem install cross_spec_rails -v 0.1.4

Documentation

CrossSpecRails

Provides integrations between cross spec ruby and Rails.

Installation

Add this line to your application's Gemfile:

gem 'cross_spec_rails'

And then execute:

$ bundle

Usage

Mount the engine in your routes file like

if Rails.env.test?
  mount CrossSpecRails::Engine, at: "/cross_spec"
end

Requesting factory data over http

N.B only FactoryGirl/FactoryBot are supported right now.

curl -X POST http://localhost:5020/cross_spec/factories/user

Note the URL namespace from the routes.rb of cross_spec followed by the /factories path followed by the name of your factory.

You can also specify attributes for the factory using a query string like

curl -X POST http://localhost:5020/cross_spec/factories/user?attributes[email]=julie@example.com&attributes[name]=Julie

Traits are supported as well

curl -X POST http://localhost:5020/cross_spec/factories/user?traits[]=admin&traits[]=with_articles

You can control the response format with to_json_args

curl -X POST http://localhost:5020/cross_spec/factories/user?to_json_args[include]=articles

See the to_json docs for supported params. The object provided in the request is passed directly to that method

Finally the bulk api is also supported

curl -X POST http://localhost:5020/cross_spec/factories_list/user?num=4

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.