Skip to content

Commit

Permalink
Upgrade rspec and cucumber to rails 3 compatible version
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Jan 28, 2011
1 parent 37a067a commit fb5809a
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 329 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--colour
21 changes: 10 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ gem "compass", ">= 0.10.6"
gem 'fancy-buttons'
gem "rails-geocoder", :require => "geocoder"

group :cucumber do
gem 'cucumber-rails', '>=0.2.4'
gem 'database_cleaner', '>=0.4.3'
gem 'webrat', '>=0.6.0'
group :test do
gem 'cucumber-rails'
#gem 'capybara'
gem 'webrat'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'email_spec'
end

group :cucumber, :test do
gem 'rspec-rails', '~> 1.3.2'
# This is the latest version of the gem that is compatible with Rails 2
gem 'factory_girl', '1.2.4'
# Version 1.0.0 is for Rails 3 so can't use that yet
gem 'email_spec', '< 1.0.0', :require => 'email_spec'

group :test, :development do
gem 'rspec-rails', '~> 2.4'
end
7 changes: 4 additions & 3 deletions config/cucumber.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
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 %>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
91 changes: 71 additions & 20 deletions features/step_definitions/email_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ def current_email_address
mailbox_for(address).size.should == parse_email_count(amount)
end

# DEPRECATED
# The following methods are left in for backwards compatibility and
# should be removed by version 0.4.0
Then /^(?:I|they|"([^"]*?)") should not receive an email$/ do |address|
email_spec_deprecate "The step 'I/they/[email] should not receive an email' is no longer supported.
Please use 'I/they/[email] should receive no emails' instead."
unread_emails_for(address).size.should == 0
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
end

Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
open_email(address, :with_text => expected_body)
end

#
Expand Down Expand Up @@ -95,11 +94,11 @@ def current_email_address
end

Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
current_email.body.should include(text)
current_email.default_part_body.to_s.should include(text)
end

Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
current_email.body.should =~ Regexp.new(text)
current_email.default_part_body.to_s.should =~ Regexp.new(text)
end

Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
Expand All @@ -114,19 +113,50 @@ def current_email_address
current_email.should have_header(name, Regexp.new(text))
end

Then /^I should see it is a multi\-part email$/ do
current_email.should be_multipart
end

# DEPRECATED
# The following methods are left in for backwards compatibility and
# should be removed by version 0.4.0.
Then /^(?:I|they) should see "([^"]*?)" in the subject$/ do |text|
email_spec_deprecate "The step 'I/they should see [text] in the subject' is no longer supported.
Please use 'I/they should see [text] in the email subject' instead."
current_email.should have_subject(Regexp.new(text))
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
current_email.html_part.body.to_s.should include(text)
end
Then /^(?:I|they) should see "([^"]*?)" in the email$/ do |text|
email_spec_deprecate "The step 'I/they should see [text] in the email' is no longer supported.
Please use 'I/they should see [text] in the email body' instead."
current_email.body.should =~ Regexp.new(text)

Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
current_email.text_part.body.to_s.should include(text)
end

#
# Inspect the Email Attachments
#

Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
current_email_attachments.size.should == parse_email_count(amount)
end

Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
current_email_attachments.select { |a| a.filename == filename }.size.should == parse_email_count(amount)
end

Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
current_email_attachments[(index.to_i - 1)].filename.should == filename
end

Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
current_email_attachments.select { |a| a.content_type.include?(content_type) }.size.should == parse_email_count(amount)
end

Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
current_email_attachments[(index.to_i - 1)].content_type.should include(content_type)
end

Then /^all attachments should not be blank$/ do
current_email_attachments.each do |attachment|
attachment.read.size.should_not == 0
end
end

Then /^show me a list of email attachments$/ do
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
end

#
Expand All @@ -141,3 +171,24 @@ def current_email_address
click_first_link_in_email
end

#
# Debugging
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
# Patches accepted. ;)
#

Then /^save and open current email$/ do
EmailSpec::EmailViewer::save_and_open_email(current_email)
end

Then /^save and open all text emails$/ do
EmailSpec::EmailViewer::save_and_open_all_text_emails
end

Then /^save and open all html emails$/ do
EmailSpec::EmailViewer::save_and_open_all_html_emails
end

Then /^save and open all raw emails$/ do
EmailSpec::EmailViewer::save_and_open_all_raw_emails
end
Loading

0 comments on commit fb5809a

Please sign in to comment.