lws 0.2.1 → 0.3.0.beta3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd9b57026c373eec38df4b746c643dad33a72b24
4
+ data.tar.gz: 51c458c026bf0124bc4f96b9c10314ddf95c8a87
5
+ SHA512:
6
+ metadata.gz: f8e4f3e34688a00da22cfe01c86c31d09af98050345bd132ff5e354e895501a9f1f945a669ba54215597cf44cf10ed534b95ee3daee49471b94b215ff804c2a7
7
+ data.tar.gz: ab76f33ee799fbe4edc200239dd809cd9a0ac2bfd442462d4cb04ace380b67187c02ba4aa8a027a24d088b95853b1704bb1148c559bbe52c77d0754f317e6d46
data/Rakefile CHANGED
@@ -15,4 +15,50 @@ YARD::Rake::YardocTask.new do |t|
15
15
  "--title", "LeftClick Web Services Documentation"]
16
16
  end
17
17
 
18
+ desc "Insert/update copyright headers in all script files"
19
+ task :copyright do
20
+ copyright_text = File.read("copyright.txt")
21
+
22
+ Dir["**/*.{pl,perl,rb,sh}"].sort.each do |script_file|
23
+ if File.symlink? script_file
24
+ puts "I: script file is a symlink: #{script_file}, skipping!"
25
+ next
26
+ end
27
+
28
+ puts "I: processing script file #{script_file}"
29
+ lines = File.readlines(script_file)
30
+ new_script_file = script_file + ".new"
31
+ new_perm = File.stat(script_file).mode
32
+ File.open(new_script_file, "w", new_perm) do |new_file|
33
+ found_copyright = false
34
+ removing_old_copyright = false
35
+ lines.each do |line|
36
+ if found_copyright
37
+ new_file.print line
38
+ next
39
+ end
40
+
41
+ if line =~ /^#..+/
42
+ new_file.print line unless removing_old_copyright
43
+ next
44
+ end
45
+ if line =~ /^([^#]|$)/
46
+ new_file.print copyright_text
47
+ new_file.puts unless line.chomp.empty?
48
+ removing_old_copyright = false
49
+ found_copyright = true
50
+ elsif line =~ /^\#$/
51
+ removing_old_copyright = true
52
+ next
53
+ else
54
+ raise "got unexpected line in header: #{line.chomp}"
55
+ end
56
+
57
+ new_file.print line
58
+ end
59
+ end
60
+ File.rename(new_script_file, script_file)
61
+ end
62
+ end
63
+
18
64
  task default: :test
data/copyright.txt ADDED
@@ -0,0 +1,9 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
data/lib/lws.rb CHANGED
@@ -1,8 +1,21 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "faraday_middleware"
2
12
  require "hashie"
3
13
  require "her"
14
+ require "multi_json"
4
15
  require "pp"
16
+ require "webmock"
5
17
 
18
+ require "lws/stubbing"
6
19
  require "lws/version"
7
20
 
8
21
  # = Main LeftClick web services module
@@ -81,6 +94,9 @@ module LWS
81
94
  # @return [Config] the API configuration for the web services
82
95
  mattr_reader :config
83
96
 
97
+ # @return [Stubbing] the stubbing setup for the web service
98
+ mattr_reader :stubbing
99
+
84
100
  # = The API configuration class
85
101
  #
86
102
  # @note Either the API token or API token middleware needs to be
@@ -112,14 +128,19 @@ module LWS
112
128
  # @return [Boolean] whether to show HTTP debug messages
113
129
  property :http_debug, default: false
114
130
 
131
+ #@!attribute json_debug
132
+ # @return [Boolean] whether to show JSON debug messages
133
+ property :json_debug, default: false
134
+
115
135
  #@!attribute logger
116
136
  # @return [#fatal, #error, #warn, #info, #debug] the logger object
117
137
  # (Rails logger, Logger, etc.)
118
138
  property :logger
119
139
 
120
- #@!attribute json_debug
121
- # @return [Boolean] whether to show JSON debug messages
122
- property :json_debug, default: false
140
+ #@!attrbute stubbing
141
+ # @return [String] the path to a directory with stubbing fixtures
142
+ # (setting this enables the default stubs)
143
+ property :stubbing
123
144
  end
124
145
 
125
146
  # Sets up the application API libraries using the provided
@@ -151,6 +172,7 @@ module LWS
151
172
  end
152
173
 
153
174
  load_app_modules
175
+ load_stubbing
154
176
 
155
177
  return self
156
178
  end
@@ -185,10 +207,32 @@ module LWS
185
207
  # @return [Array<Symbol>] the apps that were loaded
186
208
  # (see also {SUPPORTED_APPS})
187
209
  def self.load_app_modules
210
+ @app_modules = {}
188
211
  app_module_path = File.dirname(__FILE__)
189
- SUPPORTED_APPS.each do |app|
190
- load "#{app_module_path}/lws/#{app}.rb"
212
+ SUPPORTED_APPS.each do |app_name|
213
+ load "#{app_module_path}/lws/#{app_name}.rb"
214
+ @app_modules[app_name] = LWS.const_get(app_name.to_s.capitalize)
191
215
  end
192
216
  end
193
217
 
218
+ # (Re)load the stubbing if enabled (usually done by {.setup}).
219
+ #
220
+ # @return [Stubbing, nil] the stubbing object or +nil+ if disabled
221
+ def self.load_stubbing
222
+ if config.stubbing.present?
223
+ @@stubbing = Stubbing.new(config.stubbing)
224
+ else
225
+ @@stubbing.disable! if @@stubbing
226
+ @@stubbing = nil
227
+ end
228
+ end
229
+
230
+ # Returns the app module for the given app name.
231
+ #
232
+ # @param [String, Symbol] the app name
233
+ # @return [Module] the app module
234
+ def self.app_module(app_name)
235
+ @app_modules[app_name.to_sym]
236
+ end
237
+
194
238
  end # module LWS
data/lib/lws/auth.rb CHANGED
@@ -1,4 +1,14 @@
1
1
  # = The auth app module
2
+ #
3
+ # Copyright © 2016 LeftClick B.V.
4
+ #
5
+ # This software is property of LeftClick B.V. and cannot be redistributed
6
+ # and/or modified without permission. The software or any of its parts
7
+ # cannot be used for any other purposes than the LeftClick services and
8
+ # only during a valid license subscription. For more information, please
9
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
10
+ # Netherlands, info@leftclick.eu, +31492-782120.
11
+
2
12
  module LWS::Auth
3
13
 
4
14
  unless defined? ENDPOINT
data/lib/lws/generic.rb CHANGED
@@ -1,6 +1,16 @@
1
1
  # = The generic app module
2
2
  #
3
3
  # This module contains classes that are present in all applications.
4
+ #
5
+ # Copyright © 2016 LeftClick B.V.
6
+ #
7
+ # This software is property of LeftClick B.V. and cannot be redistributed
8
+ # and/or modified without permission. The software or any of its parts
9
+ # cannot be used for any other purposes than the LeftClick services and
10
+ # only during a valid license subscription. For more information, please
11
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
12
+ # Netherlands, info@leftclick.eu, +31492-782120.
13
+
4
14
  module LWS::Generic
5
15
 
6
16
  # = The generic model class
data/lib/lws/maps.rb CHANGED
@@ -1,4 +1,14 @@
1
1
  # = The maps app module
2
+ #
3
+ # Copyright © 2016 LeftClick B.V.
4
+ #
5
+ # This software is property of LeftClick B.V. and cannot be redistributed
6
+ # and/or modified without permission. The software or any of its parts
7
+ # cannot be used for any other purposes than the LeftClick services and
8
+ # only during a valid license subscription. For more information, please
9
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
10
+ # Netherlands, info@leftclick.eu, +31492-782120.
11
+
2
12
  module LWS::Maps
3
13
 
4
14
  unless defined? ENDPOINT
data/lib/lws/presence.rb CHANGED
@@ -1,4 +1,14 @@
1
1
  # = The presence app module
2
+ #
3
+ # Copyright © 2016 LeftClick B.V.
4
+ #
5
+ # This software is property of LeftClick B.V. and cannot be redistributed
6
+ # and/or modified without permission. The software or any of its parts
7
+ # cannot be used for any other purposes than the LeftClick services and
8
+ # only during a valid license subscription. For more information, please
9
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
10
+ # Netherlands, info@leftclick.eu, +31492-782120.
11
+
2
12
  module LWS::Presence
3
13
 
4
14
  unless defined? ENDPOINT
@@ -0,0 +1,122 @@
1
+ module LWS
2
+
3
+ # = Class that regulates request stubbing based on a tree of fixtures
4
+ #
5
+ # Stubbing is enabled when a path is provided to a tree of fixture objects.
6
+ # These fixture files should have the form:
7
+ #
8
+ # app_name:
9
+ # /model/1:
10
+ # default:
11
+ # id: 1
12
+ # attr: value
13
+ # test:
14
+ # id: 1
15
+ # attr: other_value
16
+ #
17
+ # When initialized, for all apps, for all paths, the default stub is
18
+ # loaded if it exists.
19
+ class Stubbing
20
+
21
+ include WebMock::API
22
+
23
+ # Creates a new request stubbing object.
24
+ #
25
+ # Also stubs requests for all apps for all paths, if a default stub
26
+ # exists.
27
+ #
28
+ # @param [Pathname, String] path to the directory with the fixtures.
29
+ def initialize(stubs_dir)
30
+ # Set up WebMock
31
+ WebMock.enable!
32
+ @stubs = {}
33
+
34
+ # Load the fixtures
35
+ raise "not a valid stubs directory" unless File.directory? stubs_dir
36
+ @fixtures = {}
37
+ Dir["#{stubs_dir}/**/*.yml"].each do |yml_file|
38
+ yml = YAML.load_file(yml_file)
39
+ @fixtures.deep_merge! yml
40
+ end
41
+
42
+ # Set request stubs for the default fixtures
43
+ @fixtures.each do |app_name, entries|
44
+ entries.each do |path, fixtures|
45
+ fixtures.each do |fixture_name, fixture|
46
+ if fixture_name == "default"
47
+ replace(:get, app_name, path, fixture_name)
48
+ replace(:delete, app_name, path, fixture_name)
49
+ replace(:put, app_name, path, fixture_name)
50
+ replace(:patch, app_name, path, fixture_name)
51
+ post_uri = Pathname.new(path).parent.to_s
52
+ if @fixtures.dig(app_name.to_s, post_uri, "post_default")
53
+ replace(:post, app_name, post_uri, "post_default")
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ # Disables all request stubbing.#
62
+ #
63
+ # This should be used when the stubbing is not used anymore.
64
+ def disable!
65
+ WebMock.disable!
66
+ end
67
+
68
+ # Replace a request stub for the given HTTP method, app name, path
69
+ # by the fixture with the given name.
70
+ #
71
+ # @note For the HTTP method +:delete+, the response status is set to 204.
72
+ #
73
+ # @param method [Symbol] the HTTP method (+:get+, +:put+, etc.)
74
+ # @param app_name [Symbol] the app name (see {::SUPPORTED_APPS})
75
+ # @param path [String] the path part of the request URI
76
+ # @param fixture_name [Symbol] the name of the fixture to use as stub
77
+ # response body
78
+ # @raise if the fixture name could not be found for the given app name
79
+ # and path
80
+ def replace(method, app_name, path, fixture_name = :default)
81
+ fixture = if fixture_name
82
+ @fixtures.dig(app_name.to_s, path, fixture_name.to_s)
83
+ else
84
+ {}
85
+ end
86
+ raise "fixture #{fixture_name} not found (app: #{app_name}, URI: #{path})" unless fixture
87
+ app_endpoint_url = LWS.app_module(app_name).api.options[:url]
88
+ app_endpoint_uri = URI.parse(app_endpoint_url)
89
+ app_endpoint_uri.path = path
90
+ full_uri = "%s://%s:%s%s" % [app_endpoint_uri.scheme,
91
+ app_endpoint_uri.host,
92
+ app_endpoint_uri.port,
93
+ app_endpoint_uri.path]
94
+ full_uri += "?#{app_endpoint_uri.query}" if app_endpoint_uri.query
95
+ full_uri += "##{app_endpoint_uri.fragment}" if app_endpoint_uri.fragment
96
+
97
+ @stubs[[method, app_name.to_sym, path]] =
98
+ if method == :delete
99
+ stub_request(method, full_uri)
100
+ .to_return(body: MultiJson.dump(fixture), status: 204)
101
+ else
102
+ stub_request(method, full_uri)
103
+ .to_return(body: MultiJson.dump(fixture))
104
+ end
105
+ end
106
+
107
+ # Removes a request stub for the given HTTP method, app name and path.
108
+ #
109
+ # @param method [Symbol] the HTTP method (+:get+, +:put+, etc.)
110
+ # @param app_name [Symbol] the app name (see {::SUPPORTED_APPS})
111
+ # @param path [String] the path part of the request URI
112
+ # @raise if there is not request stub for the given HTTP method,
113
+ # app name and path
114
+ def remove(method, app_name, path)
115
+ request_stub = @stubs.delete([method, app_name, path])
116
+ raise "no such request stub" unless request_stub
117
+ remove_request_stub request_stub
118
+ end
119
+
120
+ end
121
+
122
+ end
data/lib/lws/version.rb CHANGED
@@ -1,7 +1,17 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  module LWS
2
12
 
3
13
  # The LWS library version.
4
14
  # @note This is not the API version!
5
- VERSION = '0.2.1'
15
+ VERSION = '0.3.0.beta3'
6
16
 
7
17
  end
data/lws.gemspec CHANGED
@@ -14,7 +14,8 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_runtime_dependency "faraday_middleware", ">= 0.10.0", "< 1.0"
16
16
  s.add_runtime_dependency 'hashie'
17
- s.add_runtime_dependency 'her', '~> 0.8.1'
17
+ s.add_runtime_dependency 'her', '~> 0.8.2'
18
+ s.add_runtime_dependency 'webmock', '~> 2.1.0'
18
19
 
19
20
  s.add_development_dependency 'hashie'
20
21
  s.add_development_dependency 'her', '~> 0.8.1'
@@ -0,0 +1,67 @@
1
+ auth:
2
+ /tokens/test:
3
+ default: &token_test
4
+ id: 1
5
+ token: test
6
+ account_id: 1
7
+ device_id: null
8
+ user_id: 1
9
+
10
+ /tokens/test_device:
11
+ default:
12
+ id: 1
13
+ token: test_device
14
+ account_id: 1
15
+ device_id: 1
16
+ user_id: null
17
+
18
+ /tokens:
19
+ default:
20
+ - *token_test
21
+ post_default: *token_test
22
+
23
+ /accounts/1:
24
+ default: &account_1
25
+ id: 1
26
+ company_id: 1
27
+ manages_company_ids: [1]
28
+ language: nl
29
+ devices: []
30
+
31
+ /accounts:
32
+ default:
33
+ - *account_1
34
+ post_default: *account_1
35
+
36
+ /companies/1:
37
+ default: &company_1
38
+ id: 1
39
+ contact_person_id: 1
40
+ parent_id: null
41
+
42
+ /companies:
43
+ default:
44
+ - *company_1
45
+ post_default: *company_1
46
+
47
+ /devices/1:
48
+ default: &device_1
49
+ id: 1
50
+ account_id: 1
51
+ name: Test Device
52
+
53
+ /devices:
54
+ default:
55
+ - *device_1
56
+ post_default: *device_1
57
+
58
+ /users/1:
59
+ default: &user_1
60
+ id: 1
61
+ account_id: 1
62
+ email: test.user@leftclick.eu
63
+
64
+ /users:
65
+ default:
66
+ - *user_1
67
+ post_default: *user_1
@@ -0,0 +1,31 @@
1
+ auth:
2
+ /accounts/1/apps:
3
+ default:
4
+ - id: 1
5
+ app_key: rails-skel
6
+ permissions:
7
+ - key: configuration.read
8
+ value: "true"
9
+ - key: configuration.write
10
+ value: "true"
11
+ - key: task.read
12
+ value: "true"
13
+ - key: task.write
14
+ value: "true"
15
+ generic:
16
+ - id: 1
17
+ app_key: test
18
+ permissions:
19
+ - key: test.flag
20
+ value: "true"
21
+ - key: test.select
22
+ value: 1
23
+ - key: test.custom_select
24
+ value: "yes"
25
+ - key: test.multi_select
26
+ value: [1, 2]
27
+ no_apps: []
28
+ no_perms:
29
+ - id: 1
30
+ app_key: rails-skel
31
+ permissions: []
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "test_helper"
2
12
 
3
13
  class WorkingTokenAuthenticator < Faraday::Middleware
data/test/test_auth.rb CHANGED
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "test_helper"
2
12
 
3
13
  class TestAuthAccount < MiniTest::Unit::TestCase
data/test/test_caching.rb CHANGED
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "test_helper"
2
12
 
3
13
  class TestCaching < MiniTest::Unit::TestCase
data/test/test_generic.rb CHANGED
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "test_helper"
2
12
 
3
13
  class TestGenericConfiguration < MiniTest::Unit::TestCase
data/test/test_helper.rb CHANGED
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "logger"
2
12
  require "lws"
3
13
  require "minitest/autorun"
data/test/test_logger.rb CHANGED
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "test_helper"
2
12
 
3
13
  class TestLogger < MiniTest::Unit::TestCase
data/test/test_maps.rb CHANGED
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "test_helper"
2
12
 
3
13
  class TestMapsMap < MiniTest::Unit::TestCase
@@ -1,3 +1,13 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
1
11
  require "test_helper"
2
12
 
3
13
  class TestPresencePerson < MiniTest::Unit::TestCase
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright © 2016 LeftClick B.V.
3
+ #
4
+ # This software is property of LeftClick B.V. and cannot be redistributed
5
+ # and/or modified without permission. The software or any of its parts
6
+ # cannot be used for any other purposes than the LeftClick services and
7
+ # only during a valid license subscription. For more information, please
8
+ # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
+ # Netherlands, info@leftclick.eu, +31492-782120.
10
+
11
+ require "test_helper"
12
+
13
+ class TestStubbing < MiniTest::Unit::TestCase
14
+
15
+ def setup
16
+ # Redo the LWS setup with cache
17
+ reconfigure(stubbing: File.expand_path("../fixtures", __FILE__))
18
+ end
19
+
20
+ def teardown
21
+ reconfigure
22
+ end
23
+
24
+ def test_working_stubbing
25
+ assert_raises WebMock::NetConnectNotAllowedError do
26
+ LWS::Auth::Token.find("not_stubbed")
27
+ end
28
+ assert LWS.stubbing
29
+ assert LWS::Auth::Token.find("test")
30
+ end
31
+
32
+ def test_replace_stub
33
+ result = LWS.stubbing.replace(:get, :auth, "/accounts/1/apps", :generic)
34
+ assert result
35
+ end
36
+
37
+ def test_remove_stub
38
+ stub = LWS.stubbing.remove(:get, :auth, "/devices/1")
39
+ assert_nil stub
40
+ assert_raises RuntimeError do
41
+ LWS.stubbing.remove(:get, :auth, "/devices/1")
42
+ end
43
+ end
44
+
45
+ end
metadata CHANGED
@@ -1,99 +1,137 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.3.0.beta3
6
5
  platform: ruby
7
6
  authors:
8
7
  - LeftClick B.V.
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-08-15 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: faraday_middleware
16
- requirement: &17465740 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.10.0
22
- - - <
20
+ - - "<"
23
21
  - !ruby/object:Gem::Version
24
22
  version: '1.0'
25
23
  type: :runtime
26
24
  prerelease: false
27
- version_requirements: *17465740
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.10.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
28
33
  - !ruby/object:Gem::Dependency
29
34
  name: hashie
30
- requirement: &17463360 !ruby/object:Gem::Requirement
31
- none: false
35
+ requirement: !ruby/object:Gem::Requirement
32
36
  requirements:
33
- - - ! '>='
37
+ - - ">="
34
38
  - !ruby/object:Gem::Version
35
39
  version: '0'
36
40
  type: :runtime
37
41
  prerelease: false
38
- version_requirements: *17463360
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
39
47
  - !ruby/object:Gem::Dependency
40
48
  name: her
41
- requirement: &17461560 !ruby/object:Gem::Requirement
42
- none: false
49
+ requirement: !ruby/object:Gem::Requirement
43
50
  requirements:
44
- - - ~>
51
+ - - "~>"
45
52
  - !ruby/object:Gem::Version
46
- version: 0.8.1
53
+ version: 0.8.2
47
54
  type: :runtime
48
55
  prerelease: false
49
- version_requirements: *17461560
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.8.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: webmock
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 2.1.0
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 2.1.0
50
75
  - !ruby/object:Gem::Dependency
51
76
  name: hashie
52
- requirement: &17460740 !ruby/object:Gem::Requirement
53
- none: false
77
+ requirement: !ruby/object:Gem::Requirement
54
78
  requirements:
55
- - - ! '>='
79
+ - - ">="
56
80
  - !ruby/object:Gem::Version
57
81
  version: '0'
58
82
  type: :development
59
83
  prerelease: false
60
- version_requirements: *17460740
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
61
89
  - !ruby/object:Gem::Dependency
62
90
  name: her
63
- requirement: &17459860 !ruby/object:Gem::Requirement
64
- none: false
91
+ requirement: !ruby/object:Gem::Requirement
65
92
  requirements:
66
- - - ~>
93
+ - - "~>"
67
94
  - !ruby/object:Gem::Version
68
95
  version: 0.8.1
69
96
  type: :development
70
97
  prerelease: false
71
- version_requirements: *17459860
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.8.1
72
103
  - !ruby/object:Gem::Dependency
73
104
  name: minitest
74
- requirement: &17459240 !ruby/object:Gem::Requirement
75
- none: false
105
+ requirement: !ruby/object:Gem::Requirement
76
106
  requirements:
77
- - - ! '>='
107
+ - - ">="
78
108
  - !ruby/object:Gem::Version
79
109
  version: '0'
80
110
  type: :development
81
111
  prerelease: false
82
- version_requirements: *17459240
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
83
117
  - !ruby/object:Gem::Dependency
84
118
  name: rake
85
- requirement: &17474160 !ruby/object:Gem::Requirement
86
- none: false
119
+ requirement: !ruby/object:Gem::Requirement
87
120
  requirements:
88
- - - ~>
121
+ - - "~>"
89
122
  - !ruby/object:Gem::Version
90
123
  version: 0.9.2
91
124
  type: :development
92
125
  prerelease: false
93
- version_requirements: *17474160
94
- description: ! "This library for Ruby provides access to the LeftClick\n web services/applications
95
- using a model-based structure that abstracts from API calls\n using the available
96
- REST interfaces."
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 0.9.2
131
+ description: |-
132
+ This library for Ruby provides access to the LeftClick
133
+ web services/applications using a model-based structure that abstracts from API calls
134
+ using the available REST interfaces.
97
135
  email:
98
136
  - gem@leftclick.eu
99
137
  executables:
@@ -101,18 +139,22 @@ executables:
101
139
  extensions: []
102
140
  extra_rdoc_files: []
103
141
  files:
104
- - .gitignore
142
+ - ".gitignore"
105
143
  - Gemfile
106
144
  - README.rdoc
107
145
  - Rakefile
108
146
  - bin/lwsconsole
147
+ - copyright.txt
109
148
  - lib/lws.rb
110
149
  - lib/lws/auth.rb
111
150
  - lib/lws/generic.rb
112
151
  - lib/lws/maps.rb
113
152
  - lib/lws/presence.rb
153
+ - lib/lws/stubbing.rb
114
154
  - lib/lws/version.rb
115
155
  - lws.gemspec
156
+ - test/fixtures/auth.yml
157
+ - test/fixtures/permissions.yml
116
158
  - test/test_api_token_middleware.rb
117
159
  - test/test_auth.rb
118
160
  - test/test_caching.rb
@@ -121,31 +163,33 @@ files:
121
163
  - test/test_logger.rb
122
164
  - test/test_maps.rb
123
165
  - test/test_presence.rb
166
+ - test/test_stubbing.rb
124
167
  homepage: https://leftclick.eu/
125
168
  licenses: []
169
+ metadata: {}
126
170
  post_install_message:
127
171
  rdoc_options: []
128
172
  require_paths:
129
173
  - lib
130
174
  required_ruby_version: !ruby/object:Gem::Requirement
131
- none: false
132
175
  requirements:
133
- - - ! '>='
176
+ - - ">="
134
177
  - !ruby/object:Gem::Version
135
178
  version: '0'
136
179
  required_rubygems_version: !ruby/object:Gem::Requirement
137
- none: false
138
180
  requirements:
139
- - - ! '>='
181
+ - - ">"
140
182
  - !ruby/object:Gem::Version
141
- version: '0'
183
+ version: 1.3.1
142
184
  requirements: []
143
185
  rubyforge_project:
144
- rubygems_version: 1.8.11
186
+ rubygems_version: 2.5.1
145
187
  signing_key:
146
- specification_version: 3
188
+ specification_version: 4
147
189
  summary: LeftClick web services library for Ruby
148
190
  test_files:
191
+ - test/fixtures/auth.yml
192
+ - test/fixtures/permissions.yml
149
193
  - test/test_api_token_middleware.rb
150
194
  - test/test_auth.rb
151
195
  - test/test_caching.rb
@@ -154,4 +198,4 @@ test_files:
154
198
  - test/test_logger.rb
155
199
  - test/test_maps.rb
156
200
  - test/test_presence.rb
157
- has_rdoc:
201
+ - test/test_stubbing.rb