/
rails3_steps.rb
60 lines (52 loc) · 1.33 KB
/
rails3_steps.rb
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
When /^I generate a new rails application$/ do
@terminal.cd(TEMP_ROOT)
@terminal.run("rails _3.0.3_ new #{APP_NAME}")
steps %{
When I save the following as "Gemfile"
"""
source "http://rubygems.org"
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
"""
}
end
When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
append_to_gemfile "gem '#{name}', :path => '../../'"
steps %{And I run "bundle install"}
end
When /^I run the "([^"]*)" generator$/ do |name|
steps %{
When I run "./script/rails generate #{name}"
}
end
When /^I run the rspec generator$/ do
steps %{
When I run the "rspec:install" generator
}
end
When /^I configure the application to use rspec\-rails$/ do
append_to_gemfile "gem 'rspec-rails'"
steps %{And I run "bundle install"}
end
When /^I configure a wildcard route$/ do
steps %{
When I save the following as "config/routes.rb"
"""
Rails.application.routes.draw do |map|
match ':controller(/:action(/:id(.:format)))'
end
"""
}
end
module AppendHelpers
def append_to(path, contents)
File.open(path, "a") do |file|
file.puts
file.puts contents
end
end
def append_to_gemfile(contents)
append_to(File.join(RAILS_ROOT, 'Gemfile'), contents)
end
end
World(AppendHelpers)