Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Dynamically generate Rails and Sinatra apps to be tested by Rack::Test
Ruby
Tree: 91340c5c65

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
framework_fixture.gemspec

README.md

FrameworkFixture

Dynamically generate Rails and Sinatra apps to be tested by Rack::Test.

Build Status

Why?

It is annoying to commit a bunch of Rails apps to my projects solely for the purpose of testing.

Seems more DRY to generate them when I run the test and automatically copy specific files into it.

Requirements

gem install framework_fixture

Add frameworks.yml to Fixtures Directory

rails:
  <3:
    rails2:
      - app/controllers/application_controller.rb
      - config/environment.rb
      - config/routes.rb
  <4:
    rails3:
      - app/controllers/application_controller.rb
      - config/application.rb
      - config/routes.rb
      - Gemfile
sinatra:
  <1:
    sinatra:
      - application.rb
  <2:
    sinatra:
      - application.rb

(See specs for example of what this configuration maps to)

Add to Test Helper

require 'rubygems'
require 'framework_fixture'

FrameworkFixture.generate(File.dirname(__FILE__) + '/fixtures')

Write Test

require 'spec_helper'

if FrameworkFixture.rails == '<4'
  describe 'Rails 3' do

    include Rack::Test::Methods

    def app
      FrameworkFixture.app.call
    end

    it "should have a pulse" do
      get "/pulse"
      last_response.body.should == '1'
    end
  end
end

Run Tests With Framework Environment Variable

RAILS_ENV=test RAILS=3 spec spec
SINATRA=1 spec spec
Something went wrong with that request. Please try again.