letter_stamp_mail_delivery 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +59 -0
- data/Rakefile +9 -0
- data/letter_stamp_mail_delivery.gemspec +23 -0
- data/lib/letter_stamp_mail_delivery.rb +2 -0
- data/lib/letter_stamp_mail_delivery/action_mailer_support.rb +11 -0
- data/lib/letter_stamp_mail_delivery/delivery_method.rb +70 -0
- data/lib/letter_stamp_mail_delivery/rspec_support.rb +58 -0
- data/lib/letter_stamp_mail_delivery/version.rb +3 -0
- data/spec/letter_stamp_mail_delivery/action_mailer_support_spec.rb +13 -0
- data/spec/letter_stamp_mail_delivery/delivery_method_spec.rb +180 -0
- data/spec/letter_stamp_mail_delivery/rspec_support_spec.rb +75 -0
- data/spec/spec_helper.rb +7 -0
- metadata +132 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Kenta Murata
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# LetterStampMailDelivery
|
|
2
|
+
|
|
3
|
+
[](http://travis-ci.org/mrkn/letter_stamp_mail_delivery)
|
|
4
|
+
|
|
5
|
+
Mail delivery method to save delivered mails with filenames that allows us to easily recognize the location at which mails are delivered.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
gem 'letter_stamp_mail_delivery'
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install letter_stamp_mail_delivery
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### for RSpec
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
require 'letter_stamp_mail_delivery'
|
|
27
|
+
require 'letter_stamp_mail_delivery/rspec_support'
|
|
28
|
+
|
|
29
|
+
RSpec.configure do |config|
|
|
30
|
+
LetterStampMailDelivery::RSpecSupport.install(config)
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### for test-unit
|
|
35
|
+
|
|
36
|
+
Not supported yet.
|
|
37
|
+
|
|
38
|
+
### with ActionMailer
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
require 'letter_stamp_mail_delivery'
|
|
42
|
+
require 'letter_stamp_mail_delivery/action_mailer_support'
|
|
43
|
+
|
|
44
|
+
LetterStampMailDelivery::ActionMailerSupport.install
|
|
45
|
+
|
|
46
|
+
ActionMailer::Base.delivery_method :letter_stamp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Contributing
|
|
50
|
+
|
|
51
|
+
1. Fork it
|
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
53
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
55
|
+
5. Create new Pull Request
|
|
56
|
+
|
|
57
|
+
## Thanks
|
|
58
|
+
|
|
59
|
+
- Ryo Nakamura (@r7kamura) for the name "Letter Stamp".
|
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/letter_stamp_mail_delivery/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Kenta Murata"]
|
|
6
|
+
gem.email = ["mrkn@cookpad.com"]
|
|
7
|
+
gem.description = %q{Mail delivery method to save delivered mails with filenames that allows us to easily recognize the location at which mails are delivered.}
|
|
8
|
+
gem.summary = %q{Mail delivery method for saving mails with filenames of posting locations}
|
|
9
|
+
gem.homepage = "http://github.com/mrkn/letter_stamp_mail_delivery"
|
|
10
|
+
|
|
11
|
+
gem.files = `git ls-files`.split($\)
|
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
14
|
+
gem.name = "letter_stamp_mail_delivery"
|
|
15
|
+
gem.require_paths = ["lib"]
|
|
16
|
+
gem.version = LetterStampMailDelivery::VERSION
|
|
17
|
+
|
|
18
|
+
gem.add_dependency('mail', '>= 2.2.0')
|
|
19
|
+
|
|
20
|
+
gem.add_development_dependency('rake')
|
|
21
|
+
gem.add_development_dependency('rspec', '~> 2.10.0')
|
|
22
|
+
gem.add_development_dependency('actionmailer', '>= 3.0.10')
|
|
23
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'mail/network/delivery_methods/test_mailer'
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
module LetterStampMailDelivery
|
|
6
|
+
class DeliveryMethod < ::Mail::TestMailer
|
|
7
|
+
class << self
|
|
8
|
+
attr_accessor :posting_location
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.start
|
|
12
|
+
@mail_counts = Hash.new(0)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.mail_count
|
|
16
|
+
@mail_counts[posting_location]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class << self
|
|
20
|
+
def increment_mail_count
|
|
21
|
+
@mail_counts[posting_location] += 1
|
|
22
|
+
end
|
|
23
|
+
private :increment_mail_count
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def initialize(settings)
|
|
27
|
+
super
|
|
28
|
+
self.settings = {
|
|
29
|
+
:delivery_location => "#{tmpdir}/letter_stamp_mails",
|
|
30
|
+
}.update(settings)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def deliver!(mail)
|
|
34
|
+
super
|
|
35
|
+
save_raw_mail(mail.encoded)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def tmpdir
|
|
41
|
+
defined?(::Rails) ? "#{::Rails.root}/tmp" : Dir.tmpdir
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def posting_location
|
|
45
|
+
self.class.posting_location
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def delivery_location
|
|
49
|
+
settings[:delivery_location]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def generate_filename
|
|
53
|
+
stem = [posting_location, self.class.mail_count].flatten.join('_')
|
|
54
|
+
"#{delivery_location}/#{stem}.eml"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def save_raw_mail(raw_mail)
|
|
58
|
+
if posting_location && delivery_location
|
|
59
|
+
increment_mail_count
|
|
60
|
+
filename = generate_filename
|
|
61
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
|
62
|
+
open(filename, 'wb') {|io| io.write(raw_mail) }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def increment_mail_count
|
|
67
|
+
self.class.send :increment_mail_count
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'rspec/core/formatters/base_formatter'
|
|
2
|
+
|
|
3
|
+
module LetterStampMailDelivery
|
|
4
|
+
module RSpecSupport
|
|
5
|
+
class ExampleLocationNotifier < ::RSpec::Core::Formatters::BaseFormatter
|
|
6
|
+
def initialize(*args)
|
|
7
|
+
# nothing
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def close
|
|
11
|
+
# nothing
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def start(example_count)
|
|
15
|
+
::LetterStampMailDelivery::DeliveryMethod.start
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def example_group_started(example_group)
|
|
19
|
+
# nothing
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def example_group_finished(example_group)
|
|
23
|
+
# nothing
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def example_started(example)
|
|
27
|
+
::LetterStampMailDelivery::DeliveryMethod.posting_location = posting_location(example)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def example_passed(example)
|
|
31
|
+
example_finished
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def example_pending(example)
|
|
35
|
+
example_finished
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def example_failed(example)
|
|
39
|
+
example_finished
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def posting_location(example)
|
|
45
|
+
spec_file, lineno = example.location.split(':')
|
|
46
|
+
[spec_file, lineno.to_i]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def example_finished
|
|
50
|
+
::LetterStampMailDelivery::DeliveryMethod.posting_location = nil
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.install(rspec_configuration)
|
|
55
|
+
rspec_configuration.add_formatter(ExampleLocationNotifier)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'letter_stamp_mail_delivery/action_mailer_support'
|
|
3
|
+
|
|
4
|
+
module LetterStampMailDelivery
|
|
5
|
+
describe ActionMailerSupport do
|
|
6
|
+
describe '.install' do
|
|
7
|
+
it "should add_delivery_method :letter_stamp" do
|
|
8
|
+
described_class.install
|
|
9
|
+
ActionMailer::Base.delivery_methods.should include(:letter_stamp)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mail'
|
|
3
|
+
require 'tmpdir'
|
|
4
|
+
|
|
5
|
+
module LetterStampMailDelivery
|
|
6
|
+
describe DeliveryMethod do
|
|
7
|
+
shared_context "setup and enter temporary directory" do
|
|
8
|
+
around :each do |example|
|
|
9
|
+
Dir.mktmpdir do |tmpdir|
|
|
10
|
+
Dir.chdir(tmpdir) do
|
|
11
|
+
example.run
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
shared_context "initialize without :delivery_location" do
|
|
18
|
+
before :each do
|
|
19
|
+
Mail.defaults do
|
|
20
|
+
delivery_method DeliveryMethod
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
shared_context "initialize with :delivery_location" do
|
|
26
|
+
before :each do
|
|
27
|
+
Mail.defaults do
|
|
28
|
+
delivery_method DeliveryMethod,
|
|
29
|
+
:delivery_location => "#{Dir.pwd}/tmp/mails"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
before :each do
|
|
35
|
+
# Reset all defaults back to original state
|
|
36
|
+
Mail.defaults do
|
|
37
|
+
delivery_method :smtp, { :address => "localhost",
|
|
38
|
+
:port => 25,
|
|
39
|
+
:domain => 'localhost.localdomain',
|
|
40
|
+
:user_name => nil,
|
|
41
|
+
:password => nil,
|
|
42
|
+
:authentication => nil,
|
|
43
|
+
:enable_starttls_auto => true,
|
|
44
|
+
:openssl_verify_mode => nil }
|
|
45
|
+
DeliveryMethod.deliveries.clear
|
|
46
|
+
DeliveryMethod.start
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context "just initialized" do
|
|
51
|
+
include_context "initialize without :delivery_location"
|
|
52
|
+
|
|
53
|
+
describe ".deliveries" do
|
|
54
|
+
subject { described_class.deliveries }
|
|
55
|
+
|
|
56
|
+
it { should be_empty }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context "initialize without :delivery_location parameter" do
|
|
61
|
+
include_context "setup and enter temporary directory"
|
|
62
|
+
|
|
63
|
+
describe "#settings[:delivery_location]" do
|
|
64
|
+
subject { Mail.delivery_method.settings[:delivery_location] }
|
|
65
|
+
|
|
66
|
+
context "Rails isn't defined" do
|
|
67
|
+
include_context "initialize without :delivery_location"
|
|
68
|
+
|
|
69
|
+
it "should have the correct temporary directory" do
|
|
70
|
+
subject.should eq("#{Dir.tmpdir}/letter_stamp_mails")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context "Rails.root is defined" do
|
|
75
|
+
before :each do
|
|
76
|
+
Object.const_set(:Rails, double("Rails")) unless defined?(::Rails)
|
|
77
|
+
::Rails.stub(:root).and_return(Dir.pwd)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
after :each do
|
|
81
|
+
Object.send(:remove_const, :Rails) if ::Rails.is_a?(::RSpec::Mocks::Mock)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
include_context "initialize without :delivery_location"
|
|
85
|
+
|
|
86
|
+
it "should have \"\#{Rails.root}/tmp/letter_stamp_mails\"" do
|
|
87
|
+
subject.should eq("#{::Rails.root}/tmp/letter_stamp_mails")
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "initialize with :delivery_location parameter" do
|
|
94
|
+
include_context "setup and enter temporary directory"
|
|
95
|
+
include_context "initialize with :delivery_location"
|
|
96
|
+
|
|
97
|
+
describe "#settings[:delivery_location]" do
|
|
98
|
+
subject { Mail.delivery_method.settings[:delivery_location] }
|
|
99
|
+
|
|
100
|
+
it "should have the value specified at the initialization" do
|
|
101
|
+
subject.should eq("#{Dir.pwd}/tmp/mails")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should deliver an email into the LetterStampMailDelivery.deliveries array" do
|
|
107
|
+
Mail.defaults do
|
|
108
|
+
delivery_method DeliveryMethod
|
|
109
|
+
end
|
|
110
|
+
mail = Mail.new do
|
|
111
|
+
to 'mikel@me.com'
|
|
112
|
+
from 'you@you.com'
|
|
113
|
+
subject 'testing'
|
|
114
|
+
body 'hello'
|
|
115
|
+
end
|
|
116
|
+
mail.deliver
|
|
117
|
+
described_class.deliveries.should have(1).item
|
|
118
|
+
described_class.deliveries.first.should eq(mail)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
context "do not set posting_location" do
|
|
122
|
+
include_context "setup and enter temporary directory"
|
|
123
|
+
include_context "initialize with :delivery_location"
|
|
124
|
+
|
|
125
|
+
it "should not save an email as a file" do
|
|
126
|
+
mail = Mail.new do
|
|
127
|
+
to 'mikel@me.com'
|
|
128
|
+
from 'you@you.com'
|
|
129
|
+
subject 'testing'
|
|
130
|
+
body 'hello'
|
|
131
|
+
end
|
|
132
|
+
mail.deliver
|
|
133
|
+
Dir.glob("#{Dir.pwd}/tmp/mails/*").should have(0).item
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
context "posting_location is given" do
|
|
138
|
+
include_context "setup and enter temporary directory"
|
|
139
|
+
include_context "initialize with :delivery_location"
|
|
140
|
+
|
|
141
|
+
before :each do
|
|
142
|
+
DeliveryMethod.posting_location = ['foo_spec.rb', 42]
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
let(:mail) do
|
|
146
|
+
Mail.new do
|
|
147
|
+
to 'mikel@me.com'
|
|
148
|
+
from 'you@you.com'
|
|
149
|
+
subject 'testing'
|
|
150
|
+
body 'hello'
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "should save an email as a file named foo_spec.rb_42_1.eml" do
|
|
155
|
+
mail.deliver
|
|
156
|
+
File.should be_file("#{Dir.pwd}/tmp/mails/foo_spec.rb_42_1.eml")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "should save the second email as a file named foo_spec.rb_42_2.eml" do
|
|
160
|
+
2.times { mail.deliver }
|
|
161
|
+
File.should be_file("#{Dir.pwd}/tmp/mails/foo_spec.rb_42_2.eml")
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "should increment mail_count" do
|
|
165
|
+
expect { mail.deliver }.to change {
|
|
166
|
+
described_class.mail_count
|
|
167
|
+
}.by(1)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
describe ".mail_count" do
|
|
171
|
+
it "should maintain for each posting_location" do
|
|
172
|
+
described_class.posting_location = ['foo_spec.rb', 42]
|
|
173
|
+
mail.deliver
|
|
174
|
+
described_class.posting_location = ['bar_spec.rb', 42]
|
|
175
|
+
described_class.mail_count.should eq(0)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'letter_stamp_mail_delivery/rspec_support'
|
|
3
|
+
|
|
4
|
+
module LetterStampMailDelivery
|
|
5
|
+
describe RSpecSupport do
|
|
6
|
+
describe ".install" do
|
|
7
|
+
let(:rspec_configuration) { ::RSpec::Core::Configuration.new }
|
|
8
|
+
|
|
9
|
+
it "should add_formatter ExampleLocationNotifier" do
|
|
10
|
+
rspec_configuration.should_receive(:add_formatter).with(described_class::ExampleLocationNotifier)
|
|
11
|
+
described_class.install(rspec_configuration)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module LetterStampMailDelivery::RSpecSupport
|
|
18
|
+
describe ExampleLocationNotifier do
|
|
19
|
+
let(:dummy_output) { double("dummy output") }
|
|
20
|
+
|
|
21
|
+
subject { described_class.new(dummy_output) }
|
|
22
|
+
|
|
23
|
+
describe "#start" do
|
|
24
|
+
it "should call LetterStampMailerDelivery::DeliveryMethod.start" do
|
|
25
|
+
::LetterStampMailDelivery::DeliveryMethod.should_receive(:start).once
|
|
26
|
+
subject.start(0)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#example_started" do
|
|
31
|
+
context "with an example located at foo_spec.rb:42" do
|
|
32
|
+
let(:example) { double("example", :location => "foo_spec.rb:42") }
|
|
33
|
+
|
|
34
|
+
it "should set LetterStampMailerDelivery::DeliveryMethod.posting_location ['foo_spec.rb', 42]" do
|
|
35
|
+
subject.example_started(example)
|
|
36
|
+
::LetterStampMailDelivery::DeliveryMethod.posting_location.should eq(["foo_spec.rb", 42])
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "with an example located at bar_spec.rb:17" do
|
|
41
|
+
let(:example) { double("example", :location => "bar_spec.rb:17") }
|
|
42
|
+
|
|
43
|
+
it "should set LetterStampMailerDelivery::DeliveryMethod.posting_location ['bar_spec.rb', 16]" do
|
|
44
|
+
subject.example_started(example)
|
|
45
|
+
::LetterStampMailDelivery::DeliveryMethod.posting_location.should eq(["bar_spec.rb", 17])
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
shared_examples_for "LetterStampMailDelivery::DeliveryMethod.posting_location should be nil" do |method_name|
|
|
51
|
+
context "LetterStampMailDelivery::DeliveryMethod.posting_location is ['foo_spec.rb', 42]" do
|
|
52
|
+
before :each do
|
|
53
|
+
::LetterStampMailDelivery::DeliveryMethod.posting_location = ['foo_spec.rb', 42]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should do LetterStampMailDelivery::DeliveryMethod.posting_location = nil" do
|
|
57
|
+
subject.send(method_name, example)
|
|
58
|
+
::LetterStampMailDelivery::DeliveryMethod.posting_location.should be_nil
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe "#example_passed" do
|
|
64
|
+
it_should_behave_like "LetterStampMailDelivery::DeliveryMethod.posting_location should be nil", :example_passed
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "#example_pending" do
|
|
68
|
+
it_should_behave_like "LetterStampMailDelivery::DeliveryMethod.posting_location should be nil", :example_pending
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "#example_failed" do
|
|
72
|
+
it_should_behave_like "LetterStampMailDelivery::DeliveryMethod.posting_location should be nil", :example_failed
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: letter_stamp_mail_delivery
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Kenta Murata
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-05-31 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: mail
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 2.2.0
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 2.2.0
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rake
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rspec
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 2.10.0
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 2.10.0
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: actionmailer
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: 3.0.10
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: 3.0.10
|
|
78
|
+
description: Mail delivery method to save delivered mails with filenames that allows
|
|
79
|
+
us to easily recognize the location at which mails are delivered.
|
|
80
|
+
email:
|
|
81
|
+
- mrkn@cookpad.com
|
|
82
|
+
executables: []
|
|
83
|
+
extensions: []
|
|
84
|
+
extra_rdoc_files: []
|
|
85
|
+
files:
|
|
86
|
+
- .gitignore
|
|
87
|
+
- .rspec
|
|
88
|
+
- .travis.yml
|
|
89
|
+
- Gemfile
|
|
90
|
+
- LICENSE
|
|
91
|
+
- README.md
|
|
92
|
+
- Rakefile
|
|
93
|
+
- letter_stamp_mail_delivery.gemspec
|
|
94
|
+
- lib/letter_stamp_mail_delivery.rb
|
|
95
|
+
- lib/letter_stamp_mail_delivery/action_mailer_support.rb
|
|
96
|
+
- lib/letter_stamp_mail_delivery/delivery_method.rb
|
|
97
|
+
- lib/letter_stamp_mail_delivery/rspec_support.rb
|
|
98
|
+
- lib/letter_stamp_mail_delivery/version.rb
|
|
99
|
+
- spec/letter_stamp_mail_delivery/action_mailer_support_spec.rb
|
|
100
|
+
- spec/letter_stamp_mail_delivery/delivery_method_spec.rb
|
|
101
|
+
- spec/letter_stamp_mail_delivery/rspec_support_spec.rb
|
|
102
|
+
- spec/spec_helper.rb
|
|
103
|
+
homepage: http://github.com/mrkn/letter_stamp_mail_delivery
|
|
104
|
+
licenses: []
|
|
105
|
+
post_install_message:
|
|
106
|
+
rdoc_options: []
|
|
107
|
+
require_paths:
|
|
108
|
+
- lib
|
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
|
+
none: false
|
|
111
|
+
requirements:
|
|
112
|
+
- - ! '>='
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: '0'
|
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
|
+
none: false
|
|
117
|
+
requirements:
|
|
118
|
+
- - ! '>='
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
requirements: []
|
|
122
|
+
rubyforge_project:
|
|
123
|
+
rubygems_version: 1.8.23
|
|
124
|
+
signing_key:
|
|
125
|
+
specification_version: 3
|
|
126
|
+
summary: Mail delivery method for saving mails with filenames of posting locations
|
|
127
|
+
test_files:
|
|
128
|
+
- spec/letter_stamp_mail_delivery/action_mailer_support_spec.rb
|
|
129
|
+
- spec/letter_stamp_mail_delivery/delivery_method_spec.rb
|
|
130
|
+
- spec/letter_stamp_mail_delivery/rspec_support_spec.rb
|
|
131
|
+
- spec/spec_helper.rb
|
|
132
|
+
has_rdoc:
|