capybara-email 0.1.2 → 1.0.0
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/README.md +35 -0
- data/lib/capybara/email/driver.rb +31 -1
- data/lib/capybara/email/version.rb +1 -1
- data/lib/capybara/node/email.rb +4 -4
- metadata +60 -15
- data/LICENSE +0 -22
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# CapybaraEmail #
|
2
2
|
|
3
3
|
[](http://travis-ci.org/dockyard/capybara-email)
|
4
|
+
[](https://gemnasium.com/dockyard/capybara-email)
|
5
|
+
[](https://codeclimate.com/github/dockyard/capybara-email)
|
4
6
|
|
5
7
|
Easily test [ActionMailer](https://github.com/rails/rails/tree/master/actionmailer) and [Mail](https://github.com/mikel/mail) messages in your Capybara integration tests
|
6
8
|
|
@@ -55,6 +57,37 @@ feature 'Emailer' do
|
|
55
57
|
end
|
56
58
|
```
|
57
59
|
|
60
|
+
### Cucumber ###
|
61
|
+
Require `capybara/email` in your `features/support/env.rb`
|
62
|
+
|
63
|
+
require 'capybara/email'
|
64
|
+
|
65
|
+
Once you have required `capybara-email`, gaining access to usable methods
|
66
|
+
is easy as adding this module to your Cucumber `World`:
|
67
|
+
|
68
|
+
World(Capybara::Email::DSL)
|
69
|
+
|
70
|
+
I recommend adding this to a support file such as `features/support/capybara_email.rb`
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
require 'capybara/email'
|
74
|
+
World(Capybara::Email::DSL)
|
75
|
+
```
|
76
|
+
|
77
|
+
Example:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
Scenario: Email is sent to winning user
|
81
|
+
Given "me@example.com" is playing a game
|
82
|
+
When that user picks a winning piece
|
83
|
+
Then "me@example.com" receives an email with "You've Won!" as the subject
|
84
|
+
|
85
|
+
Then /^"([^"]*)" receives an email with "([^"]*)" as the subject$/ do |email_address, subject|
|
86
|
+
open_email(email_address)
|
87
|
+
current_email.subject.should eq subject
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
58
91
|
### Test::Unit ###
|
59
92
|
|
60
93
|
Include `Capybara::Email::DSL` in your test class
|
@@ -99,6 +132,8 @@ end
|
|
99
132
|
|
100
133
|
[Brian Cardarella](http://twitter.com/bcardarella)
|
101
134
|
|
135
|
+
[We are very thankful for the many contributors](https://github.com/dockyard/client_side_validations-simple_form/graphs/contributors)
|
136
|
+
|
102
137
|
## Versioning ##
|
103
138
|
|
104
139
|
This gem follows [Semantic Versioning](http://semver.org)
|
@@ -11,36 +11,63 @@ class Capybara::Email::Driver < Capybara::Driver::Base
|
|
11
11
|
when :rack_test
|
12
12
|
url.to_s
|
13
13
|
else
|
14
|
-
Capybara.current_session.driver.send(:url, url.
|
14
|
+
Capybara.current_session.driver.send(:url, url.request_uri)
|
15
15
|
end
|
16
16
|
|
17
17
|
Capybara.current_session.driver.visit url
|
18
18
|
end
|
19
19
|
|
20
|
+
|
20
21
|
def body
|
21
22
|
dom.to_xml
|
22
23
|
end
|
23
24
|
|
25
|
+
# Access to email subject
|
26
|
+
#
|
27
|
+
# delegates back to instance of Mail::Message
|
28
|
+
#
|
29
|
+
# @return String
|
24
30
|
def subject
|
25
31
|
email.subject
|
26
32
|
end
|
27
33
|
|
34
|
+
# Access to email recipient(s)
|
35
|
+
#
|
36
|
+
# delegates back to instance of Mail::Message
|
37
|
+
#
|
38
|
+
# @return [Array<String>]
|
28
39
|
def to
|
29
40
|
email.to
|
30
41
|
end
|
31
42
|
|
43
|
+
# Access to email sender(s)
|
44
|
+
#
|
45
|
+
# delegates back to instance of Mail::Message
|
46
|
+
#
|
47
|
+
# @return [Array<String>]
|
32
48
|
def from
|
33
49
|
email.from
|
34
50
|
end
|
35
51
|
|
52
|
+
# Nokogiri object for traversing content
|
53
|
+
#
|
54
|
+
# @return Nokogiri::HTML::Document
|
36
55
|
def dom
|
37
56
|
@dom ||= Nokogiri::HTML(source)
|
38
57
|
end
|
39
58
|
|
59
|
+
# Find elements based on given xpath
|
60
|
+
#
|
61
|
+
# @param [xpath string]
|
62
|
+
#
|
63
|
+
# @return [Array<Capybara::Driver::Node>]
|
40
64
|
def find(selector)
|
41
65
|
dom.xpath(selector).map { |node| Capybara::Email::Node.new(self, node) }
|
42
66
|
end
|
43
67
|
|
68
|
+
# String version of email HTML source
|
69
|
+
#
|
70
|
+
# @return String
|
44
71
|
def source
|
45
72
|
if email.mime_type == 'text/plain'
|
46
73
|
convert_to_html(raw)
|
@@ -49,6 +76,9 @@ class Capybara::Email::Driver < Capybara::Driver::Base
|
|
49
76
|
end
|
50
77
|
end
|
51
78
|
|
79
|
+
# Plain text email contents
|
80
|
+
#
|
81
|
+
# @return String
|
52
82
|
def raw
|
53
83
|
email.body.encoded
|
54
84
|
end
|
data/lib/capybara/node/email.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
class Capybara::Node::Email < Capybara::Node::Document
|
2
2
|
|
3
|
-
#
|
3
|
+
# Delegate to the email body
|
4
4
|
#
|
5
5
|
# @return [Mail::Message#body]
|
6
6
|
def body
|
7
7
|
base.raw
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
10
|
+
# Delegate to the email subject
|
11
11
|
#
|
12
12
|
# @return [Mail::Message#subject]
|
13
13
|
def subject
|
14
14
|
base.subject
|
15
15
|
end
|
16
16
|
|
17
|
-
#
|
17
|
+
# Delegate to the email to
|
18
18
|
#
|
19
19
|
# @return [Mail::Message#to]
|
20
20
|
def to
|
21
21
|
base.to
|
22
22
|
end
|
23
23
|
|
24
|
-
#
|
24
|
+
# Delegate to the email from
|
25
25
|
#
|
26
26
|
# @return [Mail::Message#from]
|
27
27
|
def from
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: actionmailer
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: capybara
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: bourne
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: rspec
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,7 +85,28 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rake
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
69
110
|
description: Test your ActionMailer and Mailer messages in Capybara
|
70
111
|
email:
|
71
112
|
- bcardarella@gmail.com
|
@@ -74,7 +115,6 @@ executables: []
|
|
74
115
|
extensions: []
|
75
116
|
extra_rdoc_files: []
|
76
117
|
files:
|
77
|
-
- LICENSE
|
78
118
|
- README.md
|
79
119
|
- lib/capybara-email.rb
|
80
120
|
- lib/capybara/email.rb
|
@@ -96,17 +136,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
136
|
- - ! '>='
|
97
137
|
- !ruby/object:Gem::Version
|
98
138
|
version: '0'
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
hash: 511581874085042611
|
99
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
143
|
none: false
|
101
144
|
requirements:
|
102
145
|
- - ! '>='
|
103
146
|
- !ruby/object:Gem::Version
|
104
147
|
version: '0'
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
hash: 511581874085042611
|
105
151
|
requirements: []
|
106
152
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.8.
|
153
|
+
rubygems_version: 1.8.23
|
108
154
|
signing_key:
|
109
155
|
specification_version: 3
|
110
156
|
summary: Test your ActionMailer and Mailer messages in Capybara
|
111
157
|
test_files: []
|
112
|
-
has_rdoc:
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Brian Cardarella
|
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.
|