Git Product home page Git Product logo

factory_faster's Introduction

FactoryFaster

FactoryFaster optimizes your Rails app's FactoryGirl usage by replacing create with build where it's safe to do so.

Installation

Add this line to your application's Gemfile in the 'development' group:

gem 'factory_faster'

And then execute:

$ bundle

Usage

Process just one file with:

bundle exec script/rails runner "FactoryFaster::Batch.new('test/unit/foo_test.rb').process"

Or if you want to include the gem but not require it in your Gemfile:

bundle exec script/rails runner "require 'factory_faster' ; FactoryFaster::Batch.new('test/unit/foo_test.rb').process"

Or use a glob to process lots of files:

bundle exec script/rails runner "FactoryFaster::Batch.new('test/unit/*.rb').process"

The output will be something like this:

foo> $ bundle exec script/rails runner "FactoryFaster::Batch.new('test/unit/foo_test.rb').process"
Processing test/unit/foo_test.rb
Checking target 1 of 2 on line 42
Replacing create with build
Running test
Passed!
Checking target 2 of 2 on line 207
Replacing create with build
Running test
Passed!
2 of 2 could be replaced, so replacing those

BUGS / TODO

Adding a new test to a file invalidates all the skip line numbers after the addition. Subsequent runs then get both the old and the new line numbers, so gradually more and more lines get skipped.

FactoryFaster will miss the case there a test case has multiple calls to Factory.create and if more than one of then has to be switched to Factory.build in order to trigger an error.

FactoryFaster depends on sed to replace the code. It could use plain old Ruby instead.

FactoryFaster doesn't skip commented out lines.

Contributing

  1. Fork it ( http://github.com//factory_faster/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 new Pull Request

Contributors

  • Tom Copeland - author
  • Ronnie Miller - method name bugfix

factory_faster's People

Contributors

mlr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.