webspicy 0.20.10 → 0.20.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d5592f5d20acc1479904e8bd5eff0c520e56e4d574d701a30bce0e859b99e16
4
- data.tar.gz: 7f9f4aaded3f2d9588fa367ce7c5c47c056273671aae6d6f727ce867f5d40924
3
+ metadata.gz: 7eba5a8dc97e7c8f2053da2c52e45d728d1de38777ac2088db74aa2852f0ab8a
4
+ data.tar.gz: dfd0330f95b8c9e64b63919820b7b48ba1dc0f4a7696ba03877670f41a8812b3
5
5
  SHA512:
6
- metadata.gz: 4228e07ef11827e35d4d3075c59a7d51dab6379a8281ee4388b0901dd99ee4aa119228071a985077ea91c66db4487e84601e625479120940166d9d6512bb113a
7
- data.tar.gz: 5caf9cffc1712ee79d99db2a92a2307af83d67ee28a6f41c0e78f10ad15b55992eadca463608622ac9dba8a2ab79145630002cd7d1e775214ada7182f2f343e4
6
+ metadata.gz: 243d021ca1344f09880a3fbda147c38dbacb8791c3e8f541acb524992f6c3e15bb997fbb4423b06c504c95f7a85079fa24d329379b8368cc0b04b11a0a0ab028
7
+ data.tar.gz: 47a7462b3b080b276f594b0b1df054488fa69c60038c51d2d22a664aeb83ada0c390380de1497a30d0f990bd97638fbc3acdfc636eb8fbe227e37d3c1512f6f0
@@ -0,0 +1,39 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Fakesendgrid
4
+ include Webspicy::Support::World::Item
5
+
6
+ DEFAULT_OPTIONS = {
7
+ endpoint: "http://fakesendgrid"
8
+ }
9
+
10
+ def initialize(options = {})
11
+ @options = DEFAULT_OPTIONS.merge(options)
12
+ end
13
+ attr_reader :options
14
+
15
+ def endpoint
16
+ options[:endpoint]
17
+ end
18
+
19
+ def clear!
20
+ res = HTTP.delete("#{endpoint}/api/mails")
21
+ end
22
+
23
+ def emails
24
+ res = HTTP.get("#{endpoint}/api/mails")
25
+ JSON.parse(res.body).map{|data| Email.new(data) }
26
+ end
27
+
28
+ def emails_count
29
+ emails.length
30
+ end
31
+
32
+ def last_email
33
+ emails.first
34
+ end
35
+
36
+ end # class Fakesendgrid
37
+ end # class Tester
38
+ end # module Webspicy
39
+ require_relative 'fakesendgrid/email'
@@ -0,0 +1,29 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Fakesendgrid
4
+ class Email
5
+
6
+ def initialize(data)
7
+ @data = data
8
+ end
9
+ attr_reader :data
10
+
11
+ def from
12
+ @from ||= data["from"]["email"]
13
+ end
14
+
15
+ def to
16
+ @to ||= data["personalizations"]
17
+ .select{|h| h.key? "to" }
18
+ .map{|(h)| h["to"] }
19
+ .map{|(h)| h["email"] }
20
+ end
21
+
22
+ def subject
23
+ @subject ||= data["subject"]
24
+ end
25
+
26
+ end # class Email
27
+ end # class Fakesendgrid
28
+ end # class Tester
29
+ end # module Webspicy
@@ -2,7 +2,7 @@ module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 20
5
- TINY = 10
5
+ TINY = 11
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'webspicy/tester/fakesendgrid'
3
+ module Webspicy
4
+ class Tester
5
+ class Fakesendgrid
6
+ describe Email do
7
+
8
+ DATA = JSON.parse <<~J
9
+ {
10
+ "datetime": "2021-06-02T15:29:27.161Z",
11
+ "from": {
12
+ "email": "info@mydomain.be",
13
+ "name": "Foo Bar"
14
+ },
15
+ "subject": "Hello World",
16
+ "personalizations": [
17
+ {
18
+ "to": [
19
+ {
20
+ "email": "support@mydomain.fr"
21
+ }
22
+ ]
23
+ }
24
+ ],
25
+ "content": [
26
+ {
27
+ "value": "test",
28
+ "type": "text/plain"
29
+ },
30
+ {
31
+ "value": "test <b>test</b> test",
32
+ "type": "text/html"
33
+ }
34
+ ]
35
+ }
36
+ J
37
+
38
+ subject{
39
+ Email.new(DATA)
40
+ }
41
+
42
+ it 'works as expected' do
43
+ expect(subject.from).to eql("info@mydomain.be")
44
+ expect(subject.to).to eql(["support@mydomain.fr"])
45
+ expect(subject.subject).to eql("Hello World")
46
+ end
47
+
48
+ end
49
+ end
50
+ end
51
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webspicy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.10
4
+ version: 0.20.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: http
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '4'
103
+ version: 4.4.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '4'
110
+ version: 4.4.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: path
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -261,6 +261,8 @@ files:
261
261
  - lib/webspicy/tester/assertions.rb
262
262
  - lib/webspicy/tester/client.rb
263
263
  - lib/webspicy/tester/failure.rb
264
+ - lib/webspicy/tester/fakesendgrid.rb
265
+ - lib/webspicy/tester/fakesendgrid/email.rb
264
266
  - lib/webspicy/tester/fakeses.rb
265
267
  - lib/webspicy/tester/fakeses/email.rb
266
268
  - lib/webspicy/tester/fakesmtp.rb
@@ -323,6 +325,7 @@ files:
323
325
  - spec/unit/support/world/fixtures/yaml.yml
324
326
  - spec/unit/support/world/test_world.rb
325
327
  - spec/unit/test_configuration.rb
328
+ - spec/unit/tester/fakesendgrid/test_email.rb
326
329
  - spec/unit/tester/fakeses/test_email.rb
327
330
  - spec/unit/tester/fakesmtp/test_email.rb
328
331
  - spec/unit/tester/test_asserter.rb