Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

tag: v0.2.0

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 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.