bmabey-email_spec 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.rdoc +66 -0
- data/Rakefile +57 -0
- data/generators/email_spec/email_spec_generator.rb +16 -0
- data/generators/email_spec/templates/email_steps.rb +71 -0
- data/install.rb +0 -0
- data/lib/email_spec/cucumber.rb +19 -0
- data/lib/email_spec/email_spec_helpers.rb +96 -0
- data/lib/email_spec/email_spec_matchers.rb +34 -0
- data/lib/email_spec.rb +3 -0
- data/spec/email_spec_helpers_spec.rb +28 -0
- data/spec/rails_root/Rakefile +10 -0
- data/spec/rails_root/app/controllers/application.rb +15 -0
- data/spec/rails_root/app/controllers/welcome_controller.rb +9 -0
- data/spec/rails_root/app/helpers/application_helper.rb +3 -0
- data/spec/rails_root/app/helpers/welcome_helper.rb +2 -0
- data/spec/rails_root/app/models/user_mailer.rb +12 -0
- data/spec/rails_root/app/views/user_mailer/signup.erb +3 -0
- data/spec/rails_root/app/views/welcome/confirm.html.erb +1 -0
- data/spec/rails_root/app/views/welcome/index.html.erb +8 -0
- data/spec/rails_root/app/views/welcome/signup.html.erb +1 -0
- data/spec/rails_root/config/boot.rb +109 -0
- data/spec/rails_root/config/database.yml +22 -0
- data/spec/rails_root/config/environment.rb +22 -0
- data/spec/rails_root/config/environments/development.rb +17 -0
- data/spec/rails_root/config/environments/production.rb +24 -0
- data/spec/rails_root/config/environments/test.rb +29 -0
- data/spec/rails_root/config/initializers/inflections.rb +10 -0
- data/spec/rails_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails_root/config/initializers/new_rails_defaults.rb +17 -0
- data/spec/rails_root/config/routes.rb +43 -0
- data/spec/rails_root/db/schema.rb +14 -0
- data/spec/rails_root/doc/README_FOR_APP +5 -0
- data/spec/rails_root/features/errors.feature +42 -0
- data/spec/rails_root/features/example.feature +34 -0
- data/spec/rails_root/features/step_definitions/email_steps.rb +71 -0
- data/spec/rails_root/features/step_definitions/webrat_steps.rb +100 -0
- data/spec/rails_root/features/support/env.rb +14 -0
- data/spec/rails_root/lib/tasks/cucumber.rake +7 -0
- data/spec/rails_root/lib/tasks/rspec.rake +153 -0
- data/spec/rails_root/public/404.html +30 -0
- data/spec/rails_root/public/422.html +30 -0
- data/spec/rails_root/public/500.html +33 -0
- data/spec/rails_root/public/dispatch.rb +10 -0
- data/spec/rails_root/public/favicon.ico +0 -0
- data/spec/rails_root/public/images/rails.png +0 -0
- data/spec/rails_root/public/javascripts/application.js +2 -0
- data/spec/rails_root/public/javascripts/controls.js +963 -0
- data/spec/rails_root/public/javascripts/dragdrop.js +973 -0
- data/spec/rails_root/public/javascripts/effects.js +1128 -0
- data/spec/rails_root/public/javascripts/prototype.js +4320 -0
- data/spec/rails_root/public/robots.txt +5 -0
- data/spec/rails_root/script/about +4 -0
- data/spec/rails_root/script/autospec +5 -0
- data/spec/rails_root/script/console +3 -0
- data/spec/rails_root/script/cucumber +7 -0
- data/spec/rails_root/script/dbconsole +3 -0
- data/spec/rails_root/script/destroy +3 -0
- data/spec/rails_root/script/generate +3 -0
- data/spec/rails_root/script/performance/benchmarker +3 -0
- data/spec/rails_root/script/performance/profiler +3 -0
- data/spec/rails_root/script/performance/request +3 -0
- data/spec/rails_root/script/plugin +3 -0
- data/spec/rails_root/script/process/inspector +3 -0
- data/spec/rails_root/script/process/reaper +3 -0
- data/spec/rails_root/script/process/spawner +3 -0
- data/spec/rails_root/script/runner +3 -0
- data/spec/rails_root/script/server +3 -0
- data/spec/rails_root/script/spec +5 -0
- data/spec/rails_root/script/spec_server +116 -0
- data/spec/rails_root/spec/rcov.opts +2 -0
- data/spec/rails_root/spec/spec.opts +4 -0
- data/spec/rails_root/spec/spec_helper.rb +47 -0
- data/spec/rails_root/vendor/plugins/email_spec/generators/email_spec/email_spec_generator.rb +16 -0
- data/spec/rails_root/vendor/plugins/email_spec/generators/email_spec/templates/email_steps.rb +71 -0
- metadata +170 -0
data/History.txt
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
= Email Spec
|
2
|
+
|
3
|
+
A collection of RSpec matchers and Cucumber steps to make testing emails go smoothly.
|
4
|
+
|
5
|
+
|
6
|
+
== Setup
|
7
|
+
|
8
|
+
script/plugin install git://github.com/bmabey/email-spec.git
|
9
|
+
|
10
|
+
=== Gem Setup (may or may not work atm)
|
11
|
+
|
12
|
+
gem install bmabey-email_spec
|
13
|
+
|
14
|
+
# config/environments/test.rb
|
15
|
+
config.gem 'bmabey-email_spec', :lib => 'email_spec'
|
16
|
+
|
17
|
+
=== Cucumber
|
18
|
+
|
19
|
+
To use the steps in features put the following in your env.rb:
|
20
|
+
|
21
|
+
# Make sure this require is after you require cucumber/rails/world.
|
22
|
+
require 'email_spec/cucumber'
|
23
|
+
|
24
|
+
This will load all the helpers that the steps rely on.
|
25
|
+
It will also add a Before hook for Cucumber so that emails are cleared at the start of each scenario.
|
26
|
+
|
27
|
+
Then:
|
28
|
+
|
29
|
+
script/generate email_spec
|
30
|
+
|
31
|
+
This will give you a bunch of steps to get started with in step_definitions/email_steps.rb
|
32
|
+
|
33
|
+
=== RSpec
|
34
|
+
|
35
|
+
The matchers and helpers should be available for your specs by default, but you need to include them into the example groups you want to use them in. To include them in all of your specs you can do this in your spec_helper.rb:
|
36
|
+
|
37
|
+
Spec::Runner.configure do |config|
|
38
|
+
config.include(EmailSpec::Helpers)
|
39
|
+
config.include(EmailSpec::Matchers)
|
40
|
+
end
|
41
|
+
|
42
|
+
== Usage
|
43
|
+
|
44
|
+
=== Cucumber
|
45
|
+
|
46
|
+
Scenario: A new person signs up
|
47
|
+
Given I am at "/"
|
48
|
+
When I fill in "Email" with "quentin@example.com"
|
49
|
+
And I press "Sign up"
|
50
|
+
And I should receive an email
|
51
|
+
When I open the email
|
52
|
+
Then I should see "confirm" in the email
|
53
|
+
When I follow "confirm" in the email
|
54
|
+
Then I should see "Confirm your new account"
|
55
|
+
|
56
|
+
For more examples, check out spec/rails_root in the source for a small example app that implements these steps.
|
57
|
+
|
58
|
+
== TODO:
|
59
|
+
|
60
|
+
- refactor!
|
61
|
+
- provide custom matchers to give better messages
|
62
|
+
|
63
|
+
== Authors
|
64
|
+
|
65
|
+
Ben Mabey, Aaron Gibralter, Mischa Fierer
|
66
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
['rubygems',"rake/gempackagetask",'rake/rdoctask',"rake/clean",'spec', 'spec/rake/spectask', File.expand_path('./lib/email_spec.rb')].each {|file| require file}
|
2
|
+
|
3
|
+
# package + maintenance stuff
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = "email_spec"
|
6
|
+
s.version = EmailSpec::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Ben Mabrey', 'Aaron Gibralter', 'Mischa Fierer']
|
9
|
+
s.email = "f.mischa@gmail.com"
|
10
|
+
s.homepage = "http://github.com/bmabey/email-spec/"
|
11
|
+
s.summary = "Easily test email in rspec and cucumber"
|
12
|
+
s.bindir = "bin"
|
13
|
+
s.description = s.summary
|
14
|
+
s.require_path = "lib"
|
15
|
+
s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["generators/**/*"] + Dir["spec/**/*"]
|
16
|
+
# rdoc
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Show information about the gem.'
|
22
|
+
task :debug_gem do
|
23
|
+
puts spec.to_ruby
|
24
|
+
end
|
25
|
+
|
26
|
+
task :gemspec do
|
27
|
+
system "rake debug_gem | grep -v \"(in \" > email-spec.gemspec"
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::GemPackageTask.new(spec) do |package|
|
31
|
+
package.gem_spec = spec
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage", '**/.*.sw?', '*.gem', '.config', '**/.DS_Store', '**/*.class', '**/*.jar', '**/.*.swp' ]
|
36
|
+
|
37
|
+
desc 'Install the package as a gem.'
|
38
|
+
task :install_gem => [:clean, :package] do
|
39
|
+
gem = Dir['pkg/*.gem'].first
|
40
|
+
sh "sudo gem install --local #{gem}"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Testing
|
44
|
+
|
45
|
+
desc "Run the generator on the tests"
|
46
|
+
task :generate do
|
47
|
+
system "mkdir -p spec/rails_root/vendor/plugins/email_spec"
|
48
|
+
system "cp -R generators spec/rails_root/vendor/plugins/email_spec"
|
49
|
+
system "cd spec/rails_root; ./script/generate email_spec"
|
50
|
+
end
|
51
|
+
|
52
|
+
task :features => [:generate] do
|
53
|
+
system("cd spec/rails_root; rake features; cd ../..")
|
54
|
+
end
|
55
|
+
|
56
|
+
task :default => :features
|
57
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This generator adds email steps to the step definitions directory
|
2
|
+
class EmailSpecGenerator < Rails::Generator::Base
|
3
|
+
def manifest
|
4
|
+
record do |m|
|
5
|
+
m.directory 'features/step_definitions'
|
6
|
+
m.file 'email_steps.rb', 'features/step_definitions/email_steps.rb'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def banner
|
13
|
+
"Usage: #{$0} email_spec"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -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
|
+
|
data/install.rb
ADDED
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# require this in your env.rb file after you require cucumber/rails/world
|
2
|
+
|
3
|
+
%w[helpers matchers].each do |file|
|
4
|
+
require File.join(File.dirname(__FILE__), "email_spec_#{file}.rb")
|
5
|
+
end
|
6
|
+
|
7
|
+
# Global Setup
|
8
|
+
ActionMailer::Base.delivery_method = :test
|
9
|
+
ActionMailer::Base.perform_deliveries = true
|
10
|
+
|
11
|
+
Before do
|
12
|
+
# Scenario setup
|
13
|
+
ActionMailer::Base.deliveries.clear
|
14
|
+
end
|
15
|
+
|
16
|
+
World do |world|
|
17
|
+
world.extend EmailSpec::Helpers
|
18
|
+
world.extend EmailSpec::Matchers
|
19
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module EmailSpec
|
4
|
+
|
5
|
+
module Helpers
|
6
|
+
|
7
|
+
def self.extended(base)
|
8
|
+
base.instance_eval do
|
9
|
+
@email_spec_hash = {}
|
10
|
+
@email_spec_hash[:read_emails] = {}
|
11
|
+
@email_spec_hash[:unread_emails] = {}
|
12
|
+
@email_spec_hash[:current_emails] = {}
|
13
|
+
@email_spec_hash[:current_email] = nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset_mailer
|
18
|
+
ActionMailer::Base.deliveries.clear
|
19
|
+
end
|
20
|
+
|
21
|
+
def visit_in_email(link_text)
|
22
|
+
visit(parse_email_for_link(current_email, link_text))
|
23
|
+
end
|
24
|
+
|
25
|
+
def open_email(address, opts={})
|
26
|
+
email = find_email!(address, opts)
|
27
|
+
email.should_not be_nil
|
28
|
+
set_current_email(email)
|
29
|
+
end
|
30
|
+
|
31
|
+
def open_last_email
|
32
|
+
email = ActionMailer::Base.deliveries.last
|
33
|
+
email.should_not be_nil
|
34
|
+
set_current_email(email)
|
35
|
+
end
|
36
|
+
|
37
|
+
def current_email(address=nil)
|
38
|
+
email = address ? @email_spec_hash[:current_emails][address] : @email_spec_hash[:current_email]
|
39
|
+
raise Spec::Expectations::ExpectationNotMetError, "Expected an open email but none was found. Did you forget to call open_email?" unless email
|
40
|
+
email
|
41
|
+
end
|
42
|
+
|
43
|
+
def unread_emails_for(address)
|
44
|
+
mailbox_for(address) - read_emails_for(address)
|
45
|
+
end
|
46
|
+
|
47
|
+
def read_emails_for(address)
|
48
|
+
@email_spec_hash[:read_emails][address] ||= []
|
49
|
+
end
|
50
|
+
|
51
|
+
def mailbox_for(address)
|
52
|
+
ActionMailer::Base.deliveries.select { |m| m.to.include?(address) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_email(address, opts={})
|
56
|
+
if opts[:with_subject]
|
57
|
+
email = mailbox_for(address).find { |m| m.subject =~ Regexp.new(opts[:with_subject]) }
|
58
|
+
elsif opts[:with_text]
|
59
|
+
email = mailbox_for(address).find { |m| m.body =~ Regexp.new(opts[:with_text]) }
|
60
|
+
else
|
61
|
+
email = mailbox_for(address).first
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def find_email!(address, opts={})
|
68
|
+
email = find_email(address, opts)
|
69
|
+
if email.nil?
|
70
|
+
error = "#{opts.keys.first.to_s.humanize unless opts.empty?} #{('"' + opts.values.first.to_s.humanize + '"') unless opts.empty?}"
|
71
|
+
raise Spec::Expectations::ExpectationNotMetError, "Could not find email #{error}. \n Found the following emails:\n\n #{ActionMailer::Base.deliveries.to_s}"
|
72
|
+
end
|
73
|
+
email
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_current_email(email)
|
77
|
+
return unless email
|
78
|
+
read_emails_for(email.to) << email
|
79
|
+
@email_spec_hash[:current_emails][email.to] = email
|
80
|
+
@email_spec_hash[:current_email] = email
|
81
|
+
end
|
82
|
+
|
83
|
+
def parse_email_for_link(email, link_text)
|
84
|
+
email.body.should include_text(link_text)
|
85
|
+
if link_text =~ %r{^/.*$}
|
86
|
+
# if it's an explicit link
|
87
|
+
link_text
|
88
|
+
elsif email.body =~ %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_text}[^<]*?</a>}
|
89
|
+
# if it's an anchor tag
|
90
|
+
URI.split($~[1])[5..-1].compact!.join("?").gsub("&", "&")
|
91
|
+
# sub correct ampersand after rails switches it (http://dev.rubyonrails.org/ticket/4002)
|
92
|
+
# TODO: outsource this kind of parsing to webrat or someone else
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module EmailSpec
|
2
|
+
|
3
|
+
module Matchers
|
4
|
+
|
5
|
+
class DeliverTo
|
6
|
+
|
7
|
+
def initialize(expected_email_addresses)
|
8
|
+
@expected_email_addresses = expected_email_addresses.sort
|
9
|
+
end
|
10
|
+
|
11
|
+
def matches?(email)
|
12
|
+
@email = email
|
13
|
+
@actual_recipients = (email.to || []).sort
|
14
|
+
@actual_recipients.should == @expected_email_addresses
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure_message
|
19
|
+
"expected #{@email.inspect} to deliver to #{@expected_email_addresses.inspect}, but it delievered to #{@actual_recipients.inspect}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def negative_failure_message
|
23
|
+
"expected #{@email.inspect} not to deliver to #{@expected_email_addresses.inspect}, but it did"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def deliver_to(*expected_email_addresses_or_objects_that_respond_to_email)
|
28
|
+
emails = expected_email_addresses_or_objects_that_respond_to_email.map do |email_or_object|
|
29
|
+
email_or_object.kind_of?(String) ? email_or_object : email_or_object.email
|
30
|
+
end
|
31
|
+
DeliverTo.new(emails)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/email_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
#
|
3
|
+
# module ActionMailer
|
4
|
+
# class Base
|
5
|
+
# end
|
6
|
+
# end
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# module EmailSpec
|
10
|
+
# describe Helpers do
|
11
|
+
# before(:all) do
|
12
|
+
# @helper = Object.new
|
13
|
+
# @helper.extend EmailSpec::Helpers
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# describe "#reset_mailer" do
|
17
|
+
# it "should empty the all email deliveries" do
|
18
|
+
# #given
|
19
|
+
# ActionMailer::Base.stub!(:deliveries).and_return([mock("some email", mock("another email"))])
|
20
|
+
# #when
|
21
|
+
# @helper.reset_mailer
|
22
|
+
# #then
|
23
|
+
# ActionMailer::Base.deliveries.should be_empty
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
#
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
require 'tasks/rails'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
|
7
|
+
# See ActionController::RequestForgeryProtection for details
|
8
|
+
# Uncomment the :secret if you're not using the cookie session store
|
9
|
+
protect_from_forgery # :secret => 'a74714b35b202f269f7a297709d555ce'
|
10
|
+
|
11
|
+
# See ActionController::Base for details
|
12
|
+
# Uncomment this to filter the contents of submitted sensitive data parameters
|
13
|
+
# from your application log (in this case, all fields with names like "password").
|
14
|
+
# filter_parameter_logging :password
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Confirm your new account!
|
@@ -0,0 +1 @@
|
|
1
|
+
Thanks! Go check your email!
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class GemBoot < Boot
|
51
|
+
def load_initializer
|
52
|
+
self.class.load_rubygems
|
53
|
+
load_rails_gem
|
54
|
+
require 'initializer'
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_rails_gem
|
58
|
+
if version = self.class.gem_version
|
59
|
+
gem 'rails', version
|
60
|
+
else
|
61
|
+
gem 'rails'
|
62
|
+
end
|
63
|
+
rescue Gem::LoadError => load_error
|
64
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
def rubygems_version
|
70
|
+
Gem::RubyGemsVersion rescue nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def gem_version
|
74
|
+
if defined? RAILS_GEM_VERSION
|
75
|
+
RAILS_GEM_VERSION
|
76
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
77
|
+
ENV['RAILS_GEM_VERSION']
|
78
|
+
else
|
79
|
+
parse_gem_version(read_environment_rb)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_rubygems
|
84
|
+
require 'rubygems'
|
85
|
+
min_version = '1.3.1'
|
86
|
+
unless rubygems_version >= min_version
|
87
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
88
|
+
exit 1
|
89
|
+
end
|
90
|
+
|
91
|
+
rescue LoadError
|
92
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse_gem_version(text)
|
97
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
def read_environment_rb
|
102
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# All that for this:
|
109
|
+
Rails.boot!
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file
|
2
|
+
|
3
|
+
# Uncomment below to force Rails into production mode when
|
4
|
+
# you don't control web/app server and can't set it the proper way
|
5
|
+
# ENV['RAILS_ENV'] ||= 'production'
|
6
|
+
|
7
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
8
|
+
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
|
9
|
+
|
10
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
11
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
12
|
+
|
13
|
+
Rails::Initializer.run do |config|
|
14
|
+
|
15
|
+
config.time_zone = 'UTC'
|
16
|
+
|
17
|
+
config.action_controller.session = {
|
18
|
+
:session_key => '_es_session',
|
19
|
+
:secret => 'b9327c7967925fb36f8901e43f47e0a3e8fc7856ae1b4533ddeda776381548f9ac051721446fdbc4ccc88c7353124708e73d8b0950a30487571d8f8eb5b24732'
|
20
|
+
}
|
21
|
+
|
22
|
+
end
|