From 0082aab56a653fa4148b3f7daa017de1fa36a592 Mon Sep 17 00:00:00 2001 From: Gabriel Sobrinho Date: Thu, 2 Jun 2011 10:17:43 -0300 Subject: [PATCH 1/2] Use `cucumber?` on install generator to be consistent with `rspec?` --- lib/generators/machinist/install/install_generator.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/generators/machinist/install/install_generator.rb b/lib/generators/machinist/install/install_generator.rb index 9aec6dd..9720d54 100644 --- a/lib/generators/machinist/install/install_generator.rb +++ b/lib/generators/machinist/install/install_generator.rb @@ -32,7 +32,7 @@ def test_helper end def cucumber_support - if options[:cucumber] + if cucumber? template "machinist.rb.erb", "features/support/machinist.rb" end end @@ -43,6 +43,9 @@ def rspec? options[:test_framework].to_sym == :rspec end + def cucumber? + options[:cucumber] + end end end end From 3c359578e7fa0ff4c5fef73f6b21327992cc2fdd Mon Sep 17 00:00:00 2001 From: Gabriel Sobrinho Date: Thu, 2 Jun 2011 10:19:49 -0300 Subject: [PATCH 2/2] `Machinist.reset_before_test` was removed in 2839888 --- .../machinist/install/install_generator.rb | 17 ++++++----------- .../install/templates/machinist.rb.erb | 3 --- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/generators/machinist/install/install_generator.rb b/lib/generators/machinist/install/install_generator.rb index 9720d54..3840062 100644 --- a/lib/generators/machinist/install/install_generator.rb +++ b/lib/generators/machinist/install/install_generator.rb @@ -15,22 +15,13 @@ def blueprints_file end def test_helper - if rspec? - inject_into_file("spec/spec_helper.rb", :after => "RSpec.configure do |config|\n") do - " # Reset the Machinist cache before each spec.\n" + - " config.before(:each) { Machinist.reset_before_test }\n\n" - end - else + if test_unit? inject_into_file("test/test_helper.rb", :after => "require 'rails/test_help'\n") do "require File.expand_path(File.dirname(__FILE__) + '/blueprints')\n" end - inject_into_class("test/test_helper.rb", ActiveSupport::TestCase) do - " # Reset the Machinist cache before each test.\n" + - " setup { Machinist.reset_before_test }\n\n" - end end end - + def cucumber_support if cucumber? template "machinist.rb.erb", "features/support/machinist.rb" @@ -43,6 +34,10 @@ def rspec? options[:test_framework].to_sym == :rspec end + def test_unit? + options[:test_framework].to_sym == :test_unit + end + def cucumber? options[:cucumber] end diff --git a/lib/generators/machinist/install/templates/machinist.rb.erb b/lib/generators/machinist/install/templates/machinist.rb.erb index 563b9ad..967236c 100644 --- a/lib/generators/machinist/install/templates/machinist.rb.erb +++ b/lib/generators/machinist/install/templates/machinist.rb.erb @@ -5,6 +5,3 @@ require "#{Rails.root}/spec/support/blueprints" # Load the blueprints from over in test. require "#{Rails.root}/test/blueprints" <%- end -%> - -# Reset the Machinist cache before each scenario. -Before { Machinist.reset_before_test }