bmabey-email_spec 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +12 -2
- data/Rakefile +16 -1
- data/examples/rails_root/app/controllers/{application.rb → application_controller.rb} +0 -0
- data/examples/rails_root/app/models/user_mailer.rb +1 -2
- data/examples/rails_root/config/boot.rb +1 -0
- data/examples/rails_root/config/environment.rb +2 -2
- data/examples/rails_root/config/environments/test.rb +6 -10
- data/examples/rails_root/features/errors.feature +31 -41
- data/examples/rails_root/features/example.feature +44 -41
- data/examples/rails_root/features/step_definitions/user_steps.rb +11 -8
- data/examples/rails_root/features/step_definitions/webrat_steps.rb +72 -39
- data/examples/rails_root/features/support/env.rb +15 -4
- data/examples/rails_root/features/support/paths.rb +21 -0
- data/examples/rails_root/script/cucumber +6 -4
- data/examples/rails_root/spec/models/user_mailer_spec.rb +3 -3
- data/examples/rails_root/spec/spec_helper.rb +1 -1
- data/lib/email_spec/deliveries.rb +0 -2
- data/lib/email_spec/helpers.rb +48 -31
- data/rails_generators/email_spec/templates/email_steps.rb +66 -30
- metadata +72 -83
- data/examples/rails_root/cucumber.yml +0 -1
- data/examples/rails_root/features/step_definitions/email_steps.rb +0 -86
- data/examples/rails_root/stories/all.rb +0 -4
- data/examples/rails_root/stories/helper.rb +0 -3
- data/examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/email_spec_generator.rb +0 -17
- data/examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/templates/email_steps.rb +0 -86
| @@ -1,19 +1,30 @@ | |
| 1 1 | 
             
            # Sets up the Rails environment for Cucumber
         | 
| 2 | 
            -
            ENV["RAILS_ENV"]  | 
| 2 | 
            +
            ENV["RAILS_ENV"] ||= "test"
         | 
| 3 3 | 
             
            require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
         | 
| 4 4 | 
             
            require 'cucumber/rails/world'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Comment out the next line if you don't want Cucumber Unicode support
         | 
| 7 | 
            +
            require 'cucumber/formatter/unicode'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Comment out the next line if you don't want transactions to
         | 
| 10 | 
            +
            # open/roll back around each scenario
         | 
| 5 11 | 
             
            Cucumber::Rails.use_transactional_fixtures
         | 
| 6 12 |  | 
| 13 | 
            +
            # Comment out the next line if you want Rails' own error handling
         | 
| 14 | 
            +
            # (e.g. rescue_action_in_public / rescue_responses / rescue_from)
         | 
| 15 | 
            +
            Cucumber::Rails.bypass_rescue
         | 
| 16 | 
            +
             | 
| 7 17 | 
             
            require 'webrat'
         | 
| 8 | 
            -
            require 'cucumber/ | 
| 9 | 
            -
            require 'webrat/core/matchers'
         | 
| 18 | 
            +
            require 'cucumber/webrat/table_locator' # Lets you do table.diff!(table_at('#my_table').to_a)
         | 
| 10 19 |  | 
| 11 20 | 
             
            Webrat.configure do |config|
         | 
| 12 21 | 
             
              config.mode = :rails
         | 
| 13 22 | 
             
            end
         | 
| 14 23 |  | 
| 24 | 
            +
            require 'cucumber/rails/rspec'
         | 
| 25 | 
            +
            require 'webrat/core/matchers'
         | 
| 15 26 |  | 
| 16 | 
            -
             | 
| 27 | 
            +
            # email testing in cucumber
         | 
| 17 28 | 
             
            require File.expand_path(File.dirname(__FILE__) + '../../../../../lib/email_spec')
         | 
| 18 29 | 
             
            require 'email_spec/cucumber'
         | 
| 19 30 |  | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module NavigationHelpers
         | 
| 2 | 
            +
              # Maps a name to a path. Used by the
         | 
| 3 | 
            +
              #
         | 
| 4 | 
            +
              #   When /^I go to (.+)$/ do |page_name|
         | 
| 5 | 
            +
              #
         | 
| 6 | 
            +
              # step definition in webrat_steps.rb
         | 
| 7 | 
            +
              #
         | 
| 8 | 
            +
              def path_to(page_name)
         | 
| 9 | 
            +
                case page_name
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                when /the homepage/
         | 
| 12 | 
            +
                  '/'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                else
         | 
| 15 | 
            +
                  raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
         | 
| 16 | 
            +
                    "Now, go and add a mapping in #{__FILE__}"
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            World(NavigationHelpers)
         | 
| @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 2 | 
             
            begin
         | 
| 3 3 | 
             
              load File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/cucumber/bin/cucumber")
         | 
| 4 | 
            -
            rescue LoadError
         | 
| 5 | 
            -
               | 
| 6 | 
            -
               | 
| 7 | 
            -
             | 
| 4 | 
            +
            rescue LoadError => e
         | 
| 5 | 
            +
              raise unless e.to_s =~ /cucumber/
         | 
| 6 | 
            +
              require 'rubygems'
         | 
| 7 | 
            +
              require 'cucumber'
         | 
| 8 | 
            +
              load Cucumber::BINARY
         | 
| 9 | 
            +
            end
         | 
| @@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/../spec_helper' | |
| 3 3 | 
             
            # These two example groups are specifying the exact same behavior.  However, the documentation style is different
         | 
| 4 4 | 
             
            # and the value that each one provides is different with various trade-offs.  Run these examples with the specdoc 
         | 
| 5 5 | 
             
            # formatter to get an idea of how they differ.
         | 
| 6 | 
            -
             | 
| 7 6 | 
             
            # Example of documenting the behaviour explicitly and expressing the intent in the example's sentence.
         | 
| 8 7 | 
             
            describe "Signup Email" do
         | 
| 9 8 | 
             
              include EmailSpec::Helpers
         | 
| 10 9 | 
             
              include EmailSpec::Matchers
         | 
| 11 10 | 
             
              include ActionController::UrlWriter
         | 
| 11 | 
            +
              default_url_options = {:host => 'example.com'}
         | 
| 12 12 |  | 
| 13 13 | 
             
              before(:all) do
         | 
| 14 14 | 
             
                @email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
         | 
| @@ -25,7 +25,7 @@ describe "Signup Email" do | |
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 27 | 
             
              it "should contain a link to the confirmation page" do
         | 
| 28 | 
            -
                @email.should have_body_text(/#{confirm_account_url}/)
         | 
| 28 | 
            +
                @email.should have_body_text(/#{confirm_account_url(:host => 'example.com')}/)
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 31 | 
             
              it { should have_subject(/Account confirmation/) }
         | 
| @@ -45,7 +45,7 @@ describe "Signup Email" do | |
| 45 45 |  | 
| 46 46 | 
             
              subject { @email }
         | 
| 47 47 |  | 
| 48 | 
            -
              it { should have_body_text(/#{confirm_account_url}/) }
         | 
| 48 | 
            +
              it { should have_body_text(/#{confirm_account_url(:host => 'example.com')}/) }
         | 
| 49 49 | 
             
              it { should have_subject(/Account confirmation/) }
         | 
| 50 50 |  | 
| 51 51 | 
             
              describe "sent with email address of 'jojo@yahoo.com', and users name 'Jojo Binks'" do
         | 
| @@ -6,7 +6,7 @@ require 'spec' | |
| 6 6 | 
             
            require 'spec/rails'
         | 
| 7 7 |  | 
| 8 8 | 
             
            require File.expand_path(File.dirname(__FILE__) + "/model_factory.rb")
         | 
| 9 | 
            -
            require ( | 
| 9 | 
            +
            require (RAILS_ROOT + '/../../lib/email_spec.rb')
         | 
| 10 10 |  | 
| 11 11 | 
             
            Spec::Runner.configure do |config|
         | 
| 12 12 | 
             
              config.include(Fixjour)
         | 
| @@ -13,7 +13,6 @@ module EmailSpec | |
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 15 | 
             
                def mailbox_for(address)
         | 
| 16 | 
            -
                  address = AddressConverter.instance.convert(address)
         | 
| 17 16 | 
             
                  ActionMailer::Base.deliveries.select { |m| m.to.include?(address) || (m.bcc && m.bcc.include?(address)) || (m.cc && m.cc.include?(address)) }
         | 
| 18 17 | 
             
                end
         | 
| 19 18 | 
             
              end
         | 
| @@ -36,7 +35,6 @@ module EmailSpec | |
| 36 35 | 
             
                end
         | 
| 37 36 |  | 
| 38 37 | 
             
                def mailbox_for(address)
         | 
| 39 | 
            -
                  address = AddressConverter.instance.convert(address)
         | 
| 40 38 | 
             
                  Email.all.select { |email| email.to.include?(address) || email.bcc.include?(address) || email.cc.include?(address) }.map{ |email| parse_to_tmail(email) }
         | 
| 41 39 | 
             
                end
         | 
| 42 40 |  | 
    
        data/lib/email_spec/helpers.rb
    CHANGED
    
    | @@ -5,29 +5,28 @@ module EmailSpec | |
| 5 5 |  | 
| 6 6 | 
             
              module Helpers
         | 
| 7 7 | 
             
                include Deliveries
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
                def visit_in_email(link_text)
         | 
| 10 10 | 
             
                  visit(parse_email_for_link(current_email, link_text))
         | 
| 11 11 | 
             
                end
         | 
| 12 | 
            -
             | 
| 12 | 
            +
             | 
| 13 13 | 
             
                def click_email_link_matching(regex, email = current_email)
         | 
| 14 14 | 
             
                  url = links_in_email(email).detect { |link| link =~ regex }
         | 
| 15 15 | 
             
                  raise "No link found matching #{regex.inspect} in #{email.body}" unless url
         | 
| 16 16 | 
             
                  request_uri = URI::parse(url).request_uri
         | 
| 17 17 | 
             
                  visit request_uri
         | 
| 18 18 | 
             
                end
         | 
| 19 | 
            -
             | 
| 19 | 
            +
             | 
| 20 20 | 
             
                def click_first_link_in_email(email = current_email)
         | 
| 21 21 | 
             
                  link = links_in_email(email).first
         | 
| 22 22 | 
             
                  request_uri = URI::parse(link).request_uri
         | 
| 23 23 | 
             
                  visit request_uri
         | 
| 24 24 | 
             
                end
         | 
| 25 | 
            -
             | 
| 25 | 
            +
             | 
| 26 26 | 
             
                def open_email(address, opts={})
         | 
| 27 | 
            -
                  address = convert_address(address)
         | 
| 28 27 | 
             
                  set_current_email(find_email!(address, opts))
         | 
| 29 28 | 
             
                end
         | 
| 30 | 
            -
             | 
| 29 | 
            +
             | 
| 31 30 | 
             
                alias_method :open_email_for, :open_email
         | 
| 32 31 |  | 
| 33 32 | 
             
                def open_last_email
         | 
| @@ -35,38 +34,35 @@ module EmailSpec | |
| 35 34 | 
             
                end
         | 
| 36 35 |  | 
| 37 36 | 
             
                def open_last_email_for(address)
         | 
| 38 | 
            -
                  address = convert_address(address)
         | 
| 39 37 | 
             
                  set_current_email(mailbox_for(address).last)
         | 
| 40 38 | 
             
                end
         | 
| 41 | 
            -
             | 
| 39 | 
            +
             | 
| 42 40 | 
             
                def current_email(address=nil)
         | 
| 43 41 | 
             
                  address = convert_address(address)
         | 
| 44 42 | 
             
                  email = address ? email_spec_hash[:current_emails][address] : email_spec_hash[:current_email]
         | 
| 45 | 
            -
                  raise Spec::Expectations::ExpectationNotMetError, "Expected an open email but none was found. Did you forget to call open_email?" unless email | 
| 43 | 
            +
                  raise Spec::Expectations::ExpectationNotMetError, "Expected an open email but none was found. Did you forget to call open_email?" unless email
         | 
| 46 44 | 
             
                  email
         | 
| 47 45 | 
             
                end
         | 
| 48 | 
            -
             | 
| 46 | 
            +
             | 
| 49 47 | 
             
                def unread_emails_for(address)
         | 
| 50 | 
            -
                  address = convert_address(address)
         | 
| 51 48 | 
             
                  mailbox_for(address) - read_emails_for(address)
         | 
| 52 49 | 
             
                end
         | 
| 53 | 
            -
             | 
| 50 | 
            +
             | 
| 54 51 | 
             
                def read_emails_for(address)
         | 
| 55 | 
            -
                   | 
| 56 | 
            -
                  email_spec_hash[:read_emails][address] ||= []
         | 
| 52 | 
            +
                  email_spec_hash[:read_emails][convert_address(address)] ||= []
         | 
| 57 53 | 
             
                end
         | 
| 58 | 
            -
             | 
| 54 | 
            +
             | 
| 59 55 | 
             
                def find_email(address, opts={})
         | 
| 60 56 | 
             
                  address = convert_address(address)
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                     | 
| 57 | 
            +
                  if opts[:with_subject]
         | 
| 58 | 
            +
                    mailbox_for(address).find { |m| m.subject =~ Regexp.new(opts[:with_subject]) }
         | 
| 63 59 | 
             
                  elsif opts[:with_text]
         | 
| 64 | 
            -
                     | 
| 60 | 
            +
                    mailbox_for(address).find { |m| m.body =~ Regexp.new(opts[:with_text]) }
         | 
| 65 61 | 
             
                  else
         | 
| 66 | 
            -
                     | 
| 62 | 
            +
                    mailbox_for(address).first
         | 
| 67 63 | 
             
                  end
         | 
| 68 64 | 
             
                end
         | 
| 69 | 
            -
             | 
| 65 | 
            +
             | 
| 70 66 | 
             
                def links_in_email(email)
         | 
| 71 67 | 
             
                  URI.extract(email.body, ['http', 'https'])
         | 
| 72 68 | 
             
                end
         | 
| @@ -78,7 +74,6 @@ module EmailSpec | |
| 78 74 | 
             
                end
         | 
| 79 75 |  | 
| 80 76 | 
             
                def find_email!(address, opts={})
         | 
| 81 | 
            -
                  address = convert_address(address)
         | 
| 82 77 | 
             
                  email = find_email(address, opts)
         | 
| 83 78 | 
             
                  if email.nil?
         | 
| 84 79 | 
             
                    error = "#{opts.keys.first.to_s.humanize unless opts.empty?} #{('"' + opts.values.first.to_s.humanize + '"') unless opts.empty?}"
         | 
| @@ -90,43 +85,65 @@ module EmailSpec | |
| 90 85 | 
             
                def set_current_email(email)
         | 
| 91 86 | 
             
                  return unless email
         | 
| 92 87 | 
             
                  email.to.each do |to|
         | 
| 93 | 
            -
                    read_emails_for(to) << email | 
| 88 | 
            +
                    read_emails_for(to) << email
         | 
| 94 89 | 
             
                    email_spec_hash[:current_emails][to] = email
         | 
| 95 90 | 
             
                  end
         | 
| 96 91 | 
             
                  email_spec_hash[:current_email] = email
         | 
| 97 92 | 
             
                end
         | 
| 98 | 
            -
             | 
| 93 | 
            +
             | 
| 99 94 | 
             
                def parse_email_for_link(email, text_or_regex)
         | 
| 100 95 | 
             
                  email.should have_body_text(text_or_regex)
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                  url = parse_email_for_explicit_link(email, text_or_regex) | 
| 96 | 
            +
             | 
| 97 | 
            +
                  url = parse_email_for_explicit_link(email, text_or_regex)
         | 
| 103 98 | 
             
                  url ||= parse_email_for_anchor_text_link(email, text_or_regex)
         | 
| 104 99 |  | 
| 105 100 | 
             
                  raise "No link found matching #{text_or_regex.inspect} in #{email}" unless url
         | 
| 106 101 | 
             
                  url
         | 
| 107 102 | 
             
                end
         | 
| 108 | 
            -
             | 
| 103 | 
            +
             | 
| 109 104 | 
             
                # e.g. confirm in http://confirm
         | 
| 110 105 | 
             
                def parse_email_for_explicit_link(email, regex)
         | 
| 111 106 | 
             
                  regex = /#{Regexp.escape(regex)}/ unless regex.is_a?(Regexp)
         | 
| 112 107 | 
             
                  url = links_in_email(email).detect { |link| link =~ regex }
         | 
| 113 108 | 
             
                  URI::parse(url).request_uri if url
         | 
| 114 109 | 
             
                end
         | 
| 115 | 
            -
             | 
| 110 | 
            +
             | 
| 116 111 | 
             
                # e.g. Click here in  <a href="http://confirm">Click here</a>
         | 
| 117 112 | 
             
                def parse_email_for_anchor_text_link(email, link_text)
         | 
| 118 113 | 
             
                  email.body =~ %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_text}[^<]*?</a>}
         | 
| 119 114 | 
             
                  URI.split($~[1])[5..-1].compact!.join("?").gsub("&", "&")
         | 
| 120 | 
            -
                  # sub correct ampersand after rails switches it (http://dev.rubyonrails.org/ticket/4002) | 
| 115 | 
            +
                  # sub correct ampersand after rails switches it (http://dev.rubyonrails.org/ticket/4002)
         | 
| 121 116 | 
             
                end
         | 
| 122 117 |  | 
| 118 | 
            +
                def parse_email_count(amount)
         | 
| 119 | 
            +
                  case amount
         | 
| 120 | 
            +
                  when "no"
         | 
| 121 | 
            +
                    0
         | 
| 122 | 
            +
                  when "an"
         | 
| 123 | 
            +
                    1
         | 
| 124 | 
            +
                  else
         | 
| 125 | 
            +
                    amount.to_i
         | 
| 126 | 
            +
                  end
         | 
| 127 | 
            +
                end
         | 
| 123 128 |  | 
| 124 129 | 
             
                attr_reader :last_email_address
         | 
| 125 | 
            -
             | 
| 130 | 
            +
             | 
| 126 131 | 
             
                def convert_address(address)
         | 
| 127 | 
            -
                  @last_email_address = address
         | 
| 128 | 
            -
                  AddressConverter.instance.convert( | 
| 132 | 
            +
                  @last_email_address = (address || current_email_address)
         | 
| 133 | 
            +
                  AddressConverter.instance.convert(@last_email_address)
         | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
             | 
| 137 | 
            +
                def mailbox_for(address)
         | 
| 138 | 
            +
                  super(convert_address(address)) # super resides in Deliveries
         | 
| 129 139 | 
             
                end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                def email_spec_deprecate(text)
         | 
| 142 | 
            +
                  puts ""
         | 
| 143 | 
            +
                  puts "DEPRECATION: #{text.split.join(' ')}"
         | 
| 144 | 
            +
                  puts ""
         | 
| 145 | 
            +
                end
         | 
| 146 | 
            +
             | 
| 130 147 | 
             
              end
         | 
| 131 148 | 
             
            end
         | 
| 132 149 |  | 
| @@ -1,9 +1,10 @@ | |
| 1 | 
            -
            #Commonly used email steps
         | 
| 1 | 
            +
            # Commonly used email steps
         | 
| 2 2 | 
             
            #
         | 
| 3 3 | 
             
            # To add your own steps make a custom_email_steps.rb
         | 
| 4 4 | 
             
            # The provided methods are:
         | 
| 5 5 | 
             
            #
         | 
| 6 | 
            -
            #  | 
| 6 | 
            +
            # last_email_address
         | 
| 7 | 
            +
            # reset_mailer
         | 
| 7 8 | 
             
            # open_last_email
         | 
| 8 9 | 
             
            # visit_in_email
         | 
| 9 10 | 
             
            # unread_emails_for
         | 
| @@ -12,6 +13,16 @@ | |
| 12 13 | 
             
            # open_email
         | 
| 13 14 | 
             
            # read_emails_for
         | 
| 14 15 | 
             
            # find_email
         | 
| 16 | 
            +
            #
         | 
| 17 | 
            +
            # General form for email scenarios are:
         | 
| 18 | 
            +
            #   - clear the email queue (done automatically by email_spec)
         | 
| 19 | 
            +
            #   - execute steps that sends an email
         | 
| 20 | 
            +
            #   - check the user received an/no/[0-9] emails
         | 
| 21 | 
            +
            #   - open the email
         | 
| 22 | 
            +
            #   - inspect the email contents
         | 
| 23 | 
            +
            #   - interact with the email (e.g. click links)
         | 
| 24 | 
            +
            #
         | 
| 25 | 
            +
            # The Cucumber steps below are setup in this order.
         | 
| 15 26 |  | 
| 16 27 | 
             
            module EmailHelpers
         | 
| 17 28 | 
             
              def current_email_address
         | 
| @@ -21,63 +32,88 @@ module EmailHelpers | |
| 21 32 | 
             
                last_email_address || "example@example.com"
         | 
| 22 33 | 
             
              end
         | 
| 23 34 | 
             
            end
         | 
| 35 | 
            +
             | 
| 24 36 | 
             
            World(EmailHelpers)
         | 
| 25 37 |  | 
| 26 | 
            -
            # | 
| 38 | 
            +
            #
         | 
| 39 | 
            +
            # Reset the e-mail queue within a scenario.
         | 
| 27 40 | 
             
            # This is done automatically before each scenario.
         | 
| 41 | 
            +
            #
         | 
| 42 | 
            +
             | 
| 28 43 | 
             
            Given /^(?:a clear email queue|no emails have been sent)$/ do
         | 
| 29 44 | 
             
              reset_mailer
         | 
| 30 45 | 
             
            end
         | 
| 31 46 |  | 
| 32 | 
            -
            # | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
            end
         | 
| 47 | 
            +
            #
         | 
| 48 | 
            +
            # Check how many emails have been sent/received
         | 
| 49 | 
            +
            #
         | 
| 36 50 |  | 
| 37 | 
            -
             | 
| 38 | 
            -
               | 
| 51 | 
            +
            Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
         | 
| 52 | 
            +
              unread_emails_for(address).size.should == parse_email_count(amount)
         | 
| 39 53 | 
             
            end
         | 
| 40 54 |  | 
| 41 | 
            -
            Then /^(?:I|they) should  | 
| 42 | 
            -
               | 
| 43 | 
            -
              unread_emails_for(current_email_address).size.should == amount.to_i
         | 
| 55 | 
            +
            Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
         | 
| 56 | 
            +
              mailbox_for(address).size.should == parse_email_count(amount)
         | 
| 44 57 | 
             
            end
         | 
| 45 58 |  | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 59 | 
            +
            # DEPRECATED
         | 
| 60 | 
            +
            # The following methods are left in for backwards compatibility and
         | 
| 61 | 
            +
            # should be removed by version 0.3.5.
         | 
| 62 | 
            +
            Then /^(?:I|they|"([^"]*?)") should not receive an email$/ do |address|
         | 
| 63 | 
            +
              email_spec_deprecate "The step 'I/they/[email] should not receive an email' is no longer supported.
         | 
| 64 | 
            +
                                  Please use 'I/they/[email] should receive no emails' instead."
         | 
| 65 | 
            +
              unread_emails_for(address).size.should == 0
         | 
| 48 66 | 
             
            end
         | 
| 49 67 |  | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 68 | 
            +
            #
         | 
| 69 | 
            +
            # Accessing emails
         | 
| 70 | 
            +
            #
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            # Opens the most recently received email
         | 
| 73 | 
            +
            When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
         | 
| 74 | 
            +
              open_email(address)
         | 
| 53 75 | 
             
            end
         | 
| 54 76 |  | 
| 55 | 
            -
             | 
| 56 | 
            -
               | 
| 77 | 
            +
            When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
         | 
| 78 | 
            +
              open_email(address, :with_subject => subject)
         | 
| 57 79 | 
             
            end
         | 
| 58 80 |  | 
| 59 | 
            -
             | 
| 60 | 
            -
               | 
| 81 | 
            +
            When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
         | 
| 82 | 
            +
              open_email(address, :with_text => text)
         | 
| 61 83 | 
             
            end
         | 
| 62 84 |  | 
| 63 | 
            -
             | 
| 85 | 
            +
            #
         | 
| 86 | 
            +
            # Inspect the Email Contents
         | 
| 87 | 
            +
            #
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
         | 
| 64 90 | 
             
              current_email.should have_subject(Regexp.new(text))
         | 
| 65 91 | 
             
            end
         | 
| 66 92 |  | 
| 67 | 
            -
            Then  | 
| 93 | 
            +
            Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
         | 
| 68 94 | 
             
              current_email.body.should =~ Regexp.new(text)
         | 
| 69 95 | 
             
            end
         | 
| 70 96 |  | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 97 | 
            +
            # DEPRECATED
         | 
| 98 | 
            +
            # The following methods are left in for backwards compatibility and
         | 
| 99 | 
            +
            # should be removed by version 0.3.5.
         | 
| 100 | 
            +
            Then /^(?:I|they) should see "([^"]*?)" in the subject$/ do |text|
         | 
| 101 | 
            +
              email_spec_deprecate "The step 'I/they should see [text] in the subject' is no longer supported.
         | 
| 102 | 
            +
                                  Please use 'I/they should see [text] in the email subject' instead."
         | 
| 103 | 
            +
              current_email.should have_subject(Regexp.new(text))
         | 
| 73 104 | 
             
            end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 105 | 
            +
            Then /^(?:I|they) should see "([^"]*?)" in the email$/ do |text|
         | 
| 106 | 
            +
              email_spec_deprecate "The step 'I/they should see [text] in the email' is no longer supported.
         | 
| 107 | 
            +
                                  Please use 'I/they should see [text] in the email body' instead."
         | 
| 108 | 
            +
              current_email.body.should =~ Regexp.new(text)
         | 
| 77 109 | 
             
            end
         | 
| 78 110 |  | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 111 | 
            +
            #
         | 
| 112 | 
            +
            # Interact with Email Contents
         | 
| 113 | 
            +
            #
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
         | 
| 116 | 
            +
              visit_in_email(link)
         | 
| 81 117 | 
             
            end
         | 
| 82 118 |  | 
| 83 119 | 
             
            When /^(?:I|they) click the first link in the email$/ do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: bmabey-email_spec
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Ben Mabey
         | 
| @@ -11,7 +11,7 @@ autorequire: | |
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 13 |  | 
| 14 | 
            -
            date: 2009-08- | 
| 14 | 
            +
            date: 2009-08-19 00:00:00 -07:00
         | 
| 15 15 | 
             
            default_executable: 
         | 
| 16 16 | 
             
            dependencies: []
         | 
| 17 17 |  | 
| @@ -29,78 +29,6 @@ files: | |
| 29 29 | 
             
            - MIT-LICENSE.txt
         | 
| 30 30 | 
             
            - README.rdoc
         | 
| 31 31 | 
             
            - Rakefile
         | 
| 32 | 
            -
            - examples/rails_root/Rakefile
         | 
| 33 | 
            -
            - examples/rails_root/app/controllers/application.rb
         | 
| 34 | 
            -
            - examples/rails_root/app/controllers/welcome_controller.rb
         | 
| 35 | 
            -
            - examples/rails_root/app/helpers/application_helper.rb
         | 
| 36 | 
            -
            - examples/rails_root/app/helpers/welcome_helper.rb
         | 
| 37 | 
            -
            - examples/rails_root/app/models/user.rb
         | 
| 38 | 
            -
            - examples/rails_root/app/models/user_mailer.rb
         | 
| 39 | 
            -
            - examples/rails_root/app/views/user_mailer/signup.erb
         | 
| 40 | 
            -
            - examples/rails_root/app/views/welcome/confirm.html.erb
         | 
| 41 | 
            -
            - examples/rails_root/app/views/welcome/index.html.erb
         | 
| 42 | 
            -
            - examples/rails_root/app/views/welcome/signup.html.erb
         | 
| 43 | 
            -
            - examples/rails_root/config/boot.rb
         | 
| 44 | 
            -
            - examples/rails_root/config/database.yml
         | 
| 45 | 
            -
            - examples/rails_root/config/environment.rb
         | 
| 46 | 
            -
            - examples/rails_root/config/environments/development.rb
         | 
| 47 | 
            -
            - examples/rails_root/config/environments/production.rb
         | 
| 48 | 
            -
            - examples/rails_root/config/environments/test.rb
         | 
| 49 | 
            -
            - examples/rails_root/config/initializers/inflections.rb
         | 
| 50 | 
            -
            - examples/rails_root/config/initializers/mime_types.rb
         | 
| 51 | 
            -
            - examples/rails_root/config/initializers/new_rails_defaults.rb
         | 
| 52 | 
            -
            - examples/rails_root/config/routes.rb
         | 
| 53 | 
            -
            - examples/rails_root/cucumber.yml
         | 
| 54 | 
            -
            - examples/rails_root/db/migrate/20090125013728_create_users.rb
         | 
| 55 | 
            -
            - examples/rails_root/db/schema.rb
         | 
| 56 | 
            -
            - examples/rails_root/doc/README_FOR_APP
         | 
| 57 | 
            -
            - examples/rails_root/features/errors.feature
         | 
| 58 | 
            -
            - examples/rails_root/features/example.feature
         | 
| 59 | 
            -
            - examples/rails_root/features/step_definitions/email_steps.rb
         | 
| 60 | 
            -
            - examples/rails_root/features/step_definitions/user_steps.rb
         | 
| 61 | 
            -
            - examples/rails_root/features/step_definitions/webrat_steps.rb
         | 
| 62 | 
            -
            - examples/rails_root/features/support/env.rb
         | 
| 63 | 
            -
            - examples/rails_root/public/404.html
         | 
| 64 | 
            -
            - examples/rails_root/public/422.html
         | 
| 65 | 
            -
            - examples/rails_root/public/500.html
         | 
| 66 | 
            -
            - examples/rails_root/public/dispatch.rb
         | 
| 67 | 
            -
            - examples/rails_root/public/favicon.ico
         | 
| 68 | 
            -
            - examples/rails_root/public/images/rails.png
         | 
| 69 | 
            -
            - examples/rails_root/public/javascripts/application.js
         | 
| 70 | 
            -
            - examples/rails_root/public/javascripts/controls.js
         | 
| 71 | 
            -
            - examples/rails_root/public/javascripts/dragdrop.js
         | 
| 72 | 
            -
            - examples/rails_root/public/javascripts/effects.js
         | 
| 73 | 
            -
            - examples/rails_root/public/javascripts/prototype.js
         | 
| 74 | 
            -
            - examples/rails_root/public/robots.txt
         | 
| 75 | 
            -
            - examples/rails_root/script/about
         | 
| 76 | 
            -
            - examples/rails_root/script/autospec
         | 
| 77 | 
            -
            - examples/rails_root/script/console
         | 
| 78 | 
            -
            - examples/rails_root/script/cucumber
         | 
| 79 | 
            -
            - examples/rails_root/script/dbconsole
         | 
| 80 | 
            -
            - examples/rails_root/script/destroy
         | 
| 81 | 
            -
            - examples/rails_root/script/generate
         | 
| 82 | 
            -
            - examples/rails_root/script/performance/benchmarker
         | 
| 83 | 
            -
            - examples/rails_root/script/performance/profiler
         | 
| 84 | 
            -
            - examples/rails_root/script/performance/request
         | 
| 85 | 
            -
            - examples/rails_root/script/plugin
         | 
| 86 | 
            -
            - examples/rails_root/script/process/inspector
         | 
| 87 | 
            -
            - examples/rails_root/script/process/reaper
         | 
| 88 | 
            -
            - examples/rails_root/script/process/spawner
         | 
| 89 | 
            -
            - examples/rails_root/script/runner
         | 
| 90 | 
            -
            - examples/rails_root/script/server
         | 
| 91 | 
            -
            - examples/rails_root/script/spec
         | 
| 92 | 
            -
            - examples/rails_root/script/spec_server
         | 
| 93 | 
            -
            - examples/rails_root/spec/controllers/welcome_controller_spec.rb
         | 
| 94 | 
            -
            - examples/rails_root/spec/model_factory.rb
         | 
| 95 | 
            -
            - examples/rails_root/spec/models/user_mailer_spec.rb
         | 
| 96 | 
            -
            - examples/rails_root/spec/models/user_spec.rb
         | 
| 97 | 
            -
            - examples/rails_root/spec/rcov.opts
         | 
| 98 | 
            -
            - examples/rails_root/spec/spec.opts
         | 
| 99 | 
            -
            - examples/rails_root/spec/spec_helper.rb
         | 
| 100 | 
            -
            - examples/rails_root/stories/all.rb
         | 
| 101 | 
            -
            - examples/rails_root/stories/helper.rb
         | 
| 102 | 
            -
            - examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/email_spec_generator.rb
         | 
| 103 | 
            -
            - examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/templates/email_steps.rb
         | 
| 104 32 | 
             
            - install.rb
         | 
| 105 33 | 
             
            - lib/email-spec.rb
         | 
| 106 34 | 
             
            - lib/email_spec.rb
         | 
| @@ -112,9 +40,6 @@ files: | |
| 112 40 | 
             
            - lib/email_spec/matchers.rb
         | 
| 113 41 | 
             
            - rails_generators/email_spec/email_spec_generator.rb
         | 
| 114 42 | 
             
            - rails_generators/email_spec/templates/email_steps.rb
         | 
| 115 | 
            -
            - spec/email_spec/matchers_spec.rb
         | 
| 116 | 
            -
            - spec/spec.opts
         | 
| 117 | 
            -
            - spec/spec_helper.rb
         | 
| 118 43 | 
             
            has_rdoc: false
         | 
| 119 44 | 
             
            homepage: http://github.com/bmabey/email-spec/
         | 
| 120 45 | 
             
            licenses: 
         | 
| @@ -143,36 +68,100 @@ signing_key: | |
| 143 68 | 
             
            specification_version: 3
         | 
| 144 69 | 
             
            summary: Easily test email in rspec and cucumber
         | 
| 145 70 | 
             
            test_files: 
         | 
| 71 | 
            +
            - spec/email_spec
         | 
| 146 72 | 
             
            - spec/email_spec/matchers_spec.rb
         | 
| 73 | 
            +
            - spec/spec.opts
         | 
| 147 74 | 
             
            - spec/spec_helper.rb
         | 
| 148 | 
            -
            - examples/rails_root | 
| 75 | 
            +
            - examples/rails_root
         | 
| 76 | 
            +
            - examples/rails_root/app
         | 
| 77 | 
            +
            - examples/rails_root/app/controllers
         | 
| 78 | 
            +
            - examples/rails_root/app/controllers/application_controller.rb
         | 
| 149 79 | 
             
            - examples/rails_root/app/controllers/welcome_controller.rb
         | 
| 80 | 
            +
            - examples/rails_root/app/helpers
         | 
| 150 81 | 
             
            - examples/rails_root/app/helpers/application_helper.rb
         | 
| 151 82 | 
             
            - examples/rails_root/app/helpers/welcome_helper.rb
         | 
| 83 | 
            +
            - examples/rails_root/app/models
         | 
| 152 84 | 
             
            - examples/rails_root/app/models/user.rb
         | 
| 153 85 | 
             
            - examples/rails_root/app/models/user_mailer.rb
         | 
| 86 | 
            +
            - examples/rails_root/app/views
         | 
| 87 | 
            +
            - examples/rails_root/app/views/user_mailer
         | 
| 88 | 
            +
            - examples/rails_root/app/views/user_mailer/signup.erb
         | 
| 89 | 
            +
            - examples/rails_root/app/views/welcome
         | 
| 90 | 
            +
            - examples/rails_root/app/views/welcome/confirm.html.erb
         | 
| 91 | 
            +
            - examples/rails_root/app/views/welcome/index.html.erb
         | 
| 92 | 
            +
            - examples/rails_root/app/views/welcome/signup.html.erb
         | 
| 93 | 
            +
            - examples/rails_root/config
         | 
| 154 94 | 
             
            - examples/rails_root/config/boot.rb
         | 
| 95 | 
            +
            - examples/rails_root/config/database.yml
         | 
| 155 96 | 
             
            - examples/rails_root/config/environment.rb
         | 
| 97 | 
            +
            - examples/rails_root/config/environments
         | 
| 156 98 | 
             
            - examples/rails_root/config/environments/development.rb
         | 
| 157 99 | 
             
            - examples/rails_root/config/environments/production.rb
         | 
| 158 100 | 
             
            - examples/rails_root/config/environments/test.rb
         | 
| 101 | 
            +
            - examples/rails_root/config/initializers
         | 
| 159 102 | 
             
            - examples/rails_root/config/initializers/inflections.rb
         | 
| 160 103 | 
             
            - examples/rails_root/config/initializers/mime_types.rb
         | 
| 161 104 | 
             
            - examples/rails_root/config/initializers/new_rails_defaults.rb
         | 
| 162 105 | 
             
            - examples/rails_root/config/routes.rb
         | 
| 106 | 
            +
            - examples/rails_root/db
         | 
| 107 | 
            +
            - examples/rails_root/db/migrate
         | 
| 163 108 | 
             
            - examples/rails_root/db/migrate/20090125013728_create_users.rb
         | 
| 164 109 | 
             
            - examples/rails_root/db/schema.rb
         | 
| 165 | 
            -
            - examples/rails_root/ | 
| 110 | 
            +
            - examples/rails_root/doc
         | 
| 111 | 
            +
            - examples/rails_root/doc/README_FOR_APP
         | 
| 112 | 
            +
            - examples/rails_root/features
         | 
| 113 | 
            +
            - examples/rails_root/features/errors.feature
         | 
| 114 | 
            +
            - examples/rails_root/features/example.feature
         | 
| 115 | 
            +
            - examples/rails_root/features/step_definitions
         | 
| 166 116 | 
             
            - examples/rails_root/features/step_definitions/user_steps.rb
         | 
| 167 117 | 
             
            - examples/rails_root/features/step_definitions/webrat_steps.rb
         | 
| 118 | 
            +
            - examples/rails_root/features/support
         | 
| 168 119 | 
             
            - examples/rails_root/features/support/env.rb
         | 
| 120 | 
            +
            - examples/rails_root/features/support/paths.rb
         | 
| 121 | 
            +
            - examples/rails_root/public
         | 
| 122 | 
            +
            - examples/rails_root/public/404.html
         | 
| 123 | 
            +
            - examples/rails_root/public/422.html
         | 
| 124 | 
            +
            - examples/rails_root/public/500.html
         | 
| 169 125 | 
             
            - examples/rails_root/public/dispatch.rb
         | 
| 126 | 
            +
            - examples/rails_root/public/favicon.ico
         | 
| 127 | 
            +
            - examples/rails_root/public/images
         | 
| 128 | 
            +
            - examples/rails_root/public/images/rails.png
         | 
| 129 | 
            +
            - examples/rails_root/public/javascripts
         | 
| 130 | 
            +
            - examples/rails_root/public/javascripts/application.js
         | 
| 131 | 
            +
            - examples/rails_root/public/javascripts/controls.js
         | 
| 132 | 
            +
            - examples/rails_root/public/javascripts/dragdrop.js
         | 
| 133 | 
            +
            - examples/rails_root/public/javascripts/effects.js
         | 
| 134 | 
            +
            - examples/rails_root/public/javascripts/prototype.js
         | 
| 135 | 
            +
            - examples/rails_root/public/robots.txt
         | 
| 136 | 
            +
            - examples/rails_root/Rakefile
         | 
| 137 | 
            +
            - examples/rails_root/script
         | 
| 138 | 
            +
            - examples/rails_root/script/about
         | 
| 139 | 
            +
            - examples/rails_root/script/autospec
         | 
| 140 | 
            +
            - examples/rails_root/script/console
         | 
| 141 | 
            +
            - examples/rails_root/script/cucumber
         | 
| 142 | 
            +
            - examples/rails_root/script/dbconsole
         | 
| 143 | 
            +
            - examples/rails_root/script/destroy
         | 
| 144 | 
            +
            - examples/rails_root/script/generate
         | 
| 145 | 
            +
            - examples/rails_root/script/performance
         | 
| 146 | 
            +
            - examples/rails_root/script/performance/benchmarker
         | 
| 147 | 
            +
            - examples/rails_root/script/performance/profiler
         | 
| 148 | 
            +
            - examples/rails_root/script/performance/request
         | 
| 149 | 
            +
            - examples/rails_root/script/plugin
         | 
| 150 | 
            +
            - examples/rails_root/script/process
         | 
| 151 | 
            +
            - examples/rails_root/script/process/inspector
         | 
| 152 | 
            +
            - examples/rails_root/script/process/reaper
         | 
| 153 | 
            +
            - examples/rails_root/script/process/spawner
         | 
| 154 | 
            +
            - examples/rails_root/script/runner
         | 
| 155 | 
            +
            - examples/rails_root/script/server
         | 
| 156 | 
            +
            - examples/rails_root/script/spec
         | 
| 157 | 
            +
            - examples/rails_root/script/spec_server
         | 
| 158 | 
            +
            - examples/rails_root/spec
         | 
| 159 | 
            +
            - examples/rails_root/spec/controllers
         | 
| 170 160 | 
             
            - examples/rails_root/spec/controllers/welcome_controller_spec.rb
         | 
| 171 161 | 
             
            - examples/rails_root/spec/model_factory.rb
         | 
| 162 | 
            +
            - examples/rails_root/spec/models
         | 
| 172 163 | 
             
            - examples/rails_root/spec/models/user_mailer_spec.rb
         | 
| 173 164 | 
             
            - examples/rails_root/spec/models/user_spec.rb
         | 
| 165 | 
            +
            - examples/rails_root/spec/rcov.opts
         | 
| 166 | 
            +
            - examples/rails_root/spec/spec.opts
         | 
| 174 167 | 
             
            - examples/rails_root/spec/spec_helper.rb
         | 
| 175 | 
            -
            - examples/rails_root/stories/all.rb
         | 
| 176 | 
            -
            - examples/rails_root/stories/helper.rb
         | 
| 177 | 
            -
            - examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/email_spec_generator.rb
         | 
| 178 | 
            -
            - examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/templates/email_steps.rb
         |