engaging-networks-rest 0.7.0 → 1.0.0

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: 0d4c75c9409376d414dc63d78307aa86b764c036a93b007590137f85794c1980
4
- data.tar.gz: 46e773a7635d878fe9115b66e1a7a395e0efd287ed1532c73b347c7e6e027cca
3
+ metadata.gz: 50d7f225fefc60a2c7aca2d2bc17c290a0a483548d86b78cb138b1333a131c09
4
+ data.tar.gz: e172253dbccf464fa9f8862e0dcb5afd3802cc5745f1dd7a79fe4fdfc8981d9a
5
5
  SHA512:
6
- metadata.gz: a4ae62b058d6ef1589226b0f82150da4cd45ef641f617dc967ff500b1529ba18137f098ee5e95054ed5ea0e4bdd0c42c868d5b37436960692df280a5939213e9
7
- data.tar.gz: 6b2e2241bbc45fe002587341cfe792b826f403755d8c5b77efb226595c7e325cbb95745ee306a259e778fc4a54919ba87c9ce88e68c5dacd9ba8095fabe445a2
6
+ metadata.gz: 5363d9b2582910b3b54a69eff21226508fe39986a89103f73676ffc5b18436a7d787b3890940e7d1a7d2b8d803534507ba2cdd2b1c3d2531cc2de1409b05f2de
7
+ data.tar.gz: 0efb3821b1caf980c4a56c2acf87fc2814721e8e7206bcfb853e22de59798a16d48ea3a66b8506b8e781bdd6174bc48ee395da3eb218e49287eeb14035813986
@@ -7,7 +7,7 @@ jobs:
7
7
 
8
8
  strategy:
9
9
  matrix:
10
- ruby-version: ['2.7', '3.0', '3.1', '3.2']
10
+ ruby-version: ['3.1', '3.2']
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
@@ -23,7 +23,7 @@ jobs:
23
23
 
24
24
  strategy:
25
25
  matrix:
26
- ruby-version: ['2.7', '3.0', '3.1', '3.2']
26
+ ruby-version: ['3.1', '3.2']
27
27
 
28
28
  steps:
29
29
  - uses: actions/checkout@v2
data/.gitignore ADDED
@@ -0,0 +1,53 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ .idea/
53
+ .byebug_history
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.4
1
+ 3.1.4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0] - 2023-10-17
4
+
5
+ ### BREAKING CHANGES
6
+ - Drops support for ruby versions 2.7 and 3.0. Only ruby 3.1 or newer is now supported.
7
+ - `EngagingNetworksRest.new` and `EngagingNetworksRest::Client.new` now require the `host` parameter
8
+
9
+ ### Development changes
10
+ - Removed juwelier. Dependencies are now managed only in the gemspec file.
11
+ - Replaced byebug with debug
12
+ - Upgraded required faker version to eliminate the need for pinning psych
13
+
1
14
  ## [0.7.0] - 2023-10-16
2
15
 
3
16
  ### Added
data/Gemfile CHANGED
@@ -2,17 +2,5 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'faraday', '>= 1.0'
6
- gem 'faraday_middleware'
7
-
8
- group :development do
9
- gem 'faker', '> 1.9'
10
- gem 'psych', '3.3.2' # See https://github.com/faker-ruby/faker/issues/2330
11
-
12
- gem 'faraday-detailed_logger', '>= 2.1.2'
13
- gem 'juwelier', git: 'https://github.com/flajann2/juwelier.git'
14
- gem 'pry-byebug', '> 3.6'
15
- gem 'rspec', '>= 0'
16
- gem 'rubocop'
17
- gem 'webmock', '> 3.4'
18
- end
5
+ # Gem's dependencies are specified in engaging-networks-rest.gemspec
6
+ gemspec
data/Rakefile CHANGED
@@ -11,21 +11,6 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require 'juwelier'
15
- Juwelier::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
- gem.name = 'engaging-networks-rest'
18
- gem.homepage = 'http://github.com/controlshift/engaging-networks-rest'
19
- gem.license = 'MIT'
20
- gem.summary = %(Client gem for the ENS API to Engaging Networks)
21
- gem.description = %(Client gem for the ENS API to Engaging Networks)
22
- gem.email = 'grey@controlshiftlabs.com'
23
- gem.authors = ['Grey Moore']
24
-
25
- # dependencies defined in Gemfile
26
- end
27
- Juwelier::RubygemsDotOrgTasks.new
28
-
29
14
  require 'rspec/core/rake_task'
30
15
  desc 'Run specs'
31
16
  RSpec::Core::RakeTask.new do |t|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 1.0.0
@@ -1,77 +1,42 @@
1
- # Generated by juwelier
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: engaging-networks-rest 0.7.0 ruby lib
1
+ # frozen_string_literal: true
6
2
 
7
3
  Gem::Specification.new do |s|
8
4
  s.name = "engaging-networks-rest".freeze
9
- s.version = "0.7.0"
5
+ s.version = "1.0.0"
10
6
 
11
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
8
  s.require_paths = ["lib".freeze]
13
9
  s.authors = ["Grey Moore".freeze]
14
- s.date = "2023-10-16"
10
+ s.date = "2023-10-17"
15
11
  s.description = "Client gem for the ENS API to Engaging Networks".freeze
16
- s.email = "grey@controlshiftlabs.com".freeze
12
+ s.email = "systems@controlshiftlabs.com".freeze
17
13
  s.extra_rdoc_files = [
18
14
  "LICENSE",
19
15
  "LICENSE.txt",
20
16
  "README.md"
21
17
  ]
22
- s.files = [
23
- ".github/workflows/ci.yml",
24
- ".rubocop.yml",
25
- ".ruby-gemset",
26
- ".ruby-version",
27
- "CHANGELOG.md",
28
- "Gemfile",
29
- "LICENSE",
30
- "LICENSE.txt",
31
- "README.md",
32
- "Rakefile",
33
- "VERSION",
34
- "engaging-networks-rest.gemspec",
35
- "example.rb",
36
- "lib/engaging_networks_rest.rb",
37
- "lib/engaging_networks_rest/client.rb",
38
- "lib/engaging_networks_rest/client/pages.rb",
39
- "lib/engaging_networks_rest/response/raise_error.rb",
40
- "spec/client/pages_spec.rb",
41
- "spec/client_spec.rb",
42
- "spec/spec_helper.rb"
43
- ]
44
- s.homepage = "http://github.com/controlshift/engaging-networks-rest".freeze
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+
25
+ s.homepage = 'https://github.com/controlshift/engaging-networks-rest'.freeze
45
26
  s.licenses = ["MIT".freeze]
46
- s.rubygems_version = "3.1.6".freeze
47
27
  s.summary = "Client gem for the ENS API to Engaging Networks".freeze
48
28
 
49
29
  if s.respond_to? :specification_version then
50
30
  s.specification_version = 4
51
31
  end
52
32
 
53
- if s.respond_to? :add_runtime_dependency then
54
- s.add_runtime_dependency(%q<faraday>.freeze, [">= 1.0"])
55
- s.add_runtime_dependency(%q<faraday_middleware>.freeze, [">= 0"])
56
- s.add_development_dependency(%q<faker>.freeze, ["> 1.9"])
57
- s.add_development_dependency(%q<psych>.freeze, ["= 3.3.2"])
58
- s.add_development_dependency(%q<faraday-detailed_logger>.freeze, [">= 2.1.2"])
59
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
60
- s.add_development_dependency(%q<pry-byebug>.freeze, ["> 3.6"])
61
- s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
62
- s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
63
- s.add_development_dependency(%q<webmock>.freeze, ["> 3.4"])
64
- else
65
- s.add_dependency(%q<faraday>.freeze, [">= 1.0"])
66
- s.add_dependency(%q<faraday_middleware>.freeze, [">= 0"])
67
- s.add_dependency(%q<faker>.freeze, ["> 1.9"])
68
- s.add_dependency(%q<psych>.freeze, ["= 3.3.2"])
69
- s.add_dependency(%q<faraday-detailed_logger>.freeze, [">= 2.1.2"])
70
- s.add_dependency(%q<juwelier>.freeze, [">= 0"])
71
- s.add_dependency(%q<pry-byebug>.freeze, ["> 3.6"])
72
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
73
- s.add_dependency(%q<rubocop>.freeze, [">= 0"])
74
- s.add_dependency(%q<webmock>.freeze, ["> 3.4"])
75
- end
76
- end
33
+ s.add_runtime_dependency(%q<faraday>.freeze, [">= 1.0"])
34
+ s.add_runtime_dependency(%q<faraday_middleware>.freeze, [">= 0"])
77
35
 
36
+ s.add_development_dependency(%q<faker>.freeze, ["> 2.20.0"])
37
+ s.add_development_dependency(%q<faraday-detailed_logger>.freeze, [">= 2.1.2"])
38
+ s.add_development_dependency(%q<debug>.freeze, ["> 0"])
39
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
40
+ s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
41
+ s.add_development_dependency(%q<webmock>.freeze, ["> 3.4"])
42
+ end
@@ -9,9 +9,7 @@ module EngagingNetworksRest
9
9
  class Client
10
10
  attr_reader :api_key, :connection, :ens_auth_key
11
11
 
12
- ENS_DOMAIN = 'www.e-activist.com'
13
-
14
- def initialize(api_key:, host: ENS_DOMAIN)
12
+ def initialize(api_key:, host:)
15
13
  @api_key = api_key
16
14
 
17
15
  @connection = Faraday.new(url: "https://#{host}") do |conn|
@@ -40,11 +38,11 @@ module EngagingNetworksRest
40
38
  end
41
39
 
42
40
  def get(path:, params: {})
43
- request(method: :get, path: path, params: params)
41
+ request(method: :get, path:, params:)
44
42
  end
45
43
 
46
44
  def post(path:, body: {})
47
- request(method: :post, path: path, body: body)
45
+ request(method: :post, path:, body:)
48
46
  end
49
47
 
50
48
  include EngagingNetworksRest::Client::Pages
@@ -4,8 +4,8 @@ require 'engaging_networks_rest/client'
4
4
 
5
5
  module EngagingNetworksRest
6
6
  class << self
7
- def new(api_key:, host: EngagingNetworksRest::Client::ENS_DOMAIN)
8
- EngagingNetworksRest::Client.new(api_key: api_key, host: host)
7
+ def new(api_key:, host:)
8
+ EngagingNetworksRest::Client.new(api_key:, host:)
9
9
  end
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engaging-networks-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -44,28 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.9'
47
+ version: 2.20.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.9'
55
- - !ruby/object:Gem::Dependency
56
- name: psych
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 3.3.2
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
67
- - !ruby/object:Gem::Version
68
- version: 3.3.2
54
+ version: 2.20.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: faraday-detailed_logger
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +67,19 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: 2.1.2
83
69
  - !ruby/object:Gem::Dependency
84
- name: juwelier
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: pry-byebug
70
+ name: debug
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - ">"
102
74
  - !ruby/object:Gem::Version
103
- version: '3.6'
75
+ version: '0'
104
76
  type: :development
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - ">"
109
81
  - !ruby/object:Gem::Version
110
- version: '3.6'
82
+ version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: rspec
113
85
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +123,7 @@ dependencies:
151
123
  - !ruby/object:Gem::Version
152
124
  version: '3.4'
153
125
  description: Client gem for the ENS API to Engaging Networks
154
- email: grey@controlshiftlabs.com
126
+ email: systems@controlshiftlabs.com
155
127
  executables: []
156
128
  extensions: []
157
129
  extra_rdoc_files:
@@ -160,6 +132,7 @@ extra_rdoc_files:
160
132
  - README.md
161
133
  files:
162
134
  - ".github/workflows/ci.yml"
135
+ - ".gitignore"
163
136
  - ".rubocop.yml"
164
137
  - ".ruby-gemset"
165
138
  - ".ruby-version"
@@ -176,10 +149,7 @@ files:
176
149
  - lib/engaging_networks_rest/client.rb
177
150
  - lib/engaging_networks_rest/client/pages.rb
178
151
  - lib/engaging_networks_rest/response/raise_error.rb
179
- - spec/client/pages_spec.rb
180
- - spec/client_spec.rb
181
- - spec/spec_helper.rb
182
- homepage: http://github.com/controlshift/engaging-networks-rest
152
+ homepage: https://github.com/controlshift/engaging-networks-rest
183
153
  licenses:
184
154
  - MIT
185
155
  metadata: {}
@@ -198,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
168
  - !ruby/object:Gem::Version
199
169
  version: '0'
200
170
  requirements: []
201
- rubygems_version: 3.1.6
171
+ rubygems_version: 3.3.26
202
172
  signing_key:
203
173
  specification_version: 4
204
174
  summary: Client gem for the ENS API to Engaging Networks
@@ -1,137 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe EngagingNetworksRest::Client::Pages do
6
- let(:api_key) { 'abc-123' }
7
- let(:ens_auth_key) { 'tmp-auth-key-456' }
8
- let(:standard_headers) { { 'Content-Type' => 'application/json', 'Ens-Auth-Token' => ens_auth_key } }
9
-
10
- subject { EngagingNetworksRest::Client.new(api_key: api_key) }
11
-
12
- describe '#pages' do
13
- let(:page_type) { 'dcf' }
14
- let(:page_status) { 'live' }
15
- let(:pages_url) { "https://#{EngagingNetworksRest::Client::ENS_DOMAIN}/ens/service/page" }
16
-
17
- # The API docs don't actually say what this response looks like, so this is a guess.
18
- # Fortunately, it doesn't actually matter for our purposes, since we just return whatever JSON we get.
19
- let(:response) { [{ 'id' => 123, 'title' => 'A page' }, { 'id' => 234, 'title' => 'Another page' }] }
20
-
21
- shared_examples_for 'list pages' do
22
- it 'should get pages' do
23
- stub_request(:get, pages_url)
24
- .with(headers: standard_headers, query: { 'type' => page_type, 'status' => page_status })
25
- .to_return(status: '200',
26
- headers: { content_type: 'application/json; charset=utf-8' },
27
- body: response.to_json)
28
-
29
- expect(subject.pages(type: page_type, status: page_status)).to eq response
30
- end
31
-
32
- it 'should omit status param if not specified' do
33
- stub_request(:get, pages_url)
34
- .with(headers: standard_headers, query: { 'type' => page_type })
35
- .to_return(status: '200',
36
- headers: { content_type: 'application/json; charset=utf-8' },
37
- body: response.to_json)
38
-
39
- expect(subject.pages(type: page_type)).to eq response
40
- end
41
- end
42
-
43
- context 'not already authenticated' do
44
- before :each do
45
- expect(subject).to receive(:authenticate!) do
46
- allow(subject).to receive(:ens_auth_key).and_return(ens_auth_key)
47
- end
48
- end
49
-
50
- include_examples 'list pages'
51
- end
52
-
53
- context 'already authenticated' do
54
- before :each do
55
- allow(subject).to receive(:ens_auth_key).and_return(ens_auth_key)
56
- end
57
-
58
- include_examples 'list pages'
59
- end
60
- end
61
-
62
- describe '#process_page_request' do
63
- let(:page_id) { 234 }
64
- let(:page_req_url) { "https://#{EngagingNetworksRest::Client::ENS_DOMAIN}/ens/service/page/#{page_id}/process" }
65
- let(:email) { Faker::Internet.email }
66
- let(:supporter_hash) do
67
- { 'firstName' => 'Joe', 'lastName' => 'Smith', 'emailAddress' => email, 'customField1' => 'foo' }
68
- end
69
- let(:response) do
70
- { 'id' => '1234567', 'status' => 'SUCCESS', 'supporterEmailAddress' => email, 'supporterId' => '98765' }
71
- end
72
- let(:failure_response) { { 'status' => 'ERROR', 'message' => 'Something went wrong' } }
73
-
74
- shared_examples_for 'process page request' do
75
- it 'should send correct body for supporter and generic data' do
76
- stub_request(:post, page_req_url)
77
- .with(body: { 'txn1' => 'foo', 'txn2' => 'bar', 'suppressAutoResponder' => true,
78
- supporter: { 'lastName' => 'Smith', 'emailAddress' => email } }.to_json,
79
- headers: standard_headers)
80
- .to_return(status: '200',
81
- headers: { content_type: 'application/json; charset=utf-8' },
82
- body: response.to_json)
83
-
84
- subject.process_page_request(page_id: page_id,
85
- generic_data: { 'txn1' => 'foo',
86
- 'txn2' => 'bar',
87
- 'suppressAutoResponder' => true },
88
- supporter_data: { 'lastName' => 'Smith', 'emailAddress' => email })
89
- end
90
-
91
- it 'should process the page request and return its ID' do
92
- stub_request(:post, page_req_url)
93
- .with(body: { supporter: supporter_hash }.to_json, headers: standard_headers)
94
- .to_return(status: '200',
95
- headers: { content_type: 'application/json; charset=utf-8' },
96
- body: response.to_json)
97
-
98
- result = subject.process_page_request(page_id: page_id, supporter_data: supporter_hash)
99
-
100
- expect(result['id']).to eq '1234567'
101
- expect(result['supporterId']).to eq '98765'
102
- expect(result['supporterEmailAddress']).to eq email
103
- end
104
-
105
- it 'should raise if response status is not SUCCESS' do
106
- stub_request(:post, page_req_url)
107
- .with(body: { supporter: supporter_hash }.to_json, headers: standard_headers)
108
- .to_return(status: '200',
109
- headers: { content_type: 'application/json; charset=utf-8' },
110
- body: failure_response.to_json)
111
-
112
- expect do
113
- subject.process_page_request(page_id: page_id,
114
- supporter_data: supporter_hash)
115
- end.to raise_error(RuntimeError, /Unexpected 'status' value on response.*Something went wrong/)
116
- end
117
- end
118
-
119
- context 'not already authenticated' do
120
- before :each do
121
- expect(subject).to receive(:authenticate!) do
122
- allow(subject).to receive(:ens_auth_key).and_return(ens_auth_key)
123
- end
124
- end
125
-
126
- include_examples 'process page request'
127
- end
128
-
129
- context 'already authenticated' do
130
- before :each do
131
- allow(subject).to receive(:ens_auth_key).and_return(ens_auth_key)
132
- end
133
-
134
- include_examples 'process page request'
135
- end
136
- end
137
- end
data/spec/client_spec.rb DELETED
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe EngagingNetworksRest::Client do
6
- let(:api_key) { 'abc123' }
7
- let(:content_type_header) { { 'Content-Type' => 'application/json' } }
8
-
9
- subject { EngagingNetworksRest::Client.new(api_key: api_key) }
10
-
11
- describe '#authenticate!' do
12
- let(:auth_key) { '75491e42-99dc-45ce-b637-a681bede875c' }
13
- let(:auth_key_body) { "{\"ens-auth-token\":\"#{auth_key}\",\"expires\":3600000}" }
14
-
15
- before :each do
16
- stub_request(:post, auth_url)
17
- .with(body: api_key, headers: content_type_header)
18
- .to_return(body: auth_key_body, headers: content_type_header)
19
- end
20
-
21
- context 'with no host specified' do
22
- let(:auth_url) { "https://#{EngagingNetworksRest::Client::ENS_DOMAIN}/ens/service/authenticate" }
23
-
24
- it 'should set the ens_auth_key on the client' do
25
- subject.authenticate!
26
-
27
- expect(subject.ens_auth_key).to eq auth_key
28
- end
29
- end
30
-
31
- context 'with a host specified' do
32
- let(:host) { 'example.com' }
33
- let(:auth_url) { "https://#{host}/ens/service/authenticate" }
34
-
35
- subject { EngagingNetworksRest::Client.new(api_key: api_key, host: host) }
36
-
37
- it 'should set the ens_auth_key on the client' do
38
- subject.authenticate!
39
-
40
- expect(subject.ens_auth_key).to eq auth_key
41
- end
42
- end
43
- end
44
- end
data/spec/spec_helper.rb DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec'
4
- require 'webmock/rspec'
5
- require 'faker'
6
-
7
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
8
-
9
- require 'engaging_networks_rest'
10
-
11
- RSpec.configure do |config|
12
- config.include WebMock::API
13
-
14
- config.before :each do
15
- WebMock.reset!
16
- end
17
-
18
- config.after :each do
19
- WebMock.reset!
20
- end
21
- end