cucumber-mailcatcher 0.11 → 0.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d03aa27678b5628e68f6a413105f2e934303f4f1
4
- data.tar.gz: d94851efff695546e98cef37a9522455adfafd6c
3
+ metadata.gz: ab604c3e398cbae235785d0f01a7fd3c51392a42
4
+ data.tar.gz: eeaffbaa844e4dcefb301d81485fea4cec0ab3c9
5
5
  SHA512:
6
- metadata.gz: e08ad9c63ab1f38806bef52ce4ea4c84aca2731b86930dc31b778a351db8e9ed68987ffa6cc19050b727a4f0b384e3796f9bc2e06e520cb97108f7e0d92d5857
7
- data.tar.gz: 6daa1a54da9213fc8e8e6ceb9b66aaff33372f545e7be613813b12f6cbe6de4bcfb34b49878e68a398bf8c61e0e645dd7cc4db76aa2ae39f59563d1130eb87c1
6
+ metadata.gz: 285df8760a8b199a13c0e209383ea1182637ec85a11cf8d4ac8da617b2e193ddad1179888b13cdc2def64fdd9c905b5170242faed88c64581e839148a77cc4c5
7
+ data.tar.gz: 8dd605d92b4411d8e9e22656434926221cbf37904606a5d46d9a62f8d3fda557454e3e649a30c7ed4804af8030c8acc2c701bc9d5e7c4f0c8d06648747efdcac
@@ -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.rb'
8
- require 'cucumber/mailcatcher/api.rb'
9
- require 'cucumber/mailcatcher/version.rb'
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
@@ -2,6 +2,6 @@ module Cucumber
2
2
  module Mailcatcher
3
3
  NAME = "cucumber-mailcatcher"
4
4
  FOLDER = "cucumber/mailcatcher"
5
- VERSION = "0.11"
5
+ VERSION = "0.12"
6
6
  end
7
7
  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.11'
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