cucumber-mailcatcher 0.11 → 0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cucumber/mailcatcher.rb +3 -3
- data/lib/cucumber/mailcatcher/api.rb +60 -0
- data/lib/cucumber/mailcatcher/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab604c3e398cbae235785d0f01a7fd3c51392a42
|
4
|
+
data.tar.gz: eeaffbaa844e4dcefb301d81485fea4cec0ab3c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285df8760a8b199a13c0e209383ea1182637ec85a11cf8d4ac8da617b2e193ddad1179888b13cdc2def64fdd9c905b5170242faed88c64581e839148a77cc4c5
|
7
|
+
data.tar.gz: 8dd605d92b4411d8e9e22656434926221cbf37904606a5d46d9a62f8d3fda557454e3e649a30c7ed4804af8030c8acc2c701bc9d5e7c4f0c8d06648747efdcac
|
data/lib/cucumber/mailcatcher.rb
CHANGED
@@ -4,9 +4,9 @@ require 'nokogiri'
|
|
4
4
|
require 'cucumber'
|
5
5
|
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
6
6
|
|
7
|
-
require 'cucumber/mailcatcher/http_client
|
8
|
-
require 'cucumber/mailcatcher/api
|
9
|
-
require 'cucumber/mailcatcher/version
|
7
|
+
require 'cucumber/mailcatcher/http_client'
|
8
|
+
require 'cucumber/mailcatcher/api'
|
9
|
+
require 'cucumber/mailcatcher/version'
|
10
10
|
|
11
11
|
Then /^I should receive (\d+) email from "(.*?)"$/ do |count, address|
|
12
12
|
api = Cucumber::Mailcatcher::Api.new Cucumber::Mailcatcher::HttpClient.new
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Mailcatcher
|
3
|
+
class Api
|
4
|
+
def initialize http_client
|
5
|
+
@http = http_client
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_messages
|
9
|
+
@http.do_get_json '/messages'
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_messages_from_email email
|
13
|
+
messages = get_messages
|
14
|
+
|
15
|
+
messages.select { |item|
|
16
|
+
item if item["sender"].include?(email)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_messages_to_email email
|
21
|
+
messages = get_messages
|
22
|
+
|
23
|
+
messages.select { |item|
|
24
|
+
item if item["recipients"].include?(email) || item["recipients"].include?('<' + email + '>')
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_messages_with_subject subject
|
29
|
+
messages = get_messages
|
30
|
+
|
31
|
+
messages.select { |item|
|
32
|
+
item if item["subject"].include?(subject)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_messages_with_html_body body
|
37
|
+
messages = get_messages
|
38
|
+
|
39
|
+
messages.select { |item|
|
40
|
+
response = @http.do_get "/messages/#{item['id']}.json.html"
|
41
|
+
item if response.code != '404' && response.body.include?(body)
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_messages_with_plain_body body
|
46
|
+
messages = get_messages
|
47
|
+
|
48
|
+
messages.select { |item|
|
49
|
+
response = @http.do_get "/messages/#{item['id']}.json.plain"
|
50
|
+
item if response.code != '404' && response.body.include?(body)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete_messages
|
55
|
+
@http.do_delete '/messages'
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-mailcatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nic Jackson
|
@@ -58,6 +58,7 @@ extensions: []
|
|
58
58
|
extra_rdoc_files: []
|
59
59
|
files:
|
60
60
|
- lib/cucumber/mailcatcher.rb
|
61
|
+
- lib/cucumber/mailcatcher/api.rb
|
61
62
|
- lib/cucumber/mailcatcher/http_client.rb
|
62
63
|
- lib/cucumber/mailcatcher/version.rb
|
63
64
|
homepage: https://github.com/nicholasjackson/cucumber-mailcatcher
|