Skip to content

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

License

Notifications You must be signed in to change notification settings

winton/framework_fixture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages