Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

All cukes passing!

* Gemfiling database_cleaner
* Catch format.any(:all) for api/v1/owners#show
* Switch to new mailer api for email reset, confirmation
* Whitelist more attributes for User
* Move some forgotten views to use short_info
* html_safe the footer links
* Lots of form deprecation whiners silenced
* Upgrade to latest cucumber
* Hack webrat so it works on Rails 3
* Move cucumber specific setup into its own support file
* Fix a few steps that expected regexps for 'I should see'
* Removed hoptoad_notifier task, yagni
* DJ's API to start a worker changed, fixed it
* Check the last email in the Deliveries, not the first
  • Loading branch information...
commit d1085ba57343879168fb251554f641a93d6c2759 1 parent fbd96ca
@qrush qrush authored
Showing with 447 additions and 233 deletions.
  1. +1 −0  Gemfile
  2. +42 −36 Gemfile.lock
  3. +1 −1  app/controllers/api/v1/owners_controller.rb
  4. +2 −2 app/controllers/sessions_controller.rb
  5. +0 −1  app/metal/hostess.rb
  6. +1 −1  app/models/user.rb
  7. +2 −2 app/views/dashboards/show.html.erb
  8. +2 −2 app/views/layouts/application.html.erb
  9. +3 −3 app/views/passwords/edit.html.erb
  10. +1 −1  app/views/passwords/new.html.erb
  11. +1 −1  app/views/sessions/new.html.erb
  12. +1 −1  app/views/users/new.html.erb
  13. +1 −0  config/application.rb
  14. +8 −0 config/cucumber.yml
  15. +0 −3  cucumber.yml
  16. +3 −5 features/search.feature
  17. +2 −2 features/step_definitions/clearance_steps.rb
  18. +1 −1  features/step_definitions/system_steps.rb
  19. +4 −0 features/step_definitions/view_steps.rb
  20. +281 −0 features/step_definitions/web_steps.rb
  21. +0 −126 features/step_definitions/webrat_steps.rb
  22. +22 −30 features/support/env.rb
  23. +23 −0 features/support/gemcutter.rb
  24. +13 −0 features/support/webrat.rb
  25. +2 −2 features/yank.feature
  26. +20 −8 lib/tasks/cucumber.rake
  27. +0 −5 lib/tasks/hoptoad_notifier_tasks.rake
  28. +10 −0 script/cucumber
View
1  Gemfile
@@ -27,6 +27,7 @@ group :test do
gem "cucumber-rails", "0.3.2"
gem "factory_girl_rails", "1.0"
+ gem "database_cleaner", "0.5.2"
gem "fakeweb", "1.2.6"
gem "nokogiri", "1.4.1"
gem "rack-test", "0.5.4", :require => "rack/test"
View
78 Gemfile.lock
@@ -8,22 +8,22 @@ dependencies:
group:
- :test
version: = 1.2.6
- rails:
- group:
- - :default
- version: = 3.0.0.beta4
- gravtastic:
+ pg:
group:
- :default
- version: = 2.1.3
+ version: = 0.8.0
system_timer:
group:
- :default
version: = 1.0
- pg:
+ gravtastic:
group:
- :default
- version: = 0.8.0
+ version: = 2.1.3
+ rails:
+ group:
+ - :default
+ version: = 3.0.0.beta4
treetop:
group:
- :test
@@ -44,44 +44,48 @@ dependencies:
group:
- :default
version: = 1.1.0
- cucumber-rails:
+ database_cleaner:
group:
- :test
- version: = 0.3.2
- will_paginate:
+ version: = 0.5.2
+ rest-client:
group:
- :default
- version: = 2.3.11
+ version: = 1.0.3
+ require:
+ - rest_client
+ json:
+ group:
+ - :default
+ version: = 1.2.0
sinatra:
group:
- :default
version: = 1.0
- json:
+ will_paginate:
group:
- :default
- version: = 1.2.0
- rest-client:
+ version: = 2.3.11
+ cucumber-rails:
group:
- - :default
- version: = 1.0.3
- require:
- - rest_client
+ - :test
+ version: = 0.3.2
webrat:
group:
- :test
version: = 0.5.3
- gchartrb:
- group:
- - :default
- version: = 0.8
- require:
- - google_chart
rack-maintenance:
group:
- :default
version: = 0.3.0
require:
- rack/maintenance
+ gchartrb:
+ group:
+ - :default
+ version: = 0.8
+ require:
+ - google_chart
redgreen:
group:
- :test
@@ -92,36 +96,36 @@ dependencies:
version: = 0.5.4
require:
- rack/test
- clearance:
- group:
- - :default
- version: = 0.9.0.rc5
hoptoad_notifier:
group:
- :default
version: = 2.2.0
- redis:
+ clearance:
group:
- :default
- version: = 2.0.1
+ version: = 0.9.0.rc5
aws-s3:
group:
- :default
version: = 0.6.2
require:
- aws/s3
+ redis:
+ group:
+ - :default
+ version: = 2.0.1
webmock:
group:
- :test
version: = 0.7.3
- xml-simple:
- group:
- - :default
- version: = 1.0.12
factory_girl_rails:
group:
- :test
version: = 1.0
+ xml-simple:
+ group:
+ - :default
+ version: = 1.0.12
nokogiri:
group:
- :test
@@ -199,6 +203,8 @@ specs:
version: 0.3.2
- daemons:
version: 1.1.0
+- database_cleaner:
+ version: 0.5.2
- delayed_job:
version: 2.1.0.pre
source: 0
@@ -244,7 +250,7 @@ specs:
version: 0.5.3
- will_paginate:
version: 2.3.11
-hash: 150b641f21af34ede62d593d4200bce738ab72ee
+hash: 7fb30ea9ae84dd1506b0ac2eb9ec57ec8894c21a
sources:
- Git:
uri: git://github.com/pvdb/delayed_job.git
View
2  app/controllers/api/v1/owners_controller.rb
@@ -9,7 +9,7 @@ class Api::V1::OwnersController < ApplicationController
def show
respond_to do |format|
- format.json { render :json => @rubygem.owners }
+ format.any(:json, :all) { render :json => @rubygem.owners }
format.yaml { render :text => @rubygem.owners.to_yaml }
end
end
View
4 app/controllers/sessions_controller.rb
@@ -13,9 +13,9 @@ def create
redirect_back_or(url_after_create)
else
if @user.email_reset
- Mailer.deliver_email_reset(@user)
+ Mailer.email_reset(@user).deliver
else
- ClearanceMailer.deliver_confirmation(@user)
+ ClearanceMailer.confirmation(@user).deliver
end
flash_notice_after_create
redirect_to(new_session_url)
View
1  app/metal/hostess.rb
@@ -1,4 +1,3 @@
-require 'sinatra'
class Hostess < Sinatra::Base
cattr_writer :local
View
2  app/models/user.rb
@@ -2,7 +2,7 @@ class User < ActiveRecord::Base
include Clearance::User
is_gravtastic
- attr_accessible :handle
+ attr_accessible :handle, :password_confirmation, :password, :email
has_many :rubygems, :through => :ownerships,
:order => "name ASC",
View
4 app/views/dashboards/show.html.erb
@@ -18,7 +18,7 @@
<% end -%>
</strong>
<%= time_ago_in_words(version.created_at) %> ago</div>
- <%= short_info(version.info) %>
+ <%= short_info(version) %>
</a>
</li>
<% end %>
@@ -57,7 +57,7 @@
<div class="downloads">
<strong><%= gem.downloads %></strong> downloads
</div>
- <%= link_to gem, gem, :title => gem.versions.latest.try(:summary) %>
+ <%= link_to gem, gem, :title => short_info(gem.versions.most_recent) %>
</li>
<% end %>
</ol>
View
4 app/views/layouts/application.html.erb
@@ -78,8 +78,8 @@
<%= link_to "Code", "http://github.com/rubygems/gemcutter" %>
<%= link_to "Discuss", "http://groups.google.com/group/gemcutter" %>
<%= link_to "Stats", statistics_url %>
- <%= link_to "designed by #{image_tag('thoughtbot.png')}", "http://thoughtbot.com", :title => "Designed by Thoughtbot", :id => "thoughtbot" %>
- <%= link_to "supported by #{image_tag('rubycentral.png')}", "http://rubycentral.org", :title => "Supported by Ruby Central", :id => "rubycentral" %>
+ <%= link_to "designed by #{image_tag('thoughtbot.png')}".html_safe, "http://thoughtbot.com", :title => "Designed by Thoughtbot", :id => "thoughtbot" %>
+ <%= link_to "supported by #{image_tag('rubycentral.png')}".html_safe, "http://rubycentral.org", :title => "Supported by Ruby Central", :id => "rubycentral" %>
</div>
</div>
</div>
View
6 app/views/passwords/edit.html.erb
@@ -1,8 +1,8 @@
<% @title = "reset password" %>
-<% form_for(:user,
- :url => user_password_path(@user, :token => @user.confirmation_token),
- :html => { :method => :put }) do |form| %>
+<%= form_for(:user,
+ :url => user_password_path(@user, :token => @user.confirmation_token),
+ :html => { :method => :put }) do |form| %>
<%= error_messages_for :user %>
<div class="password_field">
<%= form.label :password %>
View
2  app/views/passwords/new.html.erb
@@ -4,7 +4,7 @@
We will email you a link to change your password.
</p>
-<% form_for :password, :url => passwords_path do |form| %>
+<%= form_for :password, :url => passwords_path do |form| %>
<div class="text_field">
<%= form.label :email, "Email address" %>
<%= form.text_field :email, :size => '25' %>
View
2  app/views/sessions/new.html.erb
@@ -5,7 +5,7 @@
</div>
<%= link_to "Forgot Password?", new_password_url %>
</div>
-<% form_for :session, :url => session_path do |form| %>
+<%= form_for :session, :url => session_path do |form| %>
<div class="text_field">
<%= form.label :who, "Email or Handle" %>
<%= form.text_field :who, :size => 25 %>
View
2  app/views/users/new.html.erb
@@ -5,7 +5,7 @@
</div>
<%= link_to "Already have an account?", sign_in_path %>
</div>
-<% form_for @user do |form| %>
+<%= form_for @user do |form| %>
<%= render :partial => '/users/form', :object => form %>
<%= form.submit 'Sign up', :disable_with => 'Please wait...' %>
<% end %>
View
1  config/application.rb
@@ -11,5 +11,6 @@ class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.active_record.include_root_in_json = false
+ config.middleware.use "Hostess"
end
end
View
8 config/cucumber.yml
@@ -0,0 +1,8 @@
+<%
+rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
+rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
+%>
+default: <%= std_opts %> features
+wip: --tags @wip:3 --wip features
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
View
3  cucumber.yml
@@ -1,3 +0,0 @@
-default: features -t ~wip -f progress
-wip: features -t wip -f progress
-all: features -f progress
View
8 features/search.feature
@@ -72,7 +72,7 @@ Feature: Search
When I go to the homepage
And I fill in "query" with "rgem"
And I press "Search"
- Then I should not see "RGem \(1.0.0\)"
+ Then I should not see "RGem (1.0.0)"
Scenario: The most recent version of a gem is yanked
Given I am signed up and confirmed as "email@person.com/password"
@@ -85,7 +85,5 @@ Feature: Search
When I go to the homepage
And I fill in "query" with "rgem"
And I press "Search"
- And I should see "RGem \(1.2.1\)"
- And I should not see "RGem \(1.2.2\)"
-
-
+ And I should see "RGem (1.2.1)"
+ And I should not see "RGem (1.2.2)"
View
4 features/step_definitions/clearance_steps.rb
@@ -56,7 +56,7 @@
Then /^a confirmation message should be sent to "(.*)"$/ do |email|
user = User.find_by_email(email)
- sent = ActionMailer::Base.deliveries.first
+ sent = ActionMailer::Base.deliveries.last
assert_equal [user.email], sent.to
assert_match /confirm/i, sent.subject
assert !user.confirmation_token.blank?
@@ -71,7 +71,7 @@
Then /^a password reset message should be sent to "(.*)"$/ do |email|
user = User.find_by_email(email)
- sent = ActionMailer::Base.deliveries.first
+ sent = ActionMailer::Base.deliveries.last
assert_equal [user.email], sent.to
assert_match /password/i, sent.subject
assert !user.confirmation_token.blank?
View
2  features/step_definitions/system_steps.rb
@@ -1,3 +1,3 @@
When 'the system processes jobs' do
- Delayed::Job.work_off
+ Delayed::Worker.new(:quiet => true).work_off
end
View
4 features/step_definitions/view_steps.rb
@@ -19,3 +19,7 @@
"#{row['name']} (#{row['downloads']})"
end
end
+
+Then /^I should see the version "([^\"]*)" featured$/ do |version_number|
+ assert_select("h3", :text => version_number)
+end
View
281 features/step_definitions/web_steps.rb
@@ -0,0 +1,281 @@
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+
+require 'uri'
+require 'cgi'
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
+
+# Commonly used webrat steps
+# http://github.com/brynary/webrat
+
+Given /^(?:|I )am on (.+)$/ do |page_name|
+ visit path_to(page_name)
+end
+
+When /^(?:|I )go to (.+)$/ do |page_name|
+ visit path_to(page_name)
+end
+
+When /^(?:|I )press "([^"]*)"$/ do |button|
+ click_button(button)
+end
+
+When /^(?:|I )follow "([^"]*)"$/ do |link|
+ click_link(link)
+end
+
+When /^(?:|I )follow "([^"]*)" within "([^"]*)"$/ do |link, parent|
+ click_link_within(parent, link)
+end
+
+When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
+ fill_in(field, :with => value)
+end
+
+When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
+ fill_in(field, :with => value)
+end
+
+# Use this to fill in an entire form with data from a table. Example:
+#
+# When I fill in the following:
+# | Account Number | 5002 |
+# | Expiry date | 2009-11-01 |
+# | Note | Nice guy |
+# | Wants Email? | |
+#
+# TODO: Add support for checkbox, select og option
+# based on naming conventions.
+#
+When /^(?:|I )fill in the following:$/ do |fields|
+ fields.rows_hash.each do |name, value|
+ When %{I fill in "#{name}" with "#{value}"}
+ end
+end
+
+When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
+ select(value, :from => field)
+end
+
+# Use this step in conjunction with Rail's datetime_select helper. For example:
+# When I select "December 25, 2008 10:00" as the date and time
+When /^(?:|I )select "([^"]*)" as the date and time$/ do |time|
+ select_datetime(time)
+end
+
+# Use this step when using multiple datetime_select helpers on a page or
+# you want to specify which datetime to select. Given the following view:
+# <%= f.label :preferred %><br />
+# <%= f.datetime_select :preferred %>
+# <%= f.label :alternative %><br />
+# <%= f.datetime_select :alternative %>
+# The following steps would fill out the form:
+# When I select "November 23, 2004 11:20" as the "Preferred" date and time
+# And I select "November 25, 2004 10:30" as the "Alternative" date and time
+When /^(?:|I )select "([^"]*)" as the "([^"]*)" date and time$/ do |datetime, datetime_label|
+ select_datetime(datetime, :from => datetime_label)
+end
+
+# Use this step in conjunction with Rail's time_select helper. For example:
+# When I select "2:20PM" as the time
+# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
+# will convert the 2:20PM to 14:20 and then select it.
+When /^(?:|I )select "([^"]*)" as the time$/ do |time|
+ select_time(time)
+end
+
+# Use this step when using multiple time_select helpers on a page or you want to
+# specify the name of the time on the form. For example:
+# When I select "7:30AM" as the "Gym" time
+When /^(?:|I )select "([^"]*)" as the "([^"]*)" time$/ do |time, time_label|
+ select_time(time, :from => time_label)
+end
+
+# Use this step in conjunction with Rail's date_select helper. For example:
+# When I select "February 20, 1981" as the date
+When /^(?:|I )select "([^"]*)" as the date$/ do |date|
+ select_date(date)
+end
+
+# Use this step when using multiple date_select helpers on one page or
+# you want to specify the name of the date on the form. For example:
+# When I select "April 26, 1982" as the "Date of Birth" date
+When /^(?:|I )select "([^"]*)" as the "([^"]*)" date$/ do |date, date_label|
+ select_date(date, :from => date_label)
+end
+
+When /^(?:|I )check "([^"]*)"$/ do |field|
+ check(field)
+end
+
+When /^(?:|I )uncheck "([^"]*)"$/ do |field|
+ uncheck(field)
+end
+
+When /^(?:|I )choose "([^"]*)"$/ do |field|
+ choose(field)
+end
+
+# Adds support for validates_attachment_content_type. Without the mime-type getting
+# passed to attach_file() you will get a "Photo file is not one of the allowed file types."
+# error message
+When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
+ type = path.split(".")[1]
+
+ case type
+ when "jpg"
+ type = "image/jpg"
+ when "jpeg"
+ type = "image/jpeg"
+ when "png"
+ type = "image/png"
+ when "gif"
+ type = "image/gif"
+ end
+
+ attach_file(field, path, type)
+end
+
+Then /^(?:|I )should see "([^"]*)"$/ do |text|
+ if response.respond_to? :should
+ response.should contain(text)
+ else
+ assert_contain text
+ end
+end
+
+Then /^(?:|I )should see "([^"]*)" within "([^"]*)"$/ do |text, selector|
+ within(selector) do |content|
+ if content.respond_to? :should
+ content.should contain(text)
+ else
+ hc = Webrat::Matchers::HasContent.new(text)
+ assert hc.matches?(content), hc.failure_message
+ end
+ end
+end
+
+Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+ if response.respond_to? :should
+ response.should contain(regexp)
+ else
+ assert_match(regexp, response_body)
+ end
+end
+
+Then /^(?:|I )should see \/([^\/]*)\/ within "([^"]*)"$/ do |regexp, selector|
+ within(selector) do |content|
+ regexp = Regexp.new(regexp)
+ if content.respond_to? :should
+ content.should contain(regexp)
+ else
+ assert_match(regexp, content)
+ end
+ end
+end
+
+Then /^(?:|I )should not see "([^"]*)"$/ do |text|
+ if response.respond_to? :should_not
+ response.should_not contain(text)
+ else
+ assert_not_contain(text)
+ end
+end
+
+Then /^(?:|I )should not see "([^"]*)" within "([^"]*)"$/ do |text, selector|
+ within(selector) do |content|
+ if content.respond_to? :should_not
+ content.should_not contain(text)
+ else
+ hc = Webrat::Matchers::HasContent.new(text)
+ assert !hc.matches?(content), hc.negative_failure_message
+ end
+ end
+end
+
+Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+ if response.respond_to? :should_not
+ response.should_not contain(regexp)
+ else
+ assert_not_contain(regexp)
+ end
+end
+
+Then /^(?:|I )should not see \/([^\/]*)\/ within "([^"]*)"$/ do |regexp, selector|
+ within(selector) do |content|
+ regexp = Regexp.new(regexp)
+ if content.respond_to? :should_not
+ content.should_not contain(regexp)
+ else
+ assert_no_match(regexp, content)
+ end
+ end
+end
+
+Then /^the "([^"]*)" field should contain "([^"]*)"$/ do |field, value|
+ field_value = field_labeled(field).value
+ if field_value.respond_to? :should
+ field_value.should =~ /#{value}/
+ else
+ assert_match(/#{value}/, field_value)
+ end
+end
+
+Then /^the "([^"]*)" field should not contain "([^"]*)"$/ do |field, value|
+ field_value = field_labeled(field).value
+ if field_value.respond_to? :should_not
+ field_value.should_not =~ /#{value}/
+ else
+ assert_no_match(/#{value}/, field_value)
+ end
+end
+
+Then /^the "([^"]*)" checkbox should be checked$/ do |label|
+ field = field_labeled(label)
+ if field.respond_to? :should
+ field.should be_checked
+ else
+ assert field.checked?
+ end
+end
+
+Then /^the "([^"]*)" checkbox should not be checked$/ do |label|
+ field = field_labeled(label)
+ if field.respond_to? :should_not
+ field.should_not be_checked
+ else
+ assert !field.checked?
+ end
+end
+
+Then /^(?:|I )should be on (.+)$/ do |page_name|
+ current_path = URI.parse(current_url).path
+ if current_path.respond_to? :should
+ current_path.should == path_to(page_name)
+ else
+ assert_equal path_to(page_name), current_path
+ end
+end
+
+Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
+ query = URI.parse(current_url).query
+ actual_params = query ? CGI.parse(query) : {}
+ expected_params = {}
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
+
+ if actual_params.respond_to? :should
+ actual_params.should == expected_params
+ else
+ assert_equal expected_params, actual_params
+ end
+end
+
+Then /^show me the page$/ do
+ save_and_open_page
+end
View
126 features/step_definitions/webrat_steps.rb
@@ -1,126 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
-
-# Commonly used webrat steps
-# http://github.com/brynary/webrat
-
-Given /^I am on (.+)$/ do |page_name|
- visit path_to(page_name)
-end
-
-When /^I go to (.+)$/ do |page_name|
- visit path_to(page_name)
-end
-
-When /^I press "([^\"]*)"$/ do |button|
- click_button(button)
-end
-
-When /^I follow "([^\"]*)"$/ do |link|
- click_link(link)
-end
-
-When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
- fill_in(field, :with => value)
-end
-
-When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
- select(value, :from => field)
-end
-
-# Use this step in conjunction with Rail's datetime_select helper. For example:
-# When I select "December 25, 2008 10:00" as the date and time
-When /^I select "([^\"]*)" as the date and time$/ do |time|
- select_datetime(time)
-end
-
-# Use this step when using multiple datetime_select helpers on a page or
-# you want to specify which datetime to select. Given the following view:
-# <%= f.label :preferred %><br />
-# <%= f.datetime_select :preferred %>
-# <%= f.label :alternative %><br />
-# <%= f.datetime_select :alternative %>
-# The following steps would fill out the form:
-# When I select "November 23, 2004 11:20" as the "Preferred" data and time
-# And I select "November 25, 2004 10:30" as the "Alternative" data and time
-When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
- select_datetime(datetime, :from => datetime_label)
-end
-
-# Use this step in conjunction with Rail's time_select helper. For example:
-# When I select "2:20PM" as the time
-# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
-# will convert the 2:20PM to 14:20 and then select it.
-When /^I select "([^\"]*)" as the time$/ do |time|
- select_time(time)
-end
-
-# Use this step when using multiple time_select helpers on a page or you want to
-# specify the name of the time on the form. For example:
-# When I select "7:30AM" as the "Gym" time
-When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
- select_time(time, :from => time_label)
-end
-
-# Use this step in conjunction with Rail's date_select helper. For example:
-# When I select "February 20, 1981" as the date
-When /^I select "([^\"]*)" as the date$/ do |date|
- select_date(date)
-end
-
-# Use this step when using multiple date_select helpers on one page or
-# you want to specify the name of the date on the form. For example:
-# When I select "April 26, 1982" as the "Date of Birth" date
-When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
- select_date(date, :from => date_label)
-end
-
-When /^I check "([^\"]*)"$/ do |field|
- check(field)
-end
-
-When /^I uncheck "([^\"]*)"$/ do |field|
- uncheck(field)
-end
-
-When /^I choose "([^\"]*)"$/ do |field|
- choose(field)
-end
-
-When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
- attach_file(field, path)
-end
-
-# Modified the below to not use #should
-Then /^I should see "([^\"]*)"$/ do |text|
- # response.should contain(text)
- assert_contain Regexp.new(text)
-end
-
-Then /^I should not see "([^\"]*)"$/ do |text|
- # response.should_not contain(text)
- assert_not_contain Regexp.new(text)
-end
-
-Then /^I should see the version "([^\"]*)" featured$/ do |version_number|
- assert_select("h3", :text => version_number)
-end
-
-Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
- # field_labeled(field).value.should =~ /#{value}/
- assert field_labeled(field).value =~ /#{value}/
-end
-
-Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
- # field_labeled(field).value.should_not =~ /#{value}/
- assert field_labeled(field).value =~ /#{value}/
-end
-
-Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
- # field_labeled(label).should be_checked
- assert field_labeled(label).checked?
-end
-
-Then /^I should be on (.+)$/ do |page_name|
- # URI.parse(current_url).path.should == path_to(page_name)
- assert_equal path_to(page_name), URI.parse(current_url).path
-end
View
52 features/support/env.rb
@@ -1,40 +1,32 @@
-# Sets up the Rails environment for Cucumber
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
-require 'cucumber/rails/world'
-require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
-Cucumber::Rails.use_transactional_fixtures
-Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
- # (e.g. rescue_action_in_public / rescue_responses / rescue_from)
-
-require 'factory_girl'
-Factory.find_definitions
-require 'test/unit/assertions'
-World(Test::Unit::Assertions)
+require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
+require 'cucumber/rails/world'
+require 'cucumber/web/tableish'
require 'webrat'
+require 'webrat/core/matchers'
+
Webrat.configure do |config|
config.mode = :rails
+ config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end
-require 'webrat/core/matchers'
-require 'webrat/core/matchers/have_tag'
-
-require 'webmock'
-WebMock.disable_net_connect!
-
-TEST_DIR = File.join('/', 'tmp', 'gemcutter')
-Hostess.local = true
-Before do
- WebMock.reset_webmock
- FileUtils.mkdir(TEST_DIR)
- Dir.chdir(TEST_DIR)
-end
-
-After do
- Dir.chdir(TEST_DIR)
- FileUtils.rm_rf(TEST_DIR)
- $redis.flushdb
-end
+# If you set this to false, any error raised from within your app will bubble
+# up to your step definition and out to cucumber unless you catch it somewhere
+# on the way. You can make Rails rescue errors and render error pages on a
+# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
+#
+# If you set this to true, Rails will rescue all errors and render error
+# pages, more or less in the same way your application would behave in the
+# default production environment. It's not recommended to do this for all
+# of your scenarios, as this makes it hard to discover errors in your application.
+ActionController::Base.allow_rescue = false
View
23 features/support/gemcutter.rb
@@ -0,0 +1,23 @@
+WebMock.disable_net_connect!
+
+Hostess.local = true
+
+TEST_DIR = File.join('/', 'tmp', 'gemcutter')
+
+DatabaseCleaner.clean_with :truncation
+DatabaseCleaner.strategy = :transaction
+
+Before do
+ WebMock.reset_webmock
+ DatabaseCleaner.start
+
+ FileUtils.mkdir(TEST_DIR)
+ Dir.chdir(TEST_DIR)
+end
+
+After do
+ DatabaseCleaner.clean
+
+ FileUtils.rm_rf(TEST_DIR)
+ $redis.flushdb
+end
View
13 features/support/webrat.rb
@@ -0,0 +1,13 @@
+module Webrat
+ module Logging
+ def logger
+ Rails.logger
+ end
+ end
+
+ class Field
+ def parse_rails_request_params(params)
+ Rack::Utils.parse_nested_query(params)
+ end
+ end
+end
View
4 features/yank.feature
@@ -16,7 +16,7 @@ Feature: Delete Gems
And I go to the dashboard with my api key
Then I should see "RGem"
And I visit the gem page for "RGem" version "1.2.3"
- Then I should see "This gem has been yanked."
+ Then I should see "This gem has been yanked"
And I visit the gem page for "RGem"
Then I should see the version "1.2.2" featured
@@ -29,7 +29,7 @@ Feature: Delete Gems
When I yank the gem "RGem" version "1.2.3" with my api key
And I go to the dashboard with my api key
And I follow "RGem"
- And I should see "This gem has been yanked."
+ And I should see "This gem has been yanked"
Given I am signed up and confirmed as "new@owner.com/password"
And I have a gem "RGem" with version "0.1.0"
View
28 lib/tasks/cucumber.rake
@@ -1,23 +1,35 @@
-$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
-unless ARGV.any? {|a| a =~ /^gems/}
+
+unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
+
+vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
begin
require 'cucumber/rake/task'
- vendored_cucumber_binary = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
-
namespace :cucumber do
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
t.fork = true # You may get faster startup if you set this to false
- t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'progress'}"
- t.binary = vendored_cucumber_binary
+ t.profile = 'default'
end
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'wip'
+ end
+
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
+ t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
- t.cucumber_opts = "--color --tags @wip:2 --wip --format #{ENV['CUCUMBER_FORMAT'] || 'progress'}"
- t.binary = vendored_cucumber_binary
+ t.profile = 'rerun'
end
desc 'Run all features'
View
5 lib/tasks/hoptoad_notifier_tasks.rake
@@ -1,5 +0,0 @@
-Dir[File.join(RAILS_ROOT, 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier|
- $: << File.join(vendored_notifier, 'lib')
-end
-
-require 'hoptoad_notifier/tasks'
View
10 script/cucumber
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+if vendored_cucumber_bin
+ load File.expand_path(vendored_cucumber_bin)
+else
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
+ require 'cucumber'
+ load Cucumber::BINARY
+end
Please sign in to comment.
Something went wrong with that request. Please try again.