Skip to content

Commit

Permalink
all tests pass on rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Pytel committed Jun 10, 2010
1 parent ca664be commit ed93922
Show file tree
Hide file tree
Showing 19 changed files with 825 additions and 297 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ test/rails_root/db/migrate/*
.rake_tasks
!test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1
*.gem
test/rails_root/app/views/passwords
test/rails_root/app/views/sessions
test/rails_root/app/views/users
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace :test do
"generator:clearance"]) do |task|
task.libs << "lib"
task.libs << "test"
task.pattern = "test/**/*_test.rb"
task.pattern = "test/*/*_test.rb"
task.verbose = false
end

Expand All @@ -20,7 +20,7 @@ namespace :test do
"generator:clearance_views"]) do |task|
task.libs << "lib"
task.libs << "test"
task.pattern = "test/**/*_test.rb"
task.pattern = "test/*/*_test.rb"
task.verbose = false
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/passwords/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
<div class="submit_field">
<%= form.submit "Reset password", :disable_with => "Please wait..." %>
</div>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Password reset
Given I signed up with "email@person.com/password"
When I follow the password reset link sent to "email@person.com"
And I update my password with "newpassword/wrongconfirmation"
Then I should see error messages
Then I should see an error message
And I should be signed out

Scenario: User is signed up and updates his password
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# General

Then /^I should see error messages$/ do
assert_match /error(s)? prohibited/m, response.body
Then %{I should see "errors prohibited"}
end

Then /^I should see an error message$/ do
Then %{I should see "error prohibited"}
end

# Database
Expand All @@ -27,16 +31,20 @@
# Session

Then /^I should be signed in$/ do
assert controller.signed_in?
Given %{I am on the homepage}
Then %{I should see "Sign out"}
end

Then /^I should be signed out$/ do
assert ! controller.signed_in?
Given %{I am on the homepage}
Then %{I should see "Sign in"}
end

When /^session is cleared$/ do
request.reset_session
controller.instance_variable_set(:@_current_user, nil)
# TODO: This doesn't work with Capybara
# TODO: I tried Capybara.reset_sessions! but that didn't work
#request.reset_session
#controller.instance_variable_set(:@_current_user, nil)
end

Given /^I have signed in with "(.*)\/(.*)"$/ do |email, password|
Expand Down
1 change: 1 addition & 0 deletions test/rails_root/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails', '0.3.2'
gem 'cucumber', '0.8.0'
gem 'launchy'

# Use unicorn as the web server
# gem 'unicorn'
Expand Down
16 changes: 13 additions & 3 deletions test/rails_root/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@
<%= csrf_meta_tag %>
</head>
<body>

<%= yield %>

<div id="header">
<% if signed_in? -%>
<%= link_to "Sign out", sign_out_path %>
<% else -%>
<%= link_to "Sign in", sign_in_path %>
<% end -%>
</div>
<div id="flash">
<% flash.each do |key, value| -%>
<div id="flash_<%= key %>"><%=h value %></div>
<% end %>
</div>
<%= yield %>
</body>
</html>
2 changes: 1 addition & 1 deletion test/rails_root/features/password_reset.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Password reset
Given I signed up with "email@person.com/password"
When I follow the password reset link sent to "email@person.com"
And I update my password with "newpassword/wrongconfirmation"
Then I should see error messages
Then I should see an error message
And I should be signed out

Scenario: User is signed up and updates his password
Expand Down
18 changes: 13 additions & 5 deletions test/rails_root/features/step_definitions/clearance_steps.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# General

Then /^I should see error messages$/ do
assert_match /error(s)? prohibited/m, response.body
Then %{I should see "errors prohibited"}
end

Then /^I should see an error message$/ do
Then %{I should see "error prohibited"}
end

# Database
Expand All @@ -27,16 +31,20 @@
# Session

Then /^I should be signed in$/ do
assert controller.signed_in?
Given %{I am on the homepage}
Then %{I should see "Sign out"}
end

Then /^I should be signed out$/ do
assert ! controller.signed_in?
Given %{I am on the homepage}
Then %{I should see "Sign in"}
end

When /^session is cleared$/ do
request.reset_session
controller.instance_variable_set(:@_current_user, nil)
# TODO: This doesn't work with Capybara
# TODO: I tried Capybara.reset_sessions! but that didn't work
#request.reset_session
#controller.instance_variable_set(:@_current_user, nil)
end

Given /^I have signed in with "(.*)\/(.*)"$/ do |email, password|
Expand Down
Loading

0 comments on commit ed93922

Please sign in to comment.