GithubHelp home page GithubHelp logo

isabella232 / rails-2-preload Goto Github PK

View Code? Open in Web Editor NEW

This project forked from papertrail/rails-2-preload

0.0 0.0 0.0 186 KB

Optimizes testing with Spin and Rails 2

Home Page: http://dev.paperlesspost.com/rails-2-preload/

License: MIT License

Ruby 100.00%

rails-2-preload's Introduction

Rails2Preload

Build Status

Description

The purpose of Rails2Preload is to optimize testing with Spin and Rails 2. It does this by splitting the Rails 2 initialization method (Rails::Initializer#process) into two phases: preload and postload. This gives us the capability of using Spin:

  • without having to reboot Rails every time a class is modified
  • without having to disable class caching

Installation

  1. Install the gem:

    $ gem install rails_2_preload --version 0.2
    
  2. In your .spin.rb file, add:

    require "rails_2_preload"
    require "rails_2_preload/spin"
    Rails2Preload::Spin.add_spin_hooks

Usage

  1. Start the Spin server

     $ spin serve --preload=config/environment.rb --load-path=test
    
  2. Push a test to Spin

     $ spin push test/unit/your_test.rb
    

Advanced

preload_until

By default, Rails2Preload preloads until the application classes (i.e. models) are loaded. This is optimal for unit testing. This can be changed, however, with the preload_until method. For example, for functional tests, we may want to preload everything up until the views:

Rails2Preload.preload_until(:load_view_paths)

To take advantage of this feature, create a Ruby script and preload it with Spin (instead of config/environment.rb):

$ spin serve --preload=test/functional/preload.rb --load-path=test
# test/functional/preload.rb
Rails2Preload.preload_until(:load_view_paths)
Rails2Preload.initialize_rails

Contributions

Bug reports, fixes, and new features are welcomed. If you'd like to contribute code, please:

  1. Fork the project

  2. Start a branch named for your new feature or bug

  3. Run (and add to) the unit tests

  4. Perform a pull request

Thanks!

rails-2-preload's People

Contributors

quirkey avatar toddmazierski 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.