1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
APP_NAME = 'testapp'.freeze
When /^I generate a new rails application$/ do
steps %{
When I run "rails _3.0.3_ new #{APP_NAME}"
And I cd to "#{APP_NAME}"
And I write to "Gemfile" with:
"""
source "http://rubygems.org"
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
"""
And I successfully run "bundle install --local"
}
end
When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
steps %{And I run "bundle install --local"}
end
When /^I run the rspec generator$/ do
steps %{
When I successfully run "rails generate rspec:install"
}
end
When /^I configure the application to use rspec\-rails$/ do
append_to_gemfile "gem 'rspec-rails'"
steps %{And I run "bundle install --local"}
end
When /^I configure the application to use shoulda-context$/ do
append_to_gemfile "gem 'shoulda-context', :git => 'git@github.com:thoughtbot/shoulda-context.git'"
steps %{And I run "bundle install --local"}
end
When /^I configure the application to use shoulda$/ do
append_to_gemfile "gem 'shoulda-matchers', :git => 'git@github.com:thoughtbot/shoulda-matchers.git', :require => false"
append_to_gemfile "gem 'shoulda-context', :git => 'git@github.com:thoughtbot/shoulda-context.git', :require => false"
append_to_gemfile "gem 'shoulda', :path => '../../..'"
steps %{And I run "bundle install --local"}
end
When /^I configure the application to use shoulda-matchers$/ do
append_to_gemfile "gem 'shoulda-matchers', :git => 'git@github.com:thoughtbot/shoulda-matchers.git'"
steps %{And I run "bundle install --local"}
end
When /^I configure a wildcard route$/ do
steps %{
When I write to "config/routes.rb" with:
"""
Rails.application.routes.draw do
match ':controller(/:action(/:id(.:format)))'
end
"""
}
end
module AppendHelpers
def append_to(path, contents)
in_current_dir do
File.open(path, "a") do |file|
file.puts
file.puts contents
end
end
end
def append_to_gemfile(contents)
append_to('Gemfile', contents)
end
end
World(AppendHelpers)
|