roqua-rom-api 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 6799541e853eb01fd30aa3acf6adf501f0dc9df1
4
- data.tar.gz: b799b813379d314f5cde25a9d238bc910167b218
3
+ metadata.gz: 05a0d9ec612437981f82ec1c3b7236437c6aa58b
4
+ data.tar.gz: bc1bb0cac2a640d4038ba6a165a1ab38a6da3b40
5
5
  SHA512:
6
- metadata.gz: 4f8b7c6571b8f4170c95b2c002ff5b32065dc0b79e30668998eb6a5d6b2ca78dd5376c861bca06f9599785f128ea641c78295baf72363948a0883e07310f7630
7
- data.tar.gz: b71f01c1dbdadacf838a526454d6bbc23bc87101bc658796b03ae06b92ca3f5cbae2e7708d328b2417a7e635cd4e9f36a12919748cec60b207e50d1957604425
6
+ metadata.gz: d5df8650874825cc203a28a51522b34079271d3b8f9e6624e928a3f04508661d6832093c71b3629a7c904a6aec34726d0f584af95919c46237e6712546e37c05
7
+ data.tar.gz: 8064fc956752998a5f42970b7b96553e9efb7c51de471e9e5a2a59438f7218fc83a1c0a46b8d29ce0642124944c77b33e644970620ab574339770dce63962b30
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.0.4 / 2014-03-06
2
+
3
+ * Use BasicAuthSession for http requests instead of RomApi::Base class
4
+
1
5
  ### 0.0.3 / 2014-02-18
2
6
 
3
7
  * Remove daily start time from api
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roqua-rom-api (0.0.3)
4
+ roqua-rom-api (0.0.4)
5
5
  active_interaction (~> 1.0.4)
6
6
  httparty (~> 0.12.0)
7
7
 
@@ -10,10 +10,10 @@ GEM
10
10
  specs:
11
11
  active_interaction (1.0.4)
12
12
  activemodel (>= 3, < 5)
13
- activemodel (4.0.2)
14
- activesupport (= 4.0.2)
13
+ activemodel (4.0.3)
14
+ activesupport (= 4.0.3)
15
15
  builder (~> 3.1.0)
16
- activesupport (4.0.2)
16
+ activesupport (4.0.3)
17
17
  i18n (~> 0.6, >= 0.6.4)
18
18
  minitest (~> 4.2)
19
19
  multi_json (~> 1.3)
@@ -28,6 +28,7 @@ GEM
28
28
  nio4r (>= 0.5.0)
29
29
  coderay (1.1.0)
30
30
  diff-lcs (1.2.5)
31
+ fabrication (2.9.6)
31
32
  ffi (1.9.3)
32
33
  formatador (0.2.4)
33
34
  fuubar (1.3.2)
@@ -88,8 +89,10 @@ PLATFORMS
88
89
 
89
90
  DEPENDENCIES
90
91
  bundler (~> 1.0)
92
+ fabrication (~> 2.9.6)
91
93
  fuubar (~> 1.3.2)
92
94
  guard-rspec (~> 4.2.6)
93
95
  rake (~> 10.1)
94
96
  roqua-rom-api!
97
+ rspec (~> 2.14.1)
95
98
  yard (~> 0.8)
data/README.md CHANGED
@@ -6,7 +6,7 @@ Make sure the following environment variables are defined:
6
6
  ENV['ROQUA_ROM_KEY'] # username used for HTTP basic authentication on the RoQua API
7
7
  ENV['ROQUA_ROM_SECRET'] # password used for HTTP basic authentication on the RoQua API
8
8
 
9
- A HTTP basic auth username password combination can be generated in the RoQua admin interface integration tab
9
+ An HTTP basic auth username password combination can be generated in the RoQua admin interface integration tab
10
10
 
11
11
  ## Protocol Subscriptions
12
12
 
data/lib/roqua/rom_api.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'roqua/rom_api/version'
2
2
  require 'active_interaction'
3
- require 'roqua/rom_api/base'
4
- require 'roqua/rom_api/start_protocol_subscription'
3
+ require 'roqua/rom_api/sessions'
4
+ require 'roqua/rom_api/results'
5
+ require 'roqua/rom_api/start_protocol_subscription'
6
+ require 'roqua/rom_api/list_responses'
@@ -0,0 +1,18 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class ListResponses < ActiveInteraction::Base
5
+ include Sessions
6
+ include Results
7
+ string :dossier_id
8
+
9
+ def execute
10
+ session = BasicAuthSession.new
11
+ response = session.get "/dossiers/#{dossier_id}/responses"
12
+ JSON.parse(response.body)['responses'].map do |response_entry|
13
+ Response.new response_entry
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ require 'roqua/rom_api/results/response'
@@ -0,0 +1,20 @@
1
+ module Roqua
2
+ module RomApi
3
+ module Results
4
+ class Response
5
+ attr_reader :response, :name, :open_from, :open_till, :completing_url, :completer_type, :completed_at, :status
6
+
7
+ def initialize(response)
8
+ @response = response
9
+ @name = response['name']
10
+ @open_from = response['open_from']
11
+ @open_till = response['open_till']
12
+ @completing_url = response['completing_url']
13
+ @completer_type = response['completer_type']
14
+ @status = response['status']
15
+ @completed_at = response['completed_at']
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,2 @@
1
+ require 'httparty'
2
+ require 'roqua/rom_api/sessions/basic_auth_session'
@@ -0,0 +1,61 @@
1
+ module Roqua
2
+ module RomApi
3
+ module Sessions
4
+ class BasicAuthSession
5
+ attr_reader :rom_host
6
+ attr_reader :username
7
+ attr_reader :password
8
+
9
+ def initialize(rom_host: ENV['ROQUA_ROM_HOST'],
10
+ username: ENV['ROQUA_ROM_KEY'],
11
+ password: ENV['ROQUA_ROM_SECRET'])
12
+ @rom_host = rom_host
13
+ @username = username
14
+ @password = password
15
+ end
16
+
17
+ def get(path, params = {})
18
+ perform_request_or_fail do
19
+ HTTParty.get(full_url_for(path), query: params, basic_auth: basic_auth)
20
+ end
21
+ end
22
+
23
+ def post(path, params = {})
24
+ perform_request_or_fail do
25
+ HTTParty.post(full_url_for(path), body: params, basic_auth: basic_auth)
26
+ end
27
+ end
28
+
29
+ def patch(path, params = {})
30
+ perform_request_or_fail do
31
+ HTTParty.patch(full_url_for(path), body: params, basic_auth: basic_auth)
32
+ end
33
+ end
34
+
35
+ def delete(path, params = {})
36
+ HTTParty.delete(full_url_for(path), query: params, basic_auth: basic_auth)
37
+ end
38
+
39
+ private
40
+
41
+ def perform_request_or_fail(&block)
42
+ response = yield
43
+ fail response.parsed_response unless (200..299).include? response.code
44
+ response
45
+ end
46
+
47
+ def full_url_for(path)
48
+ rom_host + api_base + path + '.json'
49
+ end
50
+
51
+ def api_base
52
+ '/api/v1'
53
+ end
54
+
55
+ def basic_auth
56
+ {username: username, password: password}
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -2,16 +2,18 @@ module Roqua
2
2
  module RomApi
3
3
  # @api private
4
4
  class StartProtocolSubscription < ActiveInteraction::Base
5
+ include Sessions
5
6
  string :dossier_id
6
7
  string :protocol_key
7
8
  time :start_at, default: nil
8
9
 
9
10
  def execute
11
+ session = BasicAuthSession.new
10
12
  options = {dossier_id: dossier_id,
11
13
  protocol_key: protocol_key}
12
14
  options[:start_at] = start_at.to_i if start_at
13
- response = Base.post '/protocol_subscriptions', options
14
- fail response.parsed_response.inspect unless response.code / 100 == 2
15
+ response = session.post '/protocol_subscriptions', options
16
+ fail response.parsed_response.inspect unless (200..299).include? response.code
15
17
  response
16
18
  end
17
19
  end
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module RomApi
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.license = "MIT"
10
10
  gem.authors = ["Samuel Esposito"]
11
11
  gem.email = "s.esposito@roqua.nl"
12
- gem.homepage = "https://github.com/roqua/rom/blob/master/rom_api/README.md"
12
+ gem.homepage = "https://github.com/roqua/roqua/blob/master/rom_api/README.md"
13
13
 
14
14
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
15
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
@@ -19,7 +19,9 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency 'httparty', '~> 0.12.0'
20
20
  gem.add_dependency 'active_interaction', '~> 1.0.4'
21
21
 
22
- gem.add_development_dependency 'bundler', '~> 1.0'
23
- gem.add_development_dependency 'rake', '~> 10.1'
24
- gem.add_development_dependency 'yard', '~> 0.8'
22
+ gem.add_development_dependency 'bundler', '~> 1.0'
23
+ gem.add_development_dependency 'rake', '~> 10.1'
24
+ gem.add_development_dependency 'yard', '~> 0.8'
25
+ gem.add_development_dependency 'rspec', '~> 2.14.1'
26
+ gem.add_development_dependency 'fabrication', '~> 2.9.6'
25
27
  end
@@ -0,0 +1,7 @@
1
+ Fabricator(:basic_auth_session, from: Roqua::RomApi::Sessions::BasicAuthSession) do
2
+ initialize_with do
3
+ Roqua::RomApi::Sessions::BasicAuthSession.new username: 'some_username',
4
+ password: 'some_password',
5
+ rom_host: 'http://roqua.dev'
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe ListResponses do
4
+ let(:options) { {dossier_id: '1'} }
5
+ let(:api_path) { "/dossiers/#{options[:dossier_id]}/responses" }
6
+ let(:response) { '{"responses":[{"name":"response_1"},{"name":"response_2"}]}' }
7
+ let(:session) { Fabricate :basic_auth_session }
8
+ before { allow(BasicAuthSession).to receive(:new).and_return session }
9
+
10
+ it 'returns an array of response objects' do
11
+ allow(session).to receive(:get).with(api_path).and_return double(body: response)
12
+ result = ListResponses.run(options).result
13
+
14
+ expect(result).to be_a(Array)
15
+ expect(result.first).to be_a(Response)
16
+ expect(result.first.name).to eq('response_1')
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Response do
4
+ let(:response_body) do
5
+ {'name' => 'RS-12',
6
+ 'open_from' => '2014-02-19T14:15:49+01:00',
7
+ 'open_till' => '2014-02-20T14:15:49+01:00',
8
+ 'completer_type' => 'patient',
9
+ 'completed_at' => nil,
10
+ 'status' => 'open',
11
+ 'completing_url' => 'http://roqua.dev/client/session/new?token=26aee9a4'}
12
+ end
13
+
14
+ it 'assigns fields to attr_accessors' do
15
+ response = Response.new response_body
16
+ expect(response.name).to eq 'RS-12'
17
+ expect(response.open_from).to eq '2014-02-19T14:15:49+01:00'
18
+ expect(response.open_till).to eq '2014-02-20T14:15:49+01:00'
19
+ expect(response.completed_at).to eq nil
20
+ expect(response.completer_type).to eq 'patient'
21
+ expect(response.status).to eq 'open'
22
+ expect(response.completing_url).to eq 'http://roqua.dev/client/session/new?token=26aee9a4'
23
+ end
24
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+ include Sessions
3
+
4
+ describe BasicAuthSession do
5
+ let(:session) { Fabricate :basic_auth_session }
6
+ let(:response) { double('response', code: 201, parsed_response: 'some_response') }
7
+
8
+ describe '#initialize' do
9
+ it 'sets the rom_host instance attribute' do
10
+ session = BasicAuthSession.new rom_host: 'some_rom_host'
11
+ expect(session.rom_host).to eq('some_rom_host')
12
+ end
13
+
14
+ it 'defaults the rom_host to the ROQUA_ROM_HOST env variable' do
15
+ orginal_env_rom_host = ENV['ROQUA_ROM_HOST']
16
+ ENV['ROQUA_ROM_HOST'] = 'some_env_rom_host'
17
+ session = BasicAuthSession.new
18
+ ENV['ROQUA_ROM_HOST'] = orginal_env_rom_host
19
+ expect(session.rom_host).to eq('some_env_rom_host')
20
+ end
21
+
22
+ it 'sets the username instance variable' do
23
+ session = BasicAuthSession.new username: 'some_username'
24
+ expect(session.username).to eq('some_username')
25
+ end
26
+
27
+ it 'defaults the username to the ROQUA_ROM_KEY env variable' do
28
+ orginal_env_rom_key = ENV['ROQUA_ROM_KEY']
29
+ ENV['ROQUA_ROM_KEY'] = 'some_env_rom_key'
30
+ session = BasicAuthSession.new
31
+ ENV['ROQUA_ROM_KEY'] = orginal_env_rom_key
32
+ expect(session.username).to eq('some_env_rom_key')
33
+ end
34
+
35
+ it 'sets the password instance variable' do
36
+ session = BasicAuthSession.new password: 'some_password'
37
+ expect(session.password).to eq('some_password')
38
+ end
39
+
40
+ it 'defaults the password to the ROQUA_ROM_SECRET env variable' do
41
+ orginal_env_rom_secret = ENV['ROQUA_ROM_SECRET']
42
+ ENV['ROQUA_ROM_SECRET'] = 'some_env_rom_secret'
43
+ session = BasicAuthSession.new
44
+ ENV['ROQUA_ROM_SECRET'] = orginal_env_rom_secret
45
+ expect(session.password).to eq('some_env_rom_secret')
46
+ end
47
+ end
48
+
49
+ describe '#get' do
50
+ it 'performs a get request' do
51
+ expect(HTTParty).to receive(:get).with('http://roqua.dev/api/v1/some_path.json',
52
+ query: {some: 'param'},
53
+ basic_auth: {username: 'some_username', password: 'some_password'})
54
+ .and_return(response)
55
+ session.get '/some_path', some: 'param'
56
+ end
57
+
58
+ it 'throws an error if the reponse is not within the 200 range' do
59
+ allow(response).to receive(:code).and_return(500)
60
+ allow(HTTParty).to receive(:get).and_return(response)
61
+ expect { session.get '/some_path' }.to raise_error(RuntimeError, 'some_response')
62
+ end
63
+
64
+ it 'returns the response' do
65
+ allow(HTTParty).to receive(:get).and_return(response)
66
+ expect(session.get '/some_path').to eq(response)
67
+ end
68
+ end
69
+ end
@@ -1,29 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe StartProtocolSubscription do
4
- let(:options) do
5
- {dossier_id: 'some_dossier_id',
6
- protocol_key: 'some_key'} # nine o'clock
7
- end
4
+ let(:options) { {dossier_id: 'some_dossier_id', protocol_key: 'some_key'} }
5
+ let(:session) { Sessions::BasicAuthSession.new }
6
+ before { allow(Sessions::BasicAuthSession).to receive(:new).and_return session }
8
7
 
9
8
  it 'does a post to the rom protocol_subscription api' do
10
- expect(Base).to receive(:post).with('/protocol_subscriptions', dossier_id: options[:dossier_id],
11
- protocol_key: options[:protocol_key])
12
- .and_return double('response', code: 200)
9
+ expect(session).to receive(:post).with('/protocol_subscriptions', dossier_id: options[:dossier_id],
10
+ protocol_key: options[:protocol_key])
11
+ .and_return double('response', code: 200)
13
12
  StartProtocolSubscription.run(options)
14
13
  end
15
14
 
16
15
  it 'passes in the start_at option when provided' do
17
16
  start_at = Time.now
18
- expect(Base).to receive(:post).with('/protocol_subscriptions', dossier_id: options[:dossier_id],
19
- protocol_key: options[:protocol_key],
20
- start_at: start_at.to_i)
21
- .and_return double('response', code: 200)
17
+ expect(session).to receive(:post).with('/protocol_subscriptions', dossier_id: options[:dossier_id],
18
+ protocol_key: options[:protocol_key],
19
+ start_at: start_at.to_i)
20
+ .and_return double('response', code: 200)
22
21
  StartProtocolSubscription.run(options.merge start_at: start_at)
23
22
  end
24
23
 
25
24
  it 'raises when the response HTTP status is not in the 200 range' do
26
- allow(Base).to receive(:post).and_return double('response', code: 401)
25
+ allow(session).to receive(:post).and_return double('response', code: 401)
27
26
  expect { StartProtocolSubscription.run(options) }.to raise_error
28
27
  end
29
28
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  require 'rspec'
2
+ require 'fabrication'
2
3
  require 'roqua-rom-api'
3
4
  include Roqua::RomApi
5
+ include Roqua::RomApi::Sessions
6
+ include Roqua::RomApi::Results
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-rom-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Esposito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.8'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.14.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.14.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: fabrication
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.9.6
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.9.6
83
111
  description: Provides authenticated access to ROM utilities
84
112
  email: s.esposito@roqua.nl
85
113
  executables: []
@@ -97,15 +125,22 @@ files:
97
125
  - Rakefile
98
126
  - lib/roqua-rom-api.rb
99
127
  - lib/roqua/rom_api.rb
100
- - lib/roqua/rom_api/base.rb
128
+ - lib/roqua/rom_api/list_responses.rb
129
+ - lib/roqua/rom_api/results.rb
130
+ - lib/roqua/rom_api/results/response.rb
131
+ - lib/roqua/rom_api/sessions.rb
132
+ - lib/roqua/rom_api/sessions/basic_auth_session.rb
101
133
  - lib/roqua/rom_api/start_protocol_subscription.rb
102
134
  - lib/roqua/rom_api/version.rb
103
135
  - roqua_rom_api.gemspec
104
- - spec/lib/roqua/rom_api/base_spec.rb
136
+ - spec/fabricators/basic_auth_session_fabricator.rb
137
+ - spec/lib/roqua/rom_api/list_responses_spec.rb
138
+ - spec/lib/roqua/rom_api/results/response_spec.rb
139
+ - spec/lib/roqua/rom_api/sessions/basic_auth_session_spec.rb
105
140
  - spec/lib/roqua/rom_api/start_protocol_subscription_spec.rb
106
141
  - spec/lib/roqua_rom_api_spec.rb
107
142
  - spec/spec_helper.rb
108
- homepage: https://github.com/roqua/rom/blob/master/rom_api/README.md
143
+ homepage: https://github.com/roqua/roqua/blob/master/rom_api/README.md
109
144
  licenses:
110
145
  - MIT
111
146
  metadata: {}
@@ -130,7 +165,10 @@ signing_key:
130
165
  specification_version: 4
131
166
  summary: API wrapper gem around RoQua's ROM API
132
167
  test_files:
133
- - spec/lib/roqua/rom_api/base_spec.rb
168
+ - spec/fabricators/basic_auth_session_fabricator.rb
169
+ - spec/lib/roqua/rom_api/list_responses_spec.rb
170
+ - spec/lib/roqua/rom_api/results/response_spec.rb
171
+ - spec/lib/roqua/rom_api/sessions/basic_auth_session_spec.rb
134
172
  - spec/lib/roqua/rom_api/start_protocol_subscription_spec.rb
135
173
  - spec/lib/roqua_rom_api_spec.rb
136
174
  - spec/spec_helper.rb
@@ -1,50 +0,0 @@
1
- require 'httparty'
2
-
3
- module Roqua
4
- module RomApi
5
- # @api private
6
- class Base
7
- def self.get(url, params = {})
8
- HTTParty.get(api_base + url + '.json', query: params, basic_auth: authentication)
9
- end
10
-
11
- def self.post(url, params = {})
12
- HTTParty.post(api_base + url + '.json', query: params, basic_auth: authentication)
13
- end
14
-
15
- def self.put(url, params = {})
16
- HTTParty.put(api_base + url + '.json', query: params, basic_auth: authentication)
17
- end
18
-
19
- def self.delete(url, params = {})
20
- HTTParty.delete(api_base + url + '.json', query: params, basic_auth: authentication)
21
- end
22
-
23
- private
24
-
25
- def self.rom_host
26
- @roqua_rom_host || ENV['ROQUA_ROM_HOST']
27
- end
28
-
29
- def self.username
30
- @roqua_rom_key || ENV['ROQUA_ROM_KEY']
31
- end
32
-
33
- def self.password
34
- @roqua_rom_secret || ENV['ROQUA_ROM_SECRET']
35
- end
36
-
37
- def self.authentication
38
- {username: username, password: password}
39
- end
40
-
41
- def self.api_path
42
- '/api/v1'
43
- end
44
-
45
- def self.api_base
46
- rom_host + api_path
47
- end
48
- end
49
- end
50
- end
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Roqua
4
- describe RomApi::Base do
5
- let(:url) { '/some/url' }
6
- let(:params) { {some: 'params'} }
7
- before do
8
- RomApi::Base.instance_eval do
9
- @roqua_rom_host = 'http://roqua.dev'
10
- @roqua_rom_key = 'uname'
11
- @roqua_rom_secret = 'pwd'
12
- end
13
- end
14
-
15
- describe '.get' do
16
- it 'performs a get request to a rom_api passing in some parameters' do
17
- expect(HTTParty).to receive(:get).with('http://roqua.dev/api/v1/some/url.json',
18
- query: params,
19
- basic_auth: {username: 'uname', password: 'pwd'})
20
- RomApi::Base.get(url, params)
21
- end
22
- end
23
-
24
- describe '.post' do
25
- it 'performs a get request to a rom_api passing in some parameters' do
26
- expect(HTTParty).to receive(:post).with('http://roqua.dev/api/v1/some/url.json',
27
- query: params,
28
- basic_auth: {username: 'uname', password: 'pwd'})
29
- RomApi::Base.post(url, params)
30
- end
31
- end
32
-
33
- describe '.put' do
34
- it 'performs a get request to a rom_api passing in some parameters' do
35
- expect(HTTParty).to receive(:put).with('http://roqua.dev/api/v1/some/url.json',
36
- query: params,
37
- basic_auth: {username: 'uname', password: 'pwd'})
38
- RomApi::Base.put(url, params)
39
- end
40
- end
41
-
42
- describe '.delete' do
43
- it 'performs a get request to a rom_api passing in some parameters' do
44
- expect(HTTParty).to receive(:delete).with('http://roqua.dev/api/v1/some/url.json',
45
- query: params,
46
- basic_auth: {username: 'uname', password: 'pwd'})
47
- RomApi::Base.delete(url, params)
48
- end
49
- end
50
- end
51
- end