<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>examples/rails_root/app/controllers/application_controller.rb</filename>
    </added>
    <added>
      <filename>examples/rails_root/features/support/paths.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,3 +3,5 @@
 *.log
 *.sqlite3
 pkg
+examples/rails_root/features/step_definitions/email_steps.rb
+examples/rails_root/vendor/plugins/email_spec
\ No newline at end of file</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -44,6 +44,7 @@ module Rails
     def load_initializer
       require &quot;#{RAILS_ROOT}/vendor/rails/railties/lib/initializer&quot;
       Rails::Initializer.run(:install_gem_spec_stubs)
+      Rails::GemDependency.add_frozen_gem_path
     end
   end
 </diff>
      <filename>examples/rails_root/config/boot.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
 # ENV['RAILS_ENV'] ||= 'production'
 
 # Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION
 
 # Bootstrap the Rails environment, frameworks, and default configuration
 require File.join(File.dirname(__FILE__), 'boot')
@@ -13,7 +13,7 @@ require File.join(File.dirname(__FILE__), 'boot')
 Rails::Initializer.run do |config|
 
   config.time_zone = 'UTC'
- 
+
   config.action_controller.session = {
     :session_key =&gt; '_es_session',
     :secret      =&gt; 'b9327c7967925fb36f8901e43f47e0a3e8fc7856ae1b4533ddeda776381548f9ac051721446fdbc4ccc88c7353124708e73d8b0950a30487571d8f8eb5b24732'</diff>
      <filename>examples/rails_root/config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,13 +21,9 @@ config.action_controller.allow_forgery_protection    = false
 # ActionMailer::Base.deliveries array.
 config.action_mailer.delivery_method = :test
 
-
 # I HATE config.gem.. it doesn't work as advertised...
-config.gem 'webrat', :source =&gt; &quot;http://gems.github.com&quot;
-#config.gem 'rspec', :lib =&gt; 'spec'
-#config.gem 'rspec-rails', :lib =&gt; 'spec/rails'
-config.gem 'cucumber', :source =&gt; &quot;http://gems.github.com&quot; # aslakhellesoy-cucumber
+config.gem 'cucumber',         :lib =&gt; false
+config.gem 'webrat',           :lib =&gt; false
+config.gem 'rspec',            :lib =&gt; false
+config.gem 'rspec-rails',      :lib =&gt; 'spec/rails'
 config.gem 'nakajima-fixjour', :lib =&gt; 'fixjour', :source =&gt; &quot;http://gems.github.com&quot; # nakajima-fixjour
-
-
-</diff>
      <filename>examples/rails_root/config/environments/test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,42 +1,32 @@
 Feature: Email-spec errors example
-
-In order to help alleviate email testing in apps
-As a email-spec contributor I a newcomer
-Should be able to easily determine where I have gone wrong
-These scenarios should fail with helpful messages
-
-    Scenario: I fail to receive an email
-      Given I am at &quot;/&quot;
-      And no emails have been sent
-      When I fill in &quot;Email&quot; with &quot;example@example.com&quot;
-      And I press &quot;Sign up&quot;
-      And I should receive an email
-      When &quot;example@example.com&quot; opens the email with subject &quot;no email&quot;
-
-    Scenario: I fail to receive an email with the expected link
-      Given I am at &quot;/&quot;
-      And no emails have been sent
-      When I fill in &quot;Email&quot; with &quot;example@example.com&quot;
-      And I press &quot;Sign up&quot;
-      And I should receive an email
-      When I open the email
-      When I follow &quot;link that doesn't exist&quot; in the email
-
-    Scenario: I attempt to operate on an email that is not opened
-      Given I am at &quot;/&quot;
-      And no emails have been sent
-      When I fill in &quot;Email&quot; with &quot;example@example.com&quot;
-      And I press &quot;Sign up&quot;
-      And I should receive an email
-      When I follow &quot;confirm&quot; in the email
-
-    Scenario: I attempt to check out an unopened email
-      Given I am at &quot;/&quot;
-      And no emails have been sent
-      When I fill in &quot;Email&quot; with &quot;example@example.com&quot;
-      And I press &quot;Sign up&quot;
-      Then I should see &quot;confirm&quot; in the email
-      And I should see &quot;Account confirmation&quot; in the subject
-
-
-
+  In order to help alleviate email testing in apps
+  As a email-spec contributor I a newcomer
+  Should be able to easily determine where I have gone wrong
+  These scenarios should fail with helpful messages
+
+  Background:
+    Given I am on the homepage
+    And no emails have been sent
+    When I fill in &quot;Email&quot; with &quot;example@example.com&quot;
+    And I press &quot;Sign up&quot;
+
+  Scenario: I fail to open an email with incorrect subject
+    Then I should receive an email
+    When &quot;example@example.com&quot; opens the email with subject &quot;no email&quot;
+
+  Scenario: I fail to open an email with incorrect text
+    Then I should receive an email
+    When &quot;example@example.com&quot; opens the email with text &quot;no email&quot;
+
+  Scenario: I fail to receive an email with the expected link
+    Then I should receive an email
+    When I open the email
+    When I follow &quot;link that doesn't exist&quot; in the email
+
+  Scenario: I attempt to operate on an email that is not opened
+    Then I should receive an email
+    When I follow &quot;confirm&quot; in the email
+
+  Scenario: I attempt to check out an unopened email
+    Then I should see &quot;confirm&quot; in the email body
+    And I should see &quot;Account confirmation&quot; in the email subject</diff>
      <filename>examples/rails_root/features/errors.feature</filename>
    </modified>
    <modified>
      <diff>@@ -1,59 +1,61 @@
 Feature: EmailSpec Example -- Prevent Bots from creating accounts
 
-In order to help alleviate email testing in apps
-As an email-spec contributor I want new users of the library
-to easily adopt email-spec in their app by following this example
+  In order to help alleviate email testing in apps
+  As an email-spec contributor I want new users of the library
+  to easily adopt email-spec in their app by following this example
 
-In order to prevent bots from setting up new accounts
-As a site manager I want new users
-to verify their email address with a confirmation link
+  In order to prevent bots from setting up new accounts
+  As a site manager I want new users
+  to verify their email address with a confirmation link
 
-Scenario: A new person signs up imperatively 
-    Given I am a real person wanting to sign up for an account
-    And I am at &quot;/&quot;
+  Background:
+    Given no emails have been sent
+    And I am a real person wanting to sign up for an account
+    And I am on the homepage
+    And I submit my registration information
 
-    When I fill in &quot;Email&quot; with &quot;example@example.com&quot;
-    And I fill in &quot;Name&quot; with &quot;example Jones&quot;
-    And I press &quot;Sign up&quot;
-
-    Then &quot;example@example.com&quot; should receive 1 email
-    And &quot;example@example.com&quot; should have 1 email
-    And &quot;foo@bar.com&quot; should not receive an email
+  Scenario: First person signup (as myself) with two ways of opening email
+    Then I should receive an email
+    And I should have 1 email
+    And &quot;foo@bar.com&quot; should have no emails
 
-    When &quot;example@example.com&quot; opens the email with subject &quot;Account confirmation&quot;
+    # Opening email #1
+    When I open the email
+    Then I should see &quot;Account confirmation&quot; in the email subject
+    And I should see &quot;Joe Someone&quot; in the email body
+    And I should see &quot;confirm&quot; in the email body
 
-    Then I should see &quot;confirm&quot; in the email
-    And I should see &quot;example Jones&quot; in the email
-    And I should see &quot;Account confirmation&quot; in the subject
+    # Opening email #2
+    When I open the email with subject &quot;Account confirmation&quot;
+    Then I should see &quot;Account confirmation&quot; in the email subject
+    And I should see &quot;Joe Someone&quot; in the email body
+    And I should see &quot;confirm&quot; in the email body
 
     When I follow &quot;Click here to confirm your account!&quot; in the email
     Then I should see &quot;Confirm your new account&quot;
 
+  Scenario: Third person signup (emails sent to others) with two ways of opening email
+    Then &quot;example@example.com&quot; should receive an email
+    And &quot;example@example.com&quot; should have 1 email
+    And &quot;foo@bar.com&quot; should have no emails
 
-Scenario: slightly more declarative, but still mostly imperative
-    Given I am a real person wanting to sign up for an account
-    And I'm on the signup page
-
-    When I fill in &quot;Email&quot; with &quot;example@example.com&quot;
-    And I fill in &quot;Name&quot; with &quot;example Jones&quot;
-    And I press &quot;Sign up&quot;
-
-    Then I should receive an email
-
-    When I open the email
-    Then I should see &quot;Account confirmation&quot; in the subject
-
-    When I follow &quot;http:///confirm&quot; in the email
-    Then I should see &quot;Confirm your new account&quot;
+    # Opening email #1
+    When they open the email
+    Then they should see &quot;Account confirmation&quot; in the email subject
+    And they should see &quot;Joe Someone&quot; in the email body
+    And they should see &quot;confirm&quot; in the email body
 
+    # Opening email #2
+    When &quot;example@example.com&quot; opens the email with subject &quot;Account confirmation&quot;
+    Then they should see &quot;Account confirmation&quot; in the email subject
+    And they should see &quot;Joe Someone&quot; in the email body
+    And they should see &quot;confirm&quot; in the email body
 
- Scenario: declarative
-    Given I am a real person wanting to sign up for an account
-    And I'm on the signup page
+    When they follow &quot;Click here to confirm your account!&quot; in the email
+    Then they should see &quot;Confirm your new account&quot;
 
-    When I submit my registration information
+  Scenario: Declarative First Person signup
     Then I should receive an email with a link to a confirmation page
 
-
-
-
+  Scenario: Declarative First Person signup
+    Then they should receive an email with a link to a confirmation page</diff>
      <filename>examples/rails_root/features/example.feature</filename>
    </modified>
    <modified>
      <diff>@@ -3,21 +3,24 @@ Given &quot;I am a real person wanting to sign up for an account&quot; do
 end
 
 When /^I submit my registration information$/ do
-  fill_in &quot;Name&quot;, :with =&gt; valid_user_attributes[:name]
-  fill_in &quot;Email&quot;, :with =&gt; valid_user_attributes[:email]
+  fill_in &quot;Name&quot;, :with =&gt; 'Joe Someone'
+  fill_in &quot;Email&quot;, :with =&gt; 'example@example.com'
   click_button
 end
 
-Then /^I should receive an email with a link to a confirmation page$/ do
-  unread_emails_for(valid_user_attributes[:email]).size.should == 1 
-  
+Then /^(?:I|they) should receive an email with a link to a confirmation page$/ do
+  unread_emails_for(current_email_address).size.should == 1
+
   # this call will store the email and you can access it with current_email
-  open_last_email_for(valid_user_attributes[:email])
+  open_last_email_for(last_email_address)
   current_email.should have_subject(/Account confirmation/)
-  current_email.should have_body_text(valid_user_attributes[:name])
+  current_email.should have_body_text('Joe Someone')
 
   click_email_link_matching /confirm/
   response.should include_text(&quot;Confirm your new account&quot;)
-  
 end
 
+# Basically aliases &quot;I should see [text]&quot;, but for third person
+Then /^they should see &quot;([^\&quot;]*)&quot;$/ do |text|
+  Then &quot;I should see \&quot;#{text}\&quot;&quot;
+end</diff>
      <filename>examples/rails_root/features/step_definitions/user_steps.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,104 +1,137 @@
+require File.expand_path(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;support&quot;, &quot;paths&quot;))
+
 # Commonly used webrat steps
 # http://github.com/brynary/webrat
 
-Given /^I am at &quot;(.+)&quot;$/ do |path|
-  visit path
+Given /^I am on (.+)$/ do |page_name|
+  visit path_to(page_name)
 end
 
-Given /^I'm on the (.+) page$/ do |page|
-  locations = {&quot;signup&quot; =&gt; &quot;/&quot;}
-  visit locations[page]
+When /^I go to (.+)$/ do |page_name|
+  visit path_to(page_name)
 end
 
-When /^I press &quot;(.*)&quot;$/ do |button|
+When /^I press &quot;([^\&quot;]*)&quot;$/ do |button|
   click_button(button)
 end
 
-When /^I follow &quot;(.*)&quot;$/ do |link|
+When /^I follow &quot;([^\&quot;]*)&quot;$/ do |link|
   click_link(link)
 end
 
-When /^I fill in &quot;(.*)&quot; with &quot;(.*)&quot;$/ do |field, value|
-  fill_in(field, :with =&gt; value) 
+When /^I follow &quot;([^\&quot;]*)&quot; within &quot;([^\&quot;]*)&quot;$/ do |link, parent|
+  click_link_within(parent, link)
+end
+
+When /^I fill in &quot;([^\&quot;]*)&quot; with &quot;([^\&quot;]*)&quot;$/ do |field, value|
+  fill_in(field, :with =&gt; value)
 end
 
-When /^I select &quot;(.*)&quot; from &quot;(.*)&quot;$/ do |value, field|
-  select(value, :from =&gt; field) 
+When /^I select &quot;([^\&quot;]*)&quot; from &quot;([^\&quot;]*)&quot;$/ do |value, field|
+  select(value, :from =&gt; field)
 end
 
 # Use this step in conjunction with Rail's datetime_select helper. For example:
-# When I select &quot;December 25, 2008 10:00&quot; as the date and time 
-When /^I select &quot;(.*)&quot; as the date and time$/ do |time|
+# When I select &quot;December 25, 2008 10:00&quot; as the date and time
+When /^I select &quot;([^\&quot;]*)&quot; as the date and time$/ do |time|
   select_datetime(time)
 end
 
-# Use this step when using multiple datetime_select helpers on a page or 
+# 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:
-#   &lt;%= f.label :preferred %&gt;&lt;br /&gt;
-#   &lt;%= f.datetime_select :preferred %&gt;
-#   &lt;%= f.label :alternative %&gt;&lt;br /&gt;
-#   &lt;%= f.datetime_select :alternative %&gt;
+#   &lt;%%= f.label :preferred %&gt;&lt;br /&gt;
+#   &lt;%%= f.datetime_select :preferred %&gt;
+#   &lt;%%= f.label :alternative %&gt;&lt;br /&gt;
+#   &lt;%%= f.datetime_select :alternative %&gt;
 # The following steps would fill out the form:
-# When I select &quot;November 23, 2004 11:20&quot; as the &quot;Preferred&quot; data and time
-# And I select &quot;November 25, 2004 10:30&quot; as the &quot;Alternative&quot; data and time
-When /^I select &quot;(.*)&quot; as the &quot;(.*)&quot; date and time$/ do |datetime, datetime_label|
+# When I select &quot;November 23, 2004 11:20&quot; as the &quot;Preferred&quot; date and time
+# And I select &quot;November 25, 2004 10:30&quot; as the &quot;Alternative&quot; date and time
+When /^I select &quot;([^\&quot;]*)&quot; as the &quot;([^\&quot;]*)&quot; date and time$/ do |datetime, datetime_label|
   select_datetime(datetime, :from =&gt; datetime_label)
 end
 
-# Use this step in conjuction with Rail's time_select helper. For example:
+# Use this step in conjunction with Rail's time_select helper. For example:
 # When I select &quot;2:20PM&quot; 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 &quot;(.*)&quot; as the time$/ do |time|
+# will convert the 2:20PM to 14:20 and then select it.
+When /^I select &quot;([^\&quot;]*)&quot; 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 &quot;7:30AM&quot; as the &quot;Gym&quot; time
-When /^I select &quot;(.*)&quot; as the &quot;(.*)&quot; time$/ do |time, time_label|
+When /^I select &quot;([^\&quot;]*)&quot; as the &quot;([^\&quot;]*)&quot; time$/ do |time, time_label|
   select_time(time, :from =&gt; time_label)
 end
 
-# Use this step in conjuction with Rail's date_select helper.  For example:
+# Use this step in conjunction with Rail's date_select helper.  For example:
 # When I select &quot;February 20, 1981&quot; as the date
-When /^I select &quot;(.*)&quot; as the date$/ do |date|
+When /^I select &quot;([^\&quot;]*)&quot; 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 &quot;April 26, 1982&quot; as the &quot;Date of Birth&quot; date
-When /^I select &quot;(.*)&quot; as the &quot;(.*)&quot; date$/ do |date, date_label|
+When /^I select &quot;([^\&quot;]*)&quot; as the &quot;([^\&quot;]*)&quot; date$/ do |date, date_label|
   select_date(date, :from =&gt; date_label)
 end
 
-When /^I check &quot;(.*)&quot;$/ do |field|
-  check(field) 
+When /^I check &quot;([^\&quot;]*)&quot;$/ do |field|
+  check(field)
 end
 
-When /^I uncheck &quot;(.*)&quot;$/ do |field|
-  uncheck(field) 
+When /^I uncheck &quot;([^\&quot;]*)&quot;$/ do |field|
+  uncheck(field)
 end
 
-When /^I choose &quot;(.*)&quot;$/ do |field|
+When /^I choose &quot;([^\&quot;]*)&quot;$/ do |field|
   choose(field)
 end
 
-When /^I attach the file at &quot;(.*)&quot; to &quot;(.*)&quot; $/ do |path, field|
+When /^I attach the file at &quot;([^\&quot;]*)&quot; to &quot;([^\&quot;]*)&quot;$/ do |path, field|
   attach_file(field, path)
 end
 
-Then /^I should see &quot;(.*)&quot;$/ do |text|
-  response.body.should =~ /#{text}/m
+Then /^I should see &quot;([^\&quot;]*)&quot;$/ do |text|
+  response.should contain(text)
+end
+
+Then /^I should see \/([^\/]*)\/$/ do |regexp|
+  regexp = Regexp.new(regexp)
+  response.should contain(regexp)
+end
+
+Then /^I should not see &quot;([^\&quot;]*)&quot;$/ do |text|
+  response.should_not contain(text)
 end
 
-Then /^I should not see &quot;(.*)&quot;$/ do |text|
-  response.body.should_not =~ /#{text}/m
+Then /^I should not see \/([^\/]*)\/$/ do |regexp|
+  regexp = Regexp.new(regexp)
+  response.should_not contain(regexp)
 end
 
-Then /^the &quot;(.*)&quot; checkbox should be checked$/ do |label|
+Then /^the &quot;([^\&quot;]*)&quot; field should contain &quot;([^\&quot;]*)&quot;$/ do |field, value|
+  field_labeled(field).value.should =~ /#{value}/
+end
+
+Then /^the &quot;([^\&quot;]*)&quot; field should not contain &quot;([^\&quot;]*)&quot;$/ do |field, value|
+  field_labeled(field).value.should_not =~ /#{value}/
+end
+
+Then /^the &quot;([^\&quot;]*)&quot; checkbox should be checked$/ do |label|
   field_labeled(label).should be_checked
 end
 
+Then /^the &quot;([^\&quot;]*)&quot; checkbox should not be checked$/ do |label|
+  field_labeled(label).should_not be_checked
+end
+
+Then /^I should be on (.+)$/ do |page_name|
+  URI.parse(current_url).path.should == path_to(page_name)
+end
 
+Then /^show me the page$/ do
+  save_and_open_page
+end
\ No newline at end of file</diff>
      <filename>examples/rails_root/features/step_definitions/webrat_steps.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,30 @@
 # Sets up the Rails environment for Cucumber
-ENV[&quot;RAILS_ENV&quot;] = &quot;test&quot;
+ENV[&quot;RAILS_ENV&quot;] ||= &quot;test&quot;
 require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
 require 'cucumber/rails/world'
+
+# Comment out the next line if you don't want Cucumber Unicode support
+require 'cucumber/formatter/unicode'
+
+# Comment out the next line if you don't want transactions to
+# open/roll back around each scenario
 Cucumber::Rails.use_transactional_fixtures
 
+# Comment out the next line if you want Rails' own error handling
+# (e.g. rescue_action_in_public / rescue_responses / rescue_from)
+Cucumber::Rails.bypass_rescue
+
 require 'webrat'
-require 'cucumber/rails/rspec'
-require 'webrat/core/matchers'
+require 'cucumber/webrat/table_locator' # Lets you do table.diff!(table_at('#my_table').to_a)
 
 Webrat.configure do |config|
   config.mode = :rails
 end
 
+require 'cucumber/rails/rspec'
+require 'webrat/core/matchers'
 
-
+# email testing in cucumber
 require File.expand_path(File.dirname(__FILE__) + '../../../../../lib/email_spec')
 require 'email_spec/cucumber'
 </diff>
      <filename>examples/rails_root/features/support/env.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,6 @@ I want to verify that the example rails app runs all of it's features as expecte
     And I run &quot;cucumber features -q --no-color&quot;
     Then I should see the following summary report:
     &quot;&quot;&quot;
-    7 scenarios (4 failed, 3 passed)
-    53 steps (4 failed, 1 skipped, 48 passed)
+    9 scenarios (5 failed, 4 passed)
+    75 steps (5 failed, 1 skipped, 69 passed)
     &quot;&quot;&quot;
-</diff>
      <filename>features/rails_app.feature</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,8 @@ require 'fileutils'
 Given /^the example rails app is setup with the latest generators$/ do
   root_dir = File.join(File.expand_path(File.dirname(__FILE__)), &quot;..&quot;)
 
-  FileUtils.rm(&quot;#{root_dir}/examples/rails_root/features/step_definitions/email_steps.rb&quot;)
+  email_specs_path = &quot;#{root_dir}/examples/rails_root/features/step_definitions/email_steps.rb&quot;
+  FileUtils.rm(email_specs_path) if File.exists?(email_specs_path)
   FileUtils.mkdir_p(&quot;#{root_dir}/examples/rails_root/vendor/plugins/email_spec&quot;)
   FileUtils.cp_r(&quot;#{root_dir}/rails_generators&quot;, &quot;#{root_dir}/examples/rails_root/vendor/plugins/email_spec/&quot;)
 </diff>
      <filename>features/rails_app_steps.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,10 @@
-#Commonly used email steps
+# Commonly used email steps
 #
 # To add your own steps make a custom_email_steps.rb
 # The provided methods are:
 #
-# reset_mailer 
+# last_email_address
+# reset_mailer
 # open_last_email
 # visit_in_email
 # unread_emails_for
@@ -12,6 +13,16 @@
 # open_email
 # read_emails_for
 # find_email
+#
+# General form for emails tests is:
+#   - clear the email queue
+#   - execute steps that sends an email
+#   - check the user received an/no/[0-9] emails
+#   - open the email
+#   - inspect the email contents
+#   - interact with the email (e.g. click links)
+#
+# The Cucumber steps below are setup in this order.
 
 module EmailHelpers
   def current_email_address
@@ -23,64 +34,105 @@ module EmailHelpers
 end
 World(EmailHelpers)
 
-# Use this step to reset the e-mail queue within a scenario.
+#
+# Reset the e-mail queue within a scenario.
 # This is done automatically before each scenario.
+#
+
 Given /^(?:a clear email queue|no emails have been sent)$/ do
   reset_mailer
 end
 
-# Use this step to open the most recently sent e-mail. 
-When /^(?:I|they) open the email$/ do
-  open_email(current_email_address)
-end
+#
+# Check how many emails have been sent/received
+#
 
-When %r{^(?:I|they) follow &quot;([^&quot;]*?)&quot; in the email$} do |link|
-  visit_in_email(link)
+Then /^(?:I|they|&quot;([^&quot;]*?)&quot;) should receive (an|no|\d+) emails?$/ do |address, amount|
+  unread_emails_for(parse_current_email(address)).size.should == parse_email_count(amount)
 end
 
-Then /^(?:I|they) should receive (an|\d+) emails?$/ do |amount|
-  amount = 1 if amount == &quot;an&quot;
-  unread_emails_for(current_email_address).size.should == amount.to_i
+Then /^(?:I|they|&quot;([^&quot;]*?)&quot;) should have (an|no|\d+) emails?$/ do |address, amount|
+  mailbox_for(parse_current_email(address)).size.should == parse_email_count(amount)
 end
 
-Then /^(?:I|they) should not receive any emails?$/ do
-  unread_emails_for(current_email_address).size.should == 0
+# DEPRECATED
+# The following methods are left in for backwards compatibility and
+# should be removed by version 0.3.5.
+Then /^(?:I|they|&quot;([^&quot;]*?)&quot;) should not receive an email$/ do |address|
+  deprecation_notice &quot;The step 'I/they/[email] should not receive an email' is no longer supported.
+                      Please use 'I/they/[email] should receive no emails' instead.&quot;
+  unread_emails_for(parse_current_email(address)).size.should == 0
 end
 
-Then %r{^&quot;([^&quot;]*?)&quot; should receive (an|\d+) emails?$} do |address, amount|
-  amount = 1 if amount == &quot;an&quot;
-  unread_emails_for(address).size.should == amount.to_i 
+#
+# Accessing emails
+#
+
+# Opens the most recently received email
+When /^(?:I|they|&quot;([^&quot;]*?)&quot;) opens? the email$/ do |address|
+  open_email(parse_current_email(address))
 end
 
-Then %r{^&quot;([^&quot;]*?)&quot; should have (\d+) emails?$} do |address, n|
-  mailbox_for(address).size.should == n.to_i
+When /^(?:I|they|&quot;([^&quot;]*?)&quot;) opens? the email with subject &quot;([^&quot;]*?)&quot;$/ do |address, subject|
+  open_email(parse_current_email(address), :with_subject =&gt; subject)
 end
 
-Then %r{^&quot;([^&quot;]*?)&quot; should not receive an email$} do |address|
-  find_email(address).should be_nil
+When /^(?:I|they|&quot;([^&quot;]*?)&quot;) opens? the email with text &quot;([^&quot;]*?)&quot;$/ do |address, text|
+  open_email(parse_current_email(address), :with_text =&gt; text)
 end
 
-Then %r{^(?:I|they) should see &quot;([^&quot;]*?)&quot; in the subject$} do |text|
+#
+# Inspect the Email Contents
+#
+
+Then /^(?:I|they) should see &quot;([^&quot;]*?)&quot; in the email subject$/ do |text|
   current_email.should have_subject(Regexp.new(text))
 end
 
-Then %r{^(?:I|they) should see &quot;([^&quot;]*?)&quot; in the email$} do |text|
+Then /^(?:I|they) should see &quot;([^&quot;]*?)&quot; in the email body$/ do |text|
   current_email.body.should =~ Regexp.new(text)
 end
 
-When %r{^&quot;([^&quot;]*?)&quot; opens? the email$} do |address|
-  open_email(address)
+# DEPRECATED
+# The following methods are left in for backwards compatibility and
+# should be removed by version 0.3.5.
+Then /^(?:I|they) should see &quot;([^&quot;]*?)&quot; in the subject$/ do |text|
+  deprecation_notice &quot;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.&quot;
+  current_email.should have_subject(Regexp.new(text))
 end
-
-When %r{^&quot;([^&quot;]*?)&quot; opens? the email with subject &quot;([^&quot;]*?)&quot;$} do |address, subject|
-  open_email(address, :with_subject =&gt; subject)
+Then /^(?:I|they) should see &quot;([^&quot;]*?)&quot; in the email$/ do |text|
+  deprecation_notice &quot;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.&quot;
+  current_email.body.should =~ Regexp.new(text)
 end
 
-When %r{^&quot;([^&quot;]*?)&quot; opens? the email with text &quot;([^&quot;]*?)&quot;$} do |address, text|
-  open_email(address, :with_text =&gt; text)
+#
+# Interact with Email Contents
+#
+
+When /^(?:I|they) follow &quot;([^&quot;]*?)&quot; in the email$/ do |link|
+  visit_in_email(link)
 end
 
 When /^(?:I|they) click the first link in the email$/ do
   click_first_link_in_email
 end
 
+private
+
+def deprecation_notice(text)
+  puts &quot;&quot;
+  puts &quot;DEPRECATION: #{text.split.join(' ')}&quot;
+  puts &quot;&quot;
+end
+
+def parse_current_email(address)
+  address.nil? ? current_email_address : address
+end
+
+def parse_email_count(amount)
+  amount = 0 if amount == &quot;no&quot;
+  amount = 1 if amount == &quot;an&quot;
+  amount.to_i
+end</diff>
      <filename>rails_generators/email_spec/templates/email_steps.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>examples/rails_root/app/controllers/application.rb</filename>
    </removed>
    <removed>
      <filename>examples/rails_root/cucumber.yml</filename>
    </removed>
    <removed>
      <filename>examples/rails_root/features/step_definitions/email_steps.rb</filename>
    </removed>
    <removed>
      <filename>examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/email_spec_generator.rb</filename>
    </removed>
    <removed>
      <filename>examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/templates/email_steps.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>ec0c9bea0d702a6433aae9a10984a8d3c6ecc86f</id>
    </parent>
  </parents>
  <author>
    <name>Kieran Pilkington</name>
    <email>kieran@katipo.co.nz</email>
  </author>
  <url>http://github.com/bmabey/email-spec/commit/1cbfde8b3a2a0ca9770e75d95f7f8be8e6598653</url>
  <id>1cbfde8b3a2a0ca9770e75d95f7f8be8e6598653</id>
  <committed-date>2009-08-13T17:23:44-07:00</committed-date>
  <authored-date>2009-08-13T17:23:44-07:00</authored-date>
  <message>Refactored email_steps.rb (cleaner, more documented). Refactored test suite (tests more things, and a bit more cleanly). Made necessary changes to get tests working on latest Rails, Cucumber, and Webrat versions. Git no longer tracks examples/rails_root/features/step_definitions/email_steps.rb or examples/rails_root/vendor/plugins/email_spec because they're identical copies we only use in testing.</message>
  <tree>e7d8a65d21891712dce9305953db98095358e06c</tree>
  <committer>
    <name>Kieran Pilkington</name>
    <email>kieran@katipo.co.nz</email>
  </committer>
</commit>
