rack-rest-rspec 0.0.2 → 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
  SHA256:
3
- metadata.gz: 0d789211724035f08b5ce1adccabadddbd7b5409961ac77e70a7158854564e5f
4
- data.tar.gz: a81ab341b305adf605099f47a1af7af0841b8902260b2d915d911442dfebee88
3
+ metadata.gz: 4b81fa23d24317edb1b4fa127c8fa4419ff7601cd7e58b83199bba10a41d0f8d
4
+ data.tar.gz: 4b7f8469e2b0bf10f7ac2fb4c28337ad675d6565d7756cf5976f30bd048b2605
5
5
  SHA512:
6
- metadata.gz: 34d61192e292c62781d039766a19aabc8baf5d601aabb626b715303bccce6c1e84bd670f5cf49df83271d727421784c59a9cf2d0f1045165beaeed467dceb920
7
- data.tar.gz: 6e487bec4bc746d540ee2668635f8fa03fdfafc44f24e5811e6fad54527071a5b20b7a761a2d7a5c503f02d5635779d58552e9be2ffb9a90e1e8468f1bace39a
6
+ metadata.gz: '0538d585f4ff1c7935b53203818eda3d6ca84928df1b03add64f29211c442933f527d938e9ef7516d76c4a4a24aabb90c5f903e62c0d9ce510b4147654d2ae6a'
7
+ data.tar.gz: cd5bd2713cfd2314fa146c554d44b417252cbfe8b1fc2f66ec9666742e8220c390fb26508ec85abfb94278798362d9b61876f77db5efe24907c6ce2b24795b15
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.4
@@ -0,0 +1,17 @@
1
+ require 'pstore'
2
+
3
+ def memorize(options)
4
+
5
+ $store = PStore.new("/tmp/data.pstore")
6
+ $store.transaction do
7
+ options.each do |key,val|
8
+ $store[key] = val
9
+ end
10
+ $store.commit
11
+ end
12
+ end
13
+
14
+ def retrieve(key)
15
+ $store = PStore.new("/tmp/data.pstore")
16
+ return $store.transaction { $store[key] }
17
+ end
@@ -0,0 +1,5 @@
1
+ require 'yaml'
2
+
3
+ def get_file(file)
4
+ return YAML.load(File::readlines(file).join)
5
+ end
@@ -0,0 +1,29 @@
1
+ require 'forwardable'
2
+
3
+
4
+ class RestService
5
+ extend Forwardable
6
+
7
+
8
+ attr_reader :path
9
+ attr_reader :service
10
+ attr_reader :browser
11
+
12
+ def initialize(params = {})
13
+ defaults = {
14
+ :service => Sinatra::Base,
15
+ :path => '/'
16
+ }
17
+ defaults.merge! params
18
+ @service = defaults[:service]
19
+ @path = defaults[:path]
20
+ @browser = Rack::Test::Session.new(Rack::MockSession.new(@service))
21
+ end
22
+
23
+ def_delegators :@browser, :get, :post, :put, :delete
24
+
25
+ def returned_data
26
+ return JSON::parse(@browser.last_response.body, symbolize_names: true)
27
+ end
28
+
29
+ end
@@ -2,6 +2,6 @@ require 'rspec'
2
2
  require 'rack/test'
3
3
  require 'rspec/expectations'
4
4
 
5
- require_relative 'lib/restcrudservice.rb'
5
+ require_relative 'lib/rest_service.rb'
6
6
  require_relative 'helpers/init.rb'
7
7
  require_relative 'matchers/init.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-rest-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain GEORGES
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-13 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roodi
@@ -119,9 +119,10 @@ files:
119
119
  - README.md
120
120
  - Rakefile
121
121
  - VERSION
122
- - lib/rack-rest-rspec/helpers/hash.rb
123
122
  - lib/rack-rest-rspec/helpers/init.rb
124
- - lib/rack-rest-rspec/lib/restcrudservice.rb
123
+ - lib/rack-rest-rspec/helpers/memorizer.rb
124
+ - lib/rack-rest-rspec/helpers/yml.rb
125
+ - lib/rack-rest-rspec/lib/rest_service.rb
125
126
  - lib/rack-rest-rspec/matchers/be_correctly_sent.rb
126
127
  - lib/rack-rest-rspec/matchers/init.rb
127
128
  - lib/rack-rest-rspec/matchers/respond_a_collection_of_record.rb
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubygems_version: 3.1.2
156
+ rubygems_version: 3.4.19
156
157
  signing_key:
157
158
  specification_version: 4
158
159
  summary: 'Rack-rest-rspec: RSpec Matchers for REST Rack webservice'
@@ -1,14 +0,0 @@
1
- class Hash
2
- def symbolize!
3
- self.keys.each do |key|
4
- self[key.to_sym] = self.delete(key)
5
- end
6
- end
7
-
8
- def stringify!
9
- self.keys.each do |key|
10
- self[key.to_s] = self.delete(key)
11
- end
12
- return ahash
13
- end
14
- end
@@ -1,45 +0,0 @@
1
- class RestCRUDService
2
-
3
- attr_reader :path
4
- attr_reader :object
5
- attr_reader :browser
6
-
7
- def initialize(params = {})
8
- defaults = {
9
- :path => '/api/',
10
- :object => '',
11
- :browser => Rack::Test::Session.new(Rack::MockSession.new(Sinatra::Application))
12
- }
13
- defaults.merge! params
14
- @path = defaults[:path]
15
- @object = defaults[:object]
16
- @browser = defaults[:browser]
17
- end
18
-
19
- def url
20
- return "#{@path}/#{@object}"
21
- end
22
-
23
- def create_record _data
24
- return @browser.post self.url, _data
25
- end
26
-
27
- def retrieve_all_records
28
- return @browser.get self.url
29
- end
30
-
31
- def retrieve_record _nb
32
- return @browser.get "#{self.url}/#{_nb}"
33
- end
34
-
35
-
36
- def update_record _nb,_data
37
- return @browser.put "#{self.url}/#{_nb}", _data
38
- end
39
-
40
-
41
- def destroy_record _nb
42
- return @browser.delete "#{self.url}/#{_nb}"
43
- end
44
-
45
- end