Skip to content

Commit

Permalink
adding a spec to test rspec for nifty:authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Oct 15, 2010
1 parent 0b64ad5 commit dcaa6ed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions features/nifty_authentication.feature
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion features/nifty_scaffold.feature
Expand Up @@ -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"
7 changes: 7 additions & 0 deletions features/step_definitions/common_steps.rb
Expand Up @@ -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
Expand Down

0 comments on commit dcaa6ed

Please sign in to comment.