wilddima / industry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Industry

<img src=“https://travis-ci.org/WildDima/Industry.svg?branch=master” alt=“Build Status” />

Ruby library which allow to create factory from ActiveRecord object

Installation

Add this line to your application’s Gemfile:

gem 'industry'

And then execute:

$ bundle

Or install it yourself as:

$ gem install Industry

Usage

# Create post
Post.create(title: 'test_post')

# In params we pass object(also we can pass path as second param)
$ rake Industry:factory_girl:create[Post.first]

And it will generate factory if file doesn’t exist, and path does exist:

FactoryGirl.define do
  factory :post do
    id 2
    title 'test'
    description nil
    published true
  end
end

Rake task has 3 params:

command

string of code, executing of which, will return object for factory girl

path (optional)

path to factories. By deafault, if RSpec is defined, it will use ‘spec/factories’, if not - ‘test/factories’

method (optional)

method for serialization. By default for ActiveRecord using :serializable_hash. If command from first param return not ActiveRecord object, you can use your own method for serialization, like :to_h etc.

Contributing

Bug reports and pull requests are welcome on GitHub at github.com/wilddima/Industry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.

License

The gem is available as open source under the terms of the [MIT License](opensource.org/licenses/MIT).

About

License:MIT License


Languages

Language:Ruby 97.8%Language:HTML 1.6%Language:Shell 0.6%