teams_connector 0.1.3 → 0.1.4
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 +4 -4
- data/CHANGES.md +4 -0
- data/README.md +15 -0
- data/lib/teams_connector/configuration.rb +1 -1
- data/lib/teams_connector/notification.rb +2 -0
- data/lib/teams_connector/testing.rb +13 -0
- data/lib/teams_connector/version.rb +1 -1
- data/lib/teams_connector.rb +11 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46a69bacfa1eb6a6b46616d436ff4b8c7890db602ce30c7f082e004e53e161c3
|
4
|
+
data.tar.gz: e98ac0f36a4fc64a1ec41f100ce6b062dc4b1ff4579a2094e2b6d49530b2b5f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5183b39ff855da474a6417861020f44b2933a4e93fbc497207eab427802e88a33d41511ca30c90390741baf85f39a72b30804ddf78a302f1247e49bfb3edd69
|
7
|
+
data.tar.gz: b68b7311f4ba4f7fd2b37c99bdc960fef80d0c7528fdad6a06002820df60131c0f4b5ae1eb2f5f08a9d57e54c5a7673ee96add2d9aca7219c76301ccc5d27f14
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -109,6 +109,21 @@ end
|
|
109
109
|
TeamsConnector::Notification::AdaptiveCard.new(content: builder).deliver_later
|
110
110
|
```
|
111
111
|
|
112
|
+
## Testing
|
113
|
+
|
114
|
+
To test TeamsConnector integration in your application you can use the `:testing` method.
|
115
|
+
Instead of performing real HTTP requests, an array in `TeamsConnector.testing.requests` is filled in chronological order.
|
116
|
+
|
117
|
+
The request elements have the following structure:
|
118
|
+
```ruby
|
119
|
+
{
|
120
|
+
channel: :default,
|
121
|
+
template: :facts_card,
|
122
|
+
content: "rendered content",
|
123
|
+
time: Time.now
|
124
|
+
}
|
125
|
+
```
|
126
|
+
|
112
127
|
## Development
|
113
128
|
|
114
129
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -19,7 +19,7 @@ module TeamsConnector
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def method=(method)
|
22
|
-
raise ArgumentError, "Method '#{method.to_s}' is not supported" unless [:direct, :sidekiq].include? method
|
22
|
+
raise ArgumentError, "Method '#{method.to_s}' is not supported" unless [:direct, :sidekiq, :testing].include? method
|
23
23
|
raise ArgumentError, "Sidekiq is not available" if method == :sidekiq && !defined? Sidekiq
|
24
24
|
@method = method
|
25
25
|
end
|
@@ -27,6 +27,8 @@ module TeamsConnector
|
|
27
27
|
|
28
28
|
if TeamsConnector.configuration.method == :sidekiq
|
29
29
|
TeamsConnector::PostWorker.perform_async(url, content)
|
30
|
+
elsif TeamsConnector.configuration.method == :testing
|
31
|
+
TeamsConnector.testing.perform_request channel, @template, content
|
30
32
|
else
|
31
33
|
response = Net::HTTP.post(URI(url), content, { "Content-Type": "application/json" })
|
32
34
|
response.value
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module TeamsConnector
|
2
|
+
class Testing
|
3
|
+
attr_reader :requests
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@requests = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform_request(channel, template, content)
|
10
|
+
@requests.push({channel: channel, content: content, template: template, time: Time.now})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/teams_connector.rb
CHANGED
@@ -7,7 +7,7 @@ require 'teams_connector/builder'
|
|
7
7
|
|
8
8
|
module TeamsConnector
|
9
9
|
class << self
|
10
|
-
attr_accessor :configuration
|
10
|
+
attr_accessor :configuration, :testing
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.configuration
|
@@ -22,6 +22,16 @@ module TeamsConnector
|
|
22
22
|
yield configuration
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.testing
|
26
|
+
require 'teams_connector/testing'
|
27
|
+
@testing ||= Testing.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.reset_testing
|
31
|
+
require 'teams_connector/testing'
|
32
|
+
@testing = Testing.new
|
33
|
+
end
|
34
|
+
|
25
35
|
def self.project_root
|
26
36
|
if defined?(Rails)
|
27
37
|
return Rails.root
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teams_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Keune
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/teams_connector/notification/adaptive_card.rb
|
122
122
|
- lib/teams_connector/notification/message.rb
|
123
123
|
- lib/teams_connector/post_worker.rb
|
124
|
+
- lib/teams_connector/testing.rb
|
124
125
|
- lib/teams_connector/version.rb
|
125
126
|
- teams_connector.gemspec
|
126
127
|
- templates/teams_connector/adaptive_card.json.erb
|