diff --git a/features/nifty_authentication.feature b/features/nifty_authentication.feature index fdc2b06..df744ee 100644 --- a/features/nifty_authentication.feature +++ b/features/nifty_authentication.feature @@ -61,3 +61,17 @@ Feature: Nifty Authentication Generator When I run "rails g nifty:layout -f" And I run "rake db:migrate" Then I should successfully run "rake test" + + Scenario: Generate named authentication with rspec + Given a new Rails app + When I run "rails g nifty:authentication Account CurrentSession --rspec" + Then I should see the following files + | spec/models/account_spec.rb | + | spec/controllers/accounts_controller_spec.rb | + | spec/controllers/current_sessions_controller_spec.rb | + When I run "rails g nifty:layout -f" + And I run "rake db:migrate" + And I add "gem 'rspec-rails', '>= 2.0.1'" to file "Gemfile" + And I run "rails g rspec:install" + And I replace "mock_with :rspec" with "mock_with :mocha" in file "spec/spec_helper.rb" + Then I should successfully run "rake spec" diff --git a/features/nifty_scaffold.feature b/features/nifty_scaffold.feature index eaf2a73..1bb8724 100644 --- a/features/nifty_scaffold.feature +++ b/features/nifty_scaffold.feature @@ -32,9 +32,9 @@ Feature: Nifty Scaffold Generator Then I should see the following files | spec/models/task_spec.rb | | spec/controllers/tasks_controller_spec.rb | - And I should see "resources :projects" in file "config/routes.rb" When I run "rails g nifty:layout -f" And I run "rake db:migrate" And I add "gem 'rspec-rails', '>= 2.0.0.beta.19'" to file "Gemfile" And I run "rails g rspec:install" + And I replace "mock_with :rspec" with "mock_with :mocha" in file "spec/spec_helper.rb" Then I should successfully run "rake spec" diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb index 4dcc498..cb8cc25 100644 --- a/features/step_definitions/common_steps.rb +++ b/features/step_definitions/common_steps.rb @@ -8,6 +8,13 @@ File.open(path, 'a') { |f| f.write(content + "\n") } end +When /^I replace "([^\"]*)" with "([^\"]*)" in file "([^\"]*)"$/ do |old_content, new_content, short_path| + path = File.join(@current_directory, short_path) + File.should exist(path) + content = File.read(path).gsub(old_content, new_content) + File.open(path, 'w') { |f| f.write(content) } +end + Then /^I should see file "([^\"]*)"$/ do |path| File.should exist(File.join(@current_directory, path)) end