bmabey-email_spec 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/History.txt +4 -0
  2. data/MIT-LICENSE.txt +19 -0
  3. data/README.rdoc +66 -0
  4. data/Rakefile +57 -0
  5. data/generators/email_spec/email_spec_generator.rb +16 -0
  6. data/generators/email_spec/templates/email_steps.rb +71 -0
  7. data/install.rb +0 -0
  8. data/lib/email_spec/cucumber.rb +19 -0
  9. data/lib/email_spec/email_spec_helpers.rb +96 -0
  10. data/lib/email_spec/email_spec_matchers.rb +34 -0
  11. data/lib/email_spec.rb +3 -0
  12. data/spec/email_spec_helpers_spec.rb +28 -0
  13. data/spec/rails_root/Rakefile +10 -0
  14. data/spec/rails_root/app/controllers/application.rb +15 -0
  15. data/spec/rails_root/app/controllers/welcome_controller.rb +9 -0
  16. data/spec/rails_root/app/helpers/application_helper.rb +3 -0
  17. data/spec/rails_root/app/helpers/welcome_helper.rb +2 -0
  18. data/spec/rails_root/app/models/user_mailer.rb +12 -0
  19. data/spec/rails_root/app/views/user_mailer/signup.erb +3 -0
  20. data/spec/rails_root/app/views/welcome/confirm.html.erb +1 -0
  21. data/spec/rails_root/app/views/welcome/index.html.erb +8 -0
  22. data/spec/rails_root/app/views/welcome/signup.html.erb +1 -0
  23. data/spec/rails_root/config/boot.rb +109 -0
  24. data/spec/rails_root/config/database.yml +22 -0
  25. data/spec/rails_root/config/environment.rb +22 -0
  26. data/spec/rails_root/config/environments/development.rb +17 -0
  27. data/spec/rails_root/config/environments/production.rb +24 -0
  28. data/spec/rails_root/config/environments/test.rb +29 -0
  29. data/spec/rails_root/config/initializers/inflections.rb +10 -0
  30. data/spec/rails_root/config/initializers/mime_types.rb +5 -0
  31. data/spec/rails_root/config/initializers/new_rails_defaults.rb +17 -0
  32. data/spec/rails_root/config/routes.rb +43 -0
  33. data/spec/rails_root/db/schema.rb +14 -0
  34. data/spec/rails_root/doc/README_FOR_APP +5 -0
  35. data/spec/rails_root/features/errors.feature +42 -0
  36. data/spec/rails_root/features/example.feature +34 -0
  37. data/spec/rails_root/features/step_definitions/email_steps.rb +71 -0
  38. data/spec/rails_root/features/step_definitions/webrat_steps.rb +100 -0
  39. data/spec/rails_root/features/support/env.rb +14 -0
  40. data/spec/rails_root/lib/tasks/cucumber.rake +7 -0
  41. data/spec/rails_root/lib/tasks/rspec.rake +153 -0
  42. data/spec/rails_root/public/404.html +30 -0
  43. data/spec/rails_root/public/422.html +30 -0
  44. data/spec/rails_root/public/500.html +33 -0
  45. data/spec/rails_root/public/dispatch.rb +10 -0
  46. data/spec/rails_root/public/favicon.ico +0 -0
  47. data/spec/rails_root/public/images/rails.png +0 -0
  48. data/spec/rails_root/public/javascripts/application.js +2 -0
  49. data/spec/rails_root/public/javascripts/controls.js +963 -0
  50. data/spec/rails_root/public/javascripts/dragdrop.js +973 -0
  51. data/spec/rails_root/public/javascripts/effects.js +1128 -0
  52. data/spec/rails_root/public/javascripts/prototype.js +4320 -0
  53. data/spec/rails_root/public/robots.txt +5 -0
  54. data/spec/rails_root/script/about +4 -0
  55. data/spec/rails_root/script/autospec +5 -0
  56. data/spec/rails_root/script/console +3 -0
  57. data/spec/rails_root/script/cucumber +7 -0
  58. data/spec/rails_root/script/dbconsole +3 -0
  59. data/spec/rails_root/script/destroy +3 -0
  60. data/spec/rails_root/script/generate +3 -0
  61. data/spec/rails_root/script/performance/benchmarker +3 -0
  62. data/spec/rails_root/script/performance/profiler +3 -0
  63. data/spec/rails_root/script/performance/request +3 -0
  64. data/spec/rails_root/script/plugin +3 -0
  65. data/spec/rails_root/script/process/inspector +3 -0
  66. data/spec/rails_root/script/process/reaper +3 -0
  67. data/spec/rails_root/script/process/spawner +3 -0
  68. data/spec/rails_root/script/runner +3 -0
  69. data/spec/rails_root/script/server +3 -0
  70. data/spec/rails_root/script/spec +5 -0
  71. data/spec/rails_root/script/spec_server +116 -0
  72. data/spec/rails_root/spec/rcov.opts +2 -0
  73. data/spec/rails_root/spec/spec.opts +4 -0
  74. data/spec/rails_root/spec/spec_helper.rb +47 -0
  75. data/spec/rails_root/vendor/plugins/email_spec/generators/email_spec/email_spec_generator.rb +16 -0
  76. data/spec/rails_root/vendor/plugins/email_spec/generators/email_spec/templates/email_steps.rb +71 -0
  77. metadata +170 -0
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,24 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Enable threaded mode
8
+ # config.threadsafe!
9
+
10
+ # Use a different logger for distributed setups
11
+ # config.logger = SyslogLogger.new
12
+
13
+ # Full error reports are disabled and caching is turned on
14
+ config.action_controller.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Use a different cache store in production
18
+ # config.cache_store = :mem_cache_store
19
+
20
+ # Enable serving of images, stylesheets, and javascripts from an asset server
21
+ # config.action_controller.asset_host = "http://assets.example.com"
22
+
23
+ # Disable delivery errors, bad email addresses will be ignored
24
+ # config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,29 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
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.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Disable request forgery protection in test environment
17
+ config.action_controller.allow_forgery_protection = false
18
+
19
+ # Tell Action Mailer not to deliver emails to the real world.
20
+ # The :test delivery method accumulates sent emails in the
21
+ # ActionMailer::Base.deliveries array.
22
+ config.action_mailer.delivery_method = :test
23
+
24
+
25
+ config.gem 'webrat' , :source => "http://gems.github.com"
26
+ config.gem 'rspec', :lib => 'spec'
27
+ config.gem 'rspec-rails', :lib => 'spec/rails'
28
+ config.gem 'cucumber' , :source => "http://gems.github.com"
29
+
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,17 @@
1
+ # These settings change the behavior of Rails 2 apps and will be defaults
2
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
3
+
4
+ if defined?(ActiveRecord)
5
+ # Include Active Record class name as root for JSON serialized output.
6
+ ActiveRecord::Base.include_root_in_json = true
7
+
8
+ # Store the full class name (including module namespace) in STI type column.
9
+ ActiveRecord::Base.store_full_sti_class = true
10
+ end
11
+
12
+ # Use ISO 8601 format for JSON serialized times and dates.
13
+ ActiveSupport.use_standard_json_time_format = true
14
+
15
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
16
+ # if you're including raw json in an HTML page.
17
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,43 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+
4
+ # Sample of regular route:
5
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6
+ # Keep in mind you can assign values other than :controller and :action
7
+
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
12
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
13
+ # map.resources :products
14
+
15
+ # Sample resource route with options:
16
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17
+
18
+ # Sample resource route with sub-resources:
19
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20
+
21
+ # Sample resource route with more complex sub-resources
22
+ # map.resources :products do |products|
23
+ # products.resources :comments
24
+ # products.resources :sales, :collection => { :recent => :get }
25
+ # end
26
+
27
+ # Sample resource route within a namespace:
28
+ # map.namespace :admin do |admin|
29
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30
+ # admin.resources :products
31
+ # end
32
+
33
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34
+ map.root :controller => "welcome", :action => "index"
35
+ map.confirm_account "/confirm", :controller => "welcome", :action => "confirm"
36
+ # See how all your routes lay out with "rake routes"
37
+
38
+ # Install the default routes as the lowest priority.
39
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
40
+ # consider removing the them or commenting them out if you're using named routes and resources.
41
+ map.connect ':controller/:action/:id'
42
+ map.connect ':controller/:action/:id.:format'
43
+ end
@@ -0,0 +1,14 @@
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.
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
8
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
9
+ #
10
+ # It's strongly recommended to check this file into your version control system.
11
+
12
+ ActiveRecord::Schema.define(:version => 0) do
13
+
14
+ end
@@ -0,0 +1,5 @@
1
+ To build the guides:
2
+
3
+ * Install source-highlighter (http://www.gnu.org/software/src-highlite/source-highlight.html)
4
+ * Install the mizuho gem (http://github.com/FooBarWidget/mizuho/tree/master)
5
+ * Run `rake guides` from the railties directory
@@ -0,0 +1,42 @@
1
+ Feature: Email-spec errors example
2
+
3
+ In order to help alleviate email testing in apps
4
+ As a email-spec contributor I a newcomer
5
+ Should be able to easily determine where I have gone wrong
6
+ These scenarios should fail with helpful messages
7
+
8
+ Scenario: I fail to receive an email
9
+ Given I am at "/"
10
+ And no emails have been sent
11
+ When I fill in "Email" with "quentin@example.com"
12
+ And I press "Sign up"
13
+ And I should receive an email
14
+ When "quentin@example.com" opens the email with subject "no email"
15
+
16
+ Scenario: I fail to receive an email with the expected link
17
+ Given I am at "/"
18
+ And no emails have been sent
19
+ When I fill in "Email" with "quentin@example.com"
20
+ And I press "Sign up"
21
+ And I should receive an email
22
+ When I open the email
23
+ When I follow "link that doesn't exist" in the email
24
+
25
+ Scenario: I attempt to operate on an email that is not opened
26
+ Given I am at "/"
27
+ And no emails have been sent
28
+ When I fill in "Email" with "quentin@example.com"
29
+ And I press "Sign up"
30
+ And I should receive an email
31
+ When I follow "confirm" in the email
32
+
33
+ Scenario: I attempt to check out an unopened email
34
+ Given I am at "/"
35
+ And no emails have been sent
36
+ When I fill in "Email" with "quentin@example.com"
37
+ And I press "Sign up"
38
+ Then I should see "confirm" in the email
39
+ And I should see "Account confirmation" in the subject
40
+
41
+
42
+
@@ -0,0 +1,34 @@
1
+ Feature: Email-spec example
2
+
3
+ In order to help alleviate email testing in apps
4
+ As a email-spec contributor I a newcomer
5
+ Should be able to easily adopt email-spec in their app by following this example
6
+
7
+ Scenario: A new person signs up declaratively
8
+ Given I am at "/"
9
+ And no emails have been sent
10
+ When I fill in "Email" with "quentin@example.com"
11
+ And I press "Sign up"
12
+ Then "quentin@example.com" should receive 1 email
13
+ And "quentin@example.com" should have 1 email
14
+ And "foo@bar.com" should not receive an email
15
+ When "quentin@example.com" opens the email with subject "Account confirmation"
16
+ Then I should see "confirm" in the email
17
+ And I should see "Account confirmation" in the subject
18
+ When I follow "confirm" in the email
19
+ Then I should see "Confirm your new account"
20
+
21
+
22
+ Scenario: I sign up imperatively
23
+ Given I am at "/"
24
+ And no emails have been sent
25
+ When I fill in "Email" with "quentin@example.com"
26
+ And I press "Sign up"
27
+ And I should receive an email
28
+ When I open the email
29
+ Then I should see "confirm" in the email
30
+ When I follow "confirm" in the email
31
+ Then I should see "Confirm your new account"
32
+
33
+
34
+
@@ -0,0 +1,71 @@
1
+ #Commonly used email steps
2
+ #
3
+ # To add your own steps make a custom_email_steps.rb
4
+ # The provided methods are:
5
+ #
6
+ # reset_mailer
7
+ # open_last_email
8
+ # visit_in_email
9
+ # unread_emails_for
10
+ # mailbox_for
11
+ # current_email
12
+ # open_email
13
+ # read_emails_for
14
+ # find_email
15
+
16
+ module EmailHelpers
17
+ def current_email_address
18
+ "quentin@example.com" # Replace with your a way to find your current_email. e.g current_user.email
19
+ end
20
+ end
21
+ World {|world| world.extend EmailHelpers }
22
+
23
+ # Use this step to reset the e-mail queue within a scenario.
24
+ # This is done automatically before each scenario.
25
+ Given /^(?:a clear email queue|no emails have been sent)$/ do
26
+ reset_mailer
27
+ end
28
+
29
+ # Use this step to open the most recently sent e-mail.
30
+ When /^I open the email$/ do
31
+ open_email(current_email_address)
32
+ end
33
+
34
+ When /^I follow "(.*)" in the email$/ do |link|
35
+ visit_in_email(link)
36
+ end
37
+
38
+ Then /^I should receive (.*) emails?$/ do |amount|
39
+ amount = 1 if amount == "an"
40
+ unread_emails_for(current_email_address).size.should == amount
41
+ end
42
+
43
+ Then /^"([^']*?)" should receive (\d+) emails?$/ do |address, n|
44
+ unread_emails_for(address).size.should == n.to_i
45
+ end
46
+
47
+ Then /^"([^']*?)" should have (\d+) emails?$/ do |address, n|
48
+ mailbox_for(address).size.should == n.to_i
49
+ end
50
+
51
+ Then /^"([^']*?)" should not receive an email$/ do |address|
52
+ find_email(address).should be_nil
53
+ end
54
+
55
+ Then /^I should see "(.*)" in the subject$/ do |text|
56
+ current_email.subject.should =~ Regexp.new(text)
57
+ end
58
+
59
+ Then /^I should see "(.*)" in the email$/ do |text|
60
+ current_email.body.should =~ Regexp.new(text)
61
+ end
62
+
63
+ When %r{^"([^']*?)" opens? the email with subject "([^']*?)"$} do |address, subject|
64
+ open_email(address, :with_subject => subject)
65
+ end
66
+
67
+ When %r{^"([^']*?)" opens? the email with text "([^']*?)"$} do |address, text|
68
+ open_email(address, :with_text => text)
69
+ end
70
+
71
+
@@ -0,0 +1,100 @@
1
+ # Commonly used webrat steps
2
+ # http://github.com/brynary/webrat
3
+
4
+ Given /^I am at "(.+)"$/ do |path|
5
+ visit path
6
+ end
7
+
8
+
9
+ When /^I press "(.*)"$/ do |button|
10
+ click_button(button)
11
+ end
12
+
13
+ When /^I follow "(.*)"$/ do |link|
14
+ click_link(link)
15
+ end
16
+
17
+ When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
18
+ fill_in(field, :with => value)
19
+ end
20
+
21
+ When /^I select "(.*)" from "(.*)"$/ do |value, field|
22
+ select(value, :from => field)
23
+ end
24
+
25
+ # Use this step in conjunction with Rail's datetime_select helper. For example:
26
+ # When I select "December 25, 2008 10:00" as the date and time
27
+ When /^I select "(.*)" as the date and time$/ do |time|
28
+ select_datetime(time)
29
+ end
30
+
31
+ # Use this step when using multiple datetime_select helpers on a page or
32
+ # you want to specify which datetime to select. Given the following view:
33
+ # <%= f.label :preferred %><br />
34
+ # <%= f.datetime_select :preferred %>
35
+ # <%= f.label :alternative %><br />
36
+ # <%= f.datetime_select :alternative %>
37
+ # The following steps would fill out the form:
38
+ # When I select "November 23, 2004 11:20" as the "Preferred" data and time
39
+ # And I select "November 25, 2004 10:30" as the "Alternative" data and time
40
+ When /^I select "(.*)" as the "(.*)" date and time$/ do |datetime, datetime_label|
41
+ select_datetime(datetime, :from => datetime_label)
42
+ end
43
+
44
+ # Use this step in conjuction with Rail's time_select helper. For example:
45
+ # When I select "2:20PM" as the time
46
+ # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
47
+ # will convert the 2:20PM to 14:20 and then select it.
48
+ When /^I select "(.*)" as the time$/ do |time|
49
+ select_time(time)
50
+ end
51
+
52
+ # Use this step when using multiple time_select helpers on a page or you want to
53
+ # specify the name of the time on the form. For example:
54
+ # When I select "7:30AM" as the "Gym" time
55
+ When /^I select "(.*)" as the "(.*)" time$/ do |time, time_label|
56
+ select_time(time, :from => time_label)
57
+ end
58
+
59
+ # Use this step in conjuction with Rail's date_select helper. For example:
60
+ # When I select "February 20, 1981" as the date
61
+ When /^I select "(.*)" as the date$/ do |date|
62
+ select_date(date)
63
+ end
64
+
65
+ # Use this step when using multiple date_select helpers on one page or
66
+ # you want to specify the name of the date on the form. For example:
67
+ # When I select "April 26, 1982" as the "Date of Birth" date
68
+ When /^I select "(.*)" as the "(.*)" date$/ do |date, date_label|
69
+ select_date(date, :from => date_label)
70
+ end
71
+
72
+ When /^I check "(.*)"$/ do |field|
73
+ check(field)
74
+ end
75
+
76
+ When /^I uncheck "(.*)"$/ do |field|
77
+ uncheck(field)
78
+ end
79
+
80
+ When /^I choose "(.*)"$/ do |field|
81
+ choose(field)
82
+ end
83
+
84
+ When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
85
+ attach_file(field, path)
86
+ end
87
+
88
+ Then /^I should see "(.*)"$/ do |text|
89
+ response.body.should =~ /#{text}/m
90
+ end
91
+
92
+ Then /^I should not see "(.*)"$/ do |text|
93
+ response.body.should_not =~ /#{text}/m
94
+ end
95
+
96
+ Then /^the "(.*)" checkbox should be checked$/ do |label|
97
+ field_labeled(label).should be_checked
98
+ end
99
+
100
+
@@ -0,0 +1,14 @@
1
+ # Sets up the Rails environment for Cucumber
2
+ ENV["RAILS_ENV"] = "test"
3
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
4
+ require 'cucumber/rails/world'
5
+ Cucumber::Rails.use_transactional_fixtures
6
+
7
+ require 'webrat/rails'
8
+ require 'cucumber/rails/rspec'
9
+ require 'webrat/rspec-rails'
10
+
11
+ require File.expand_path(File.dirname(__FILE__) + '../../../../../lib/email_spec/cucumber.rb')
12
+
13
+
14
+
@@ -0,0 +1,7 @@
1
+ $:.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new(:features) do |t|
5
+ t.cucumber_opts = "--format pretty"
6
+ end
7
+ task :features => 'db:test:prepare'
@@ -0,0 +1,153 @@
1
+ raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec" if File.directory?(File.join(File.dirname(__FILE__), *%w[.. .. vendor plugins rspec pkg]))
2
+ raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec-rails" if File.directory?(File.join(File.dirname(__FILE__), *%w[.. .. vendor plugins rspec-rails pkg]))
3
+
4
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
5
+ # Check to see if the rspec plugin is installed first and require
6
+ # it if it is. If not, use the gem version.
7
+ rspec_base = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec/lib')
8
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
9
+
10
+ begin
11
+ require 'spec/rake/spectask'
12
+ Rake.application.instance_variable_get('@tasks').delete('default')
13
+
14
+ spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
15
+ task :noop do
16
+ end
17
+
18
+ task :default => :spec
19
+ task :stats => "spec:statsetup"
20
+
21
+ desc "Run all specs in spec directory (excluding plugin specs)"
22
+ Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
23
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
24
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
25
+ end
26
+
27
+ namespace :spec do
28
+ desc "Run all specs in spec directory with RCov (excluding plugin specs)"
29
+ Spec::Rake::SpecTask.new(:rcov) do |t|
30
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
31
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
32
+ t.rcov = true
33
+ t.rcov_opts = lambda do
34
+ IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
35
+ end
36
+ end
37
+
38
+ desc "Print Specdoc for all specs (excluding plugin specs)"
39
+ Spec::Rake::SpecTask.new(:doc) do |t|
40
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
41
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
42
+ end
43
+
44
+ desc "Print Specdoc for all plugin examples"
45
+ Spec::Rake::SpecTask.new(:plugin_doc) do |t|
46
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
47
+ t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
48
+ end
49
+
50
+ [:models, :controllers, :views, :helpers, :lib].each do |sub|
51
+ desc "Run the code examples in spec/#{sub}"
52
+ Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
53
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
54
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
55
+ end
56
+ end
57
+
58
+ desc "Run the code examples in vendor/plugins (except RSpec's own)"
59
+ Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
60
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
61
+ t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
62
+ end
63
+
64
+ namespace :plugins do
65
+ desc "Runs the examples for rspec_on_rails"
66
+ Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
67
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
68
+ t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
69
+ end
70
+ end
71
+
72
+ # Setup specs for stats
73
+ task :statsetup do
74
+ require 'code_statistics'
75
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
76
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
77
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
78
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
79
+ ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
80
+ ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
81
+ ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
82
+ ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
83
+ ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
84
+ ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
85
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
86
+ end
87
+
88
+ namespace :db do
89
+ namespace :fixtures do
90
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
91
+ task :load => :environment do
92
+ require 'active_record/fixtures'
93
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
94
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
95
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ namespace :server do
102
+ daemonized_server_pid = File.expand_path("spec_server.pid", RAILS_ROOT + "/tmp")
103
+
104
+ desc "start spec_server."
105
+ task :start do
106
+ if File.exist?(daemonized_server_pid)
107
+ $stderr.puts "spec_server is already running."
108
+ else
109
+ $stderr.puts "Starting up spec server."
110
+ system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
111
+ end
112
+ end
113
+
114
+ desc "stop spec_server."
115
+ task :stop do
116
+ unless File.exist?(daemonized_server_pid)
117
+ $stderr.puts "No server running."
118
+ else
119
+ $stderr.puts "Shutting down spec_server."
120
+ system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
121
+ File.delete(daemonized_server_pid)
122
+ end
123
+ end
124
+
125
+ desc "reload spec_server."
126
+ task :restart do
127
+ unless File.exist?(daemonized_server_pid)
128
+ $stderr.puts "No server running."
129
+ else
130
+ $stderr.puts "Reloading down spec_server."
131
+ system("kill", "-s", "USR2", File.read(daemonized_server_pid).strip)
132
+ end
133
+ end
134
+ end
135
+ end
136
+ rescue MissingSourceFile
137
+ # if rspec-rails is a configured gem, this will output helpful material and exit ...
138
+ require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
139
+
140
+ # ... otherwise, do this:
141
+ raise <<-MSG
142
+
143
+ You have rspec-rails rake tasks installed in
144
+ #{__FILE__},
145
+ but rspec-rails is not configured as a gem in
146
+ config/environment.rb
147
+
148
+ Either remove #{__FILE__}
149
+ or configure the rspec-rails gem in config/environment.rb.
150
+
151
+ MSG
152
+ end
153
+
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
+ <title>The page you were looking for doesn't exist (404)</title>
9
+ <style type="text/css">
10
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
+ div.dialog {
12
+ width: 25em;
13
+ padding: 0 4em;
14
+ margin: 4em auto 0 auto;
15
+ border: 1px solid #ccc;
16
+ border-right-color: #999;
17
+ border-bottom-color: #999;
18
+ }
19
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ <!-- This file lives in public/404.html -->
25
+ <div class="dialog">
26
+ <h1>The page you were looking for doesn't exist.</h1>
27
+ <p>You may have mistyped the address or the page may have moved.</p>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
+ <title>The change you wanted was rejected (422)</title>
9
+ <style type="text/css">
10
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
+ div.dialog {
12
+ width: 25em;
13
+ padding: 0 4em;
14
+ margin: 4em auto 0 auto;
15
+ border: 1px solid #ccc;
16
+ border-right-color: #999;
17
+ border-bottom-color: #999;
18
+ }
19
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ <!-- This file lives in public/422.html -->
25
+ <div class="dialog">
26
+ <h1>The change you wanted was rejected.</h1>
27
+ <p>Maybe you tried to change something you didn't have access to.</p>
28
+ </div>
29
+ </body>
30
+ </html>