bmabey-email_spec 0.1.1 → 0.1.2

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 CHANGED
@@ -1,17 +1,25 @@
1
1
  (In Git)
2
2
 
3
- === New features
3
+ === New features
4
+ === Bufixes
5
+
6
+ == 0.1.2 2009-4-05
7
+
8
+ === New features
4
9
  === Bufixes
10
+ * Actually added the renamed generators to the gem so people could use it! D'oh! (Ben Mabey)
11
+ * You can either use "./script generate email_spec" or "rubigen rails email_spec"
12
+ * Removed Rake tasks from example application to prevent conflicts when used as a plugin. (Ben Mabey)
5
13
 
6
- == 0.1.1 2008-3-26
7
- === New features
14
+ == 0.1.1 2009-3-26
15
+ === New features
8
16
  * Switched dir structure over to support rubigen. (Dr. Nic)
9
17
 
10
18
  === Bufixes
11
19
 
12
- == 0.1.0 2008-3-25
13
- === New features
14
- * Change Rakefile to run all specs and features, as well as prepare the db (Mischa Fierer)
20
+ == 0.1.0 2009-3-25
21
+ === New features
22
+ * Change Rakefile to run all specs and features, as well as prepare the db (Mischa Fierer)
15
23
  * Allow for array to be passed into deliver_to matcher. (Diego Carrion)
16
24
  * Added matcher for checking if a collection of emails includes an email with a particular subject (Luke Melia, Noah Davis)
17
25
  * Introduced hook to convert objects to email addresses (Luke Melia and Lee Bankewitz)
@@ -32,9 +40,9 @@
32
40
  === Bufixes
33
41
  * Revert parse_email_for_link helper method to allow for text links as well as explicit link finding. (Mischa Fierer)
34
42
  * Isolated variances between using email-spec with an ARMailer project. (Luke Melia)
35
-
36
43
 
37
- == 0.0.9 2008-2-15
44
+
45
+ == 0.0.9 2009-2-15
38
46
  === New features
39
47
  * have_body_text, have_header matchers (Luke Melia)
40
48
  * EmailViewer - opens all sent emails in a given scenario when the environment variables are set. (Luke Melia)
@@ -42,7 +50,7 @@
42
50
  === Bugfixes
43
51
  * set_current_email now works with multiple addresses in To field. (Brian McManus, Ben Mabey)
44
52
 
45
- == 0.0.7 2008-1-20
53
+ == 0.0.7 2009-1-20
46
54
  === New features
47
55
  * have_subject matcher (Ben Mabey)
48
56
 
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ begin
14
14
  s.bindir = "bin"
15
15
  s.description = s.summary
16
16
  s.require_path = "lib"
17
- s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["generators/**/*"] + Dir["spec/**/*"] + Dir["examples/**/*"]
17
+ s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["rails_generators/**/*"] + Dir["spec/**/*"] + Dir["examples/**/*"]
18
18
  # rdoc
19
19
  s.has_rdoc = true
20
20
  s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
@@ -1,5 +1,6 @@
1
1
  # This generator adds email steps to the step definitions directory
2
- class EmailSpecGenerator < Rails::Generator::Base
2
+ generator_base = defined?(Rails) ? Rails::Generator::Base : RubiGen::Base
3
+ class EmailSpecGenerator < generator_base
3
4
  def manifest
4
5
  record do |m|
5
6
  m.directory 'features/step_definitions'
@@ -0,0 +1,17 @@
1
+ # This generator adds email steps to the step definitions directory
2
+ generator_base = defined?(Rails) ? Rails::Generator::Base : RubiGen::Base
3
+ class EmailSpecGenerator < generator_base
4
+ def manifest
5
+ record do |m|
6
+ m.directory 'features/step_definitions'
7
+ m.file 'email_steps.rb', 'features/step_definitions/email_steps.rb'
8
+ end
9
+ end
10
+
11
+ protected
12
+
13
+ def banner
14
+ "Usage: #{$0} email_spec"
15
+ end
16
+
17
+ end
@@ -0,0 +1,74 @@
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 (an|\d+) emails?$/ do |amount|
39
+ amount = 1 if amount == "an"
40
+ unread_emails_for(current_email_address).size.should == amount.to_i
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.should have_subject(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
+ When /^I click the first link in the email$/ do
72
+ click_first_link_in_email
73
+ end
74
+
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.1.1
4
+ version: 0.1.2
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-03-26 00:00:00 -07:00
14
+ date: 2009-04-05 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
@@ -38,6 +38,10 @@ files:
38
38
  - lib/email_spec/helpers.rb
39
39
  - lib/email_spec/matchers.rb
40
40
  - lib/email_spec.rb
41
+ - rails_generators/email_spec
42
+ - rails_generators/email_spec/email_spec_generator.rb
43
+ - rails_generators/email_spec/templates
44
+ - rails_generators/email_spec/templates/email_steps.rb
41
45
  - spec/email_spec
42
46
  - spec/email_spec/matchers_spec.rb
43
47
  - spec/spec.opts
@@ -75,6 +79,7 @@ files:
75
79
  - examples/rails_root/config/routes.rb
76
80
  - examples/rails_root/cucumber.yml
77
81
  - examples/rails_root/db
82
+ - examples/rails_root/db/development.sqlite3
78
83
  - examples/rails_root/db/migrate
79
84
  - examples/rails_root/db/migrate/20090125013728_create_users.rb
80
85
  - examples/rails_root/db/schema.rb
@@ -91,8 +96,6 @@ files:
91
96
  - examples/rails_root/features/support
92
97
  - examples/rails_root/features/support/env.rb
93
98
  - examples/rails_root/lib
94
- - examples/rails_root/lib/tasks
95
- - examples/rails_root/lib/tasks/rspec.rake
96
99
  - examples/rails_root/log
97
100
  - examples/rails_root/log/development.log
98
101
  - examples/rails_root/log/test.log
@@ -111,7 +114,6 @@ files:
111
114
  - examples/rails_root/public/javascripts/effects.js
112
115
  - examples/rails_root/public/javascripts/prototype.js
113
116
  - examples/rails_root/public/robots.txt
114
- - examples/rails_root/Rakefile
115
117
  - examples/rails_root/script
116
118
  - examples/rails_root/script/about
117
119
  - examples/rails_root/script/autospec
@@ -1,10 +0,0 @@
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'
@@ -1,158 +0,0 @@
1
- rspec_gem_dir = nil
2
- Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
3
- rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
4
- end
5
- rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
6
-
7
- if rspec_gem_dir && (test ?d, rspec_plugin_dir)
8
- raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
9
- end
10
-
11
- if rspec_gem_dir
12
- $LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
13
- elsif File.exist?(rspec_plugin_dir)
14
- $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
15
- end
16
-
17
- begin
18
- require 'spec/rake/spectask'
19
- Rake.application.instance_variable_get('@tasks').delete('default')
20
-
21
- spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
22
- task :noop do
23
- end
24
-
25
- task :default => :spec
26
- task :stats => "spec:statsetup"
27
-
28
- desc "Run all specs in spec directory (excluding plugin specs)"
29
- Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
30
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
31
- t.spec_files = FileList['spec/**/*/*_spec.rb']
32
- end
33
-
34
- namespace :spec do
35
- desc "Run all specs in spec directory with RCov (excluding plugin specs)"
36
- Spec::Rake::SpecTask.new(:rcov) do |t|
37
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
38
- t.spec_files = FileList['spec/**/*/*_spec.rb']
39
- t.rcov = true
40
- t.rcov_opts = lambda do
41
- IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
42
- end
43
- end
44
-
45
- desc "Print Specdoc for all specs (excluding plugin specs)"
46
- Spec::Rake::SpecTask.new(:doc) do |t|
47
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
48
- t.spec_files = FileList['spec/**/*/*_spec.rb']
49
- end
50
-
51
- desc "Print Specdoc for all plugin examples"
52
- Spec::Rake::SpecTask.new(:plugin_doc) do |t|
53
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
54
- t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
55
- end
56
-
57
- [:models, :controllers, :views, :helpers, :lib].each do |sub|
58
- desc "Run the code examples in spec/#{sub}"
59
- Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
60
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
61
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
62
- end
63
- end
64
-
65
- desc "Run the code examples in vendor/plugins (except RSpec's own)"
66
- Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
67
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
68
- t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
69
- end
70
-
71
- namespace :plugins do
72
- desc "Runs the examples for rspec_on_rails"
73
- Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
74
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
75
- t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
76
- end
77
- end
78
-
79
- # Setup specs for stats
80
- task :statsetup do
81
- require 'code_statistics'
82
- ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
83
- ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
84
- ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
85
- ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
86
- ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
87
- ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
88
- ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
89
- ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
90
- ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
91
- ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
92
- ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
93
- end
94
-
95
- namespace :db do
96
- namespace :fixtures do
97
- desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
98
- task :load => :environment do
99
- ActiveRecord::Base.establish_connection(Rails.env)
100
- base_dir = File.join(Rails.root, 'spec', 'fixtures')
101
- fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
102
-
103
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
104
- Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
105
- end
106
- end
107
- end
108
- end
109
-
110
- namespace :server do
111
- daemonized_server_pid = File.expand_path("spec_server.pid", RAILS_ROOT + "/tmp")
112
-
113
- desc "start spec_server."
114
- task :start do
115
- if File.exist?(daemonized_server_pid)
116
- $stderr.puts "spec_server is already running."
117
- else
118
- $stderr.puts "Starting up spec server."
119
- system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
120
- end
121
- end
122
-
123
- desc "stop spec_server."
124
- task :stop do
125
- unless File.exist?(daemonized_server_pid)
126
- $stderr.puts "No server running."
127
- else
128
- $stderr.puts "Shutting down spec_server."
129
- system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
130
- File.delete(daemonized_server_pid)
131
- end
132
- end
133
-
134
- desc "reload spec_server."
135
- task :restart do
136
- unless File.exist?(daemonized_server_pid)
137
- $stderr.puts "No server running."
138
- else
139
- $stderr.puts "Reloading down spec_server."
140
- system("kill", "-s", "USR2", File.read(daemonized_server_pid).strip)
141
- end
142
- end
143
- end
144
- end
145
- rescue MissingSourceFile
146
- # if rspec-rails is a configured gem, this will output helpful material and exit ...
147
- require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
148
-
149
- # ... otherwise, do this:
150
- raise <<-MSG
151
-
152
- You have rspec rake tasks installed in
153
- #{__FILE__},
154
- but rspec can not be found in vendor/gems, vendor/plugins or on the system.
155
-
156
- MSG
157
- end
158
-