email_spec 0.6.6 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/History.txt +21 -26
  2. data/README.rdoc +5 -3
  3. data/Rakefile +16 -27
  4. data/examples/rails3_root/Gemfile +17 -0
  5. data/examples/rails3_root/Gemfile.lock +138 -0
  6. data/examples/rails3_root/README +5 -0
  7. data/examples/rails3_root/Rakefile +11 -0
  8. data/examples/rails3_root/app/controllers/application_controller.rb +3 -0
  9. data/examples/rails3_root/app/controllers/welcome_controller.rb +16 -0
  10. data/examples/rails3_root/app/helpers/application_helper.rb +2 -0
  11. data/examples/rails3_root/app/mailers/user_mailer.rb +39 -0
  12. data/examples/{rails_root → rails3_root}/app/models/user.rb +0 -0
  13. data/examples/{rails_root/app/views/user_mailer/attachments.erb → rails3_root/app/views/user_mailer/attachments.html.erb} +0 -0
  14. data/examples/{rails_root/app/views/user_mailer/newsletter.erb → rails3_root/app/views/user_mailer/newsletter.html.erb} +0 -0
  15. data/examples/{rails_root/app/views/user_mailer/signup.erb → rails3_root/app/views/user_mailer/signup.html.erb} +1 -0
  16. data/examples/rails3_root/app/views/user_mailer/signup.text.erb +4 -0
  17. data/examples/{rails_root → rails3_root}/app/views/welcome/attachments.html.erb +0 -0
  18. data/examples/{rails_root → rails3_root}/app/views/welcome/confirm.html.erb +0 -0
  19. data/examples/{rails_root → rails3_root}/app/views/welcome/index.html.erb +1 -1
  20. data/examples/{rails_root → rails3_root}/app/views/welcome/newsletter.html.erb +0 -0
  21. data/examples/{rails_root → rails3_root}/app/views/welcome/signup.html.erb +0 -0
  22. data/examples/{rails_root → rails3_root}/attachments/document.pdf +0 -0
  23. data/examples/{rails_root → rails3_root}/attachments/image.png +0 -0
  24. data/examples/rails3_root/config.ru +4 -0
  25. data/examples/rails3_root/config/application.rb +43 -0
  26. data/examples/rails3_root/config/boot.rb +14 -0
  27. data/examples/rails3_root/config/cucumber.yml +8 -0
  28. data/examples/{rails_root → rails3_root}/config/database.yml +0 -0
  29. data/examples/rails3_root/config/environment.rb +6 -0
  30. data/examples/rails3_root/config/environments/development.rb +20 -0
  31. data/examples/rails3_root/config/environments/production.rb +42 -0
  32. data/examples/rails3_root/config/environments/test.rb +30 -0
  33. data/examples/rails3_root/config/initializers/backtrace_silencers.rb +7 -0
  34. data/examples/rails3_root/config/initializers/cookie_verification_secret.rb +7 -0
  35. data/examples/rails3_root/config/initializers/delayed_job.rb +1 -0
  36. data/examples/{rails_root → rails3_root}/config/initializers/inflections.rb +0 -0
  37. data/examples/{rails_root → rails3_root}/config/initializers/mime_types.rb +0 -0
  38. data/examples/rails3_root/config/initializers/notifier_job.rb +1 -0
  39. data/examples/rails3_root/config/initializers/rspec_generator.rb +6 -0
  40. data/examples/rails3_root/config/initializers/session_store.rb +10 -0
  41. data/examples/rails3_root/config/locales/en.yml +5 -0
  42. data/examples/rails3_root/config/routes.rb +7 -0
  43. data/examples/{rails_root → rails3_root}/db/migrate/20090125013728_create_users.rb +0 -0
  44. data/examples/{rails_root → rails3_root}/db/migrate/20090908054656_create_delayed_jobs.rb +0 -0
  45. data/examples/{rails_root → rails3_root}/db/schema.rb +7 -6
  46. data/examples/rails3_root/db/seeds.rb +7 -0
  47. data/examples/rails3_root/doc/README_FOR_APP +2 -0
  48. data/examples/{rails_root → rails3_root}/features/attachments.feature +0 -0
  49. data/examples/{rails_root → rails3_root}/features/delayed_job.feature +0 -0
  50. data/examples/{rails_root → rails3_root}/features/errors.feature +0 -0
  51. data/examples/{sinatra → rails3_root}/features/example.feature +9 -0
  52. data/examples/{rails_root → rails3_root}/features/step_definitions/user_steps.rb +2 -2
  53. data/examples/rails3_root/features/step_definitions/web_steps.rb +219 -0
  54. data/examples/{rails_root → rails3_root}/features/support/env.rb +10 -10
  55. data/examples/rails3_root/features/support/env_ext.rb +2 -0
  56. data/examples/{rails_root → rails3_root}/features/support/paths.rb +2 -2
  57. data/examples/rails3_root/lib/notifier_job.rb +5 -0
  58. data/examples/{rails_root → rails3_root}/lib/tasks/cucumber.rake +6 -0
  59. data/examples/rails3_root/lib/tasks/rspec.rake +69 -0
  60. data/examples/rails3_root/public/404.html +26 -0
  61. data/examples/rails3_root/public/422.html +26 -0
  62. data/examples/rails3_root/public/500.html +26 -0
  63. data/examples/{rails_root → rails3_root}/public/favicon.ico +0 -0
  64. data/examples/{rails_root → rails3_root}/public/images/rails.png +0 -0
  65. data/examples/{rails_root → rails3_root}/public/javascripts/application.js +0 -0
  66. data/examples/{rails_root → rails3_root}/public/javascripts/controls.js +5 -3
  67. data/examples/{rails_root → rails3_root}/public/javascripts/dragdrop.js +7 -6
  68. data/examples/{rails_root → rails3_root}/public/javascripts/effects.js +8 -13
  69. data/examples/{rails_root → rails3_root}/public/javascripts/prototype.js +1573 -1019
  70. data/examples/rails3_root/public/javascripts/rails.js +109 -0
  71. data/examples/{rails_root → rails3_root}/public/robots.txt +0 -0
  72. data/examples/{rails_root → rails3_root}/script/cucumber +0 -0
  73. data/examples/rails3_root/script/rails +9 -0
  74. data/examples/rails3_root/spec/controllers/welcome_controller_spec.rb +20 -0
  75. data/examples/{rails_root → rails3_root}/spec/models/user_mailer_spec.rb +7 -18
  76. data/examples/rails3_root/spec/spec_helper.rb +19 -0
  77. data/examples/sinatra_root/config.ru +4 -0
  78. data/examples/{sinatra → sinatra_root}/features/errors.feature +0 -0
  79. data/examples/{rails_root → sinatra_root}/features/example.feature +0 -0
  80. data/examples/{sinatra → sinatra_root}/features/step_definitions/user_steps.rb +2 -2
  81. data/examples/sinatra_root/features/step_definitions/web_steps.rb +219 -0
  82. data/examples/sinatra_root/features/support/env.rb +21 -0
  83. data/examples/{sinatra → sinatra_root}/features/support/paths.rb +9 -4
  84. data/examples/sinatra_root/lib/example_sinatra_app.rb +35 -0
  85. data/lib/email_spec.rb +2 -2
  86. data/lib/email_spec/deliveries.rb +7 -11
  87. data/lib/email_spec/email_viewer.rb +1 -1
  88. data/lib/email_spec/helpers.rb +7 -7
  89. data/lib/email_spec/mail_ext.rb +11 -0
  90. data/lib/email_spec/matchers.rb +31 -26
  91. data/lib/generators/email_spec/steps/USAGE +5 -0
  92. data/lib/generators/email_spec/steps/steps_generator.rb +14 -0
  93. data/{examples/rails3_root/features/step_definitions → lib/generators/email_spec/steps/templates}/email_steps.rb +0 -0
  94. data/spec/email_spec/helpers_spec.rb +4 -6
  95. data/spec/email_spec/mail_ext_spec.rb +34 -0
  96. data/spec/email_spec/matchers_spec.rb +227 -37
  97. data/spec/spec_helper.rb +14 -2
  98. metadata +174 -207
  99. data/examples/rails_root/Rakefile +0 -13
  100. data/examples/rails_root/app/controllers/application_controller.rb +0 -15
  101. data/examples/rails_root/app/controllers/welcome_controller.rb +0 -16
  102. data/examples/rails_root/app/helpers/application_helper.rb +0 -3
  103. data/examples/rails_root/app/helpers/welcome_helper.rb +0 -2
  104. data/examples/rails_root/app/models/user_mailer.rb +0 -39
  105. data/examples/rails_root/config/boot.rb +0 -110
  106. data/examples/rails_root/config/cucumber.yml +0 -7
  107. data/examples/rails_root/config/environment.rb +0 -28
  108. data/examples/rails_root/config/environments/cucumber.rb +0 -29
  109. data/examples/rails_root/config/environments/development.rb +0 -17
  110. data/examples/rails_root/config/environments/production.rb +0 -28
  111. data/examples/rails_root/config/environments/test.rb +0 -28
  112. data/examples/rails_root/config/initializers/new_rails_defaults.rb +0 -17
  113. data/examples/rails_root/config/routes.rb +0 -45
  114. data/examples/rails_root/doc/README_FOR_APP +0 -5
  115. data/examples/rails_root/features/step_definitions/web_steps.rb +0 -273
  116. data/examples/rails_root/features/support/env_ext.rb +0 -6
  117. data/examples/rails_root/public/404.html +0 -30
  118. data/examples/rails_root/public/422.html +0 -30
  119. data/examples/rails_root/public/500.html +0 -33
  120. data/examples/rails_root/public/dispatch.rb +0 -10
  121. data/examples/rails_root/script/about +0 -4
  122. data/examples/rails_root/script/autospec +0 -5
  123. data/examples/rails_root/script/console +0 -3
  124. data/examples/rails_root/script/dbconsole +0 -3
  125. data/examples/rails_root/script/delayed_job +0 -5
  126. data/examples/rails_root/script/destroy +0 -3
  127. data/examples/rails_root/script/generate +0 -3
  128. data/examples/rails_root/script/performance/benchmarker +0 -3
  129. data/examples/rails_root/script/performance/profiler +0 -3
  130. data/examples/rails_root/script/performance/request +0 -3
  131. data/examples/rails_root/script/plugin +0 -3
  132. data/examples/rails_root/script/process/inspector +0 -3
  133. data/examples/rails_root/script/process/reaper +0 -3
  134. data/examples/rails_root/script/process/spawner +0 -3
  135. data/examples/rails_root/script/runner +0 -3
  136. data/examples/rails_root/script/server +0 -3
  137. data/examples/rails_root/script/spec +0 -5
  138. data/examples/rails_root/script/spec_server +0 -125
  139. data/examples/rails_root/spec/controllers/welcome_controller_spec.rb +0 -15
  140. data/examples/rails_root/spec/model_factory.rb +0 -6
  141. data/examples/rails_root/spec/models/user_spec.rb +0 -5
  142. data/examples/rails_root/spec/rcov.opts +0 -2
  143. data/examples/rails_root/spec/spec.opts +0 -4
  144. data/examples/rails_root/spec/spec_helper.rb +0 -51
  145. data/examples/sinatra/app.rb +0 -33
  146. data/examples/sinatra/features/step_definitions/email_steps.rb +0 -182
  147. data/examples/sinatra/features/step_definitions/web_steps.rb +0 -273
  148. data/examples/sinatra/features/support/env.rb +0 -39
  149. data/examples/sinatra_root/features/step_definitions/email_steps.rb +0 -194
  150. data/lib/email_spec/#helpers.rb# +0 -168
  151. data/spec/spec.opts +0 -4
@@ -1,3 +1,4 @@
1
1
  Hello <%= @name %>!
2
2
 
3
3
  <%= link_to "Click here to confirm your account!", confirm_account_url %>
4
+ This is the HTML part
@@ -0,0 +1,4 @@
1
+ Hello <%= @name %>!
2
+
3
+ <%= link_to "Click here to confirm your account!", confirm_account_url %>
4
+ This is the text part
@@ -1,4 +1,4 @@
1
- <% form_tag '/welcome/signup' do -%>
1
+ <%= form_tag '/welcome/signup' do -%>
2
2
  <label for="Name">Name</label>
3
3
  <%= text_field_tag 'Name' %>
4
4
  <label for="Email">Email</label>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails3Root::Application
@@ -0,0 +1,43 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module Rails3Root
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Add additional load paths for your own custom dirs
16
+ # config.load_paths += %W( #{config.root}/extras )
17
+
18
+ # Only load the plugins named here, in the order given (default is alphabetical).
19
+ # :all can be used as a placeholder for all plugins not explicitly named
20
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
+
22
+ # Activate observers that should always be running
23
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+
33
+ # Configure generators values. Many other options are available, be sure to check the documentation.
34
+ # config.generators do |g|
35
+ # g.orm :active_record
36
+ # g.template_engine :erb
37
+ # g.test_framework :test_unit, :fixture => true
38
+ # end
39
+
40
+ # Configure sensitive parameters which will be filtered from the log file.
41
+ config.filter_parameters << :password
42
+ end
43
+ end
@@ -0,0 +1,14 @@
1
+ # Use locked gems if present.
2
+ begin
3
+ require File.expand_path('../../.bundle/environment', __FILE__)
4
+
5
+ rescue LoadError
6
+ # Otherwise, use RubyGems.
7
+ require 'rubygems'
8
+
9
+ # And set up the gems listed in the Gemfile.
10
+ if File.exist?(File.expand_path('../../Gemfile', __FILE__))
11
+ require 'bundler'
12
+ Bundler.setup
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,6 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Rails3Root::Application.initialize!
6
+ ActionMailer::Base.default_url_options = { :host => 'example.com' }
@@ -0,0 +1,20 @@
1
+ Rails3Root::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+ config.active_support.deprecation = :stderr
20
+ end
@@ -0,0 +1,42 @@
1
+ Rails3Root::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+ end
@@ -0,0 +1,30 @@
1
+ Rails3Root::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
29
+ config.active_support.deprecation = :stderr
30
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Rails.application.config.secret_token = 'c63e0079364c42f86ef0256e8eb5e8f6993b30f1e64e4374f5211ddf4efdcd0895282c6383bd58dc817716b7ecc15f52de122e2df27fa326266d4163e4e5fe7d'
@@ -0,0 +1 @@
1
+ Delayed::Worker.backend = :active_record
@@ -0,0 +1 @@
1
+ require 'notifier_job'
@@ -0,0 +1,6 @@
1
+ Rails3Root::Application.configure do
2
+ config.generators do |g|
3
+ g.integration_tool :rspec
4
+ g.test_framework :rspec
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, {
4
+ :key => '_rails3_root_session',
5
+ }
6
+
7
+ # Use the database for sessions instead of the cookie-based default,
8
+ # which shouldn't be used to store highly confidential information
9
+ # (create the session table with "rake db:sessions:create")
10
+ # Rails.application.config.session_store :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,7 @@
1
+ Rails3Root::Application.routes.draw do
2
+ root :to => "welcome#index"
3
+ match "/confirm" => "welcome#confirm", :as => :confirm_account
4
+ match "/newsletter" => "welcome#newsletter", :as => :request_newsletter
5
+ match "/attachments" => "welcome#attachments", :as => :request_attachments
6
+ match "/welcome/signup" => "welcome#signup"
7
+ end
@@ -1,10 +1,11 @@
1
- # This file is auto-generated from the current state of the database. Instead of editing this file,
2
- # please use the migrations feature of Active Record to incrementally modify your database, and
3
- # then regenerate this schema definition.
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
4
  #
5
- # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6
- # to create the application database on another system, you should be using db:schema:load, not running
7
- # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
8
9
  # you'll amass, the slower it'll run and the greater likelihood for issues).
9
10
  #
10
11
  # It's strongly recommended to check this file into your version control system.
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
@@ -0,0 +1,2 @@
1
+ Use this README file to introduce your application and point to useful places in the API for learning more.
2
+ Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
@@ -60,3 +60,12 @@ Feature: EmailSpec Example -- Prevent Bots from creating accounts
60
60
 
61
61
  Scenario: Declarative First Person signup
62
62
  Then they should receive an email with a link to a confirmation page
63
+
64
+ Scenario: Checking for text in different parts
65
+ Then I should receive an email
66
+ And I should have 1 email
67
+
68
+ # Opening email #1
69
+ When I open the email
70
+ Then I should see "This is the HTML part" in the email html part body
71
+ And I should see "This is the text part" in the email text part body
@@ -5,7 +5,7 @@ end
5
5
  When /^I submit my registration information$/ do
6
6
  fill_in "Name", :with => 'Joe Someone'
7
7
  fill_in "Email", :with => 'example@example.com'
8
- click_button
8
+ click_button "Sign up"
9
9
  end
10
10
 
11
11
  Then /^(?:I|they) should receive an email with a link to a confirmation page$/ do
@@ -17,7 +17,7 @@ Then /^(?:I|they) should receive an email with a link to a confirmation page$/ d
17
17
  current_email.should have_body_text('Joe Someone')
18
18
 
19
19
  click_email_link_matching /confirm/
20
- response_body.should contain("Confirm your new account")
20
+ page.should have_content("Confirm your new account")
21
21
  end
22
22
 
23
23
  # Basically aliases "I should see [text]", but for third person
@@ -0,0 +1,219 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require 'uri'
9
+ require 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end