-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrspec.rb
57 lines (41 loc) · 1.75 KB
/
rspec.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
if yes?("Install rspec and rspec-rails?", :yellow)
@use_rspec = true
remove_file "test/"
inject_into_file "config/application.rb", :after => "config.generators do |generator|\n" do
(" " * 6) + "generator.test_framework :rspec, :views => false\n"
end
gem 'rspec', '>= 2.0.0', :group => :test
gem 'rspec-rails', '>= 2.0.0', :group => :test
gem 'database_cleaner', :group => :test
unless Gem.available?("rspec", ">= 2.0.0")
run "gem install rspec -v '>= 2.0.0' --no-rdoc --no-ri"
run "gem install rspec-rails -v '>= 2.0.0' --no-rdoc --no-ri"
else
say("Found rspec gem, skipping installation", :cyan)
say("Found rspec-rails gems, skipping installation", :cyan)
end
unless Gem.available?("database_cleaner")
run 'gem install database_cleaner --no-rdoc --no-ri'
else
say("Found database_cleaner, skipping installation", :cyan)
end
generate "rspec:install"
if yes?("Install mocha?", :yellow)
gem 'mocha', :group => :test
append_file "spec/spec_helper.rb" do
"Mocha::Configuration.warn_when(:stubbing_non_existent_method)\n" +
"Mocha::Configuration.warn_when(:stubbing_non_public_method)"
end
gsub_file "spec/spec_helper.rb", /config\.mock_with :rspec/, "config.mock_with :mocha"
end
append_file "spec/spec_helper.rb" do
"\nDatabaseCleaner.strategy = :truncation"
end
end
if yes?("Install factory_girl?", :yellow)
gem 'factory_girl_rails', :group => :test
inject_into_file "config/application.rb", :after => "config.generators do |generator|\n" do
(" " * 6) + "generator.fixture_replacement :factory_girl, :dir => '#{@use_rspec ? "spec/factories" : "test/factories"}'\n"
end
# TODO: inject require 'factory_girl' into spec_helper if @user_rspec
end