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 +4 -4
- data/VERSION +1 -1
- data/lib/rack-rest-rspec/helpers/memorizer.rb +17 -0
- data/lib/rack-rest-rspec/helpers/yml.rb +5 -0
- data/lib/rack-rest-rspec/lib/rest_service.rb +29 -0
- data/lib/rack-rest-rspec/prepare.rb +1 -1
- metadata +6 -5
- data/lib/rack-rest-rspec/helpers/hash.rb +0 -14
- data/lib/rack-rest-rspec/lib/restcrudservice.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b81fa23d24317edb1b4fa127c8fa4419ff7601cd7e58b83199bba10a41d0f8d
|
4
|
+
data.tar.gz: 4b7f8469e2b0bf10f7ac2fb4c28337ad675d6565d7756cf5976f30bd048b2605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0538d585f4ff1c7935b53203818eda3d6ca84928df1b03add64f29211c442933f527d938e9ef7516d76c4a4a24aabb90c5f903e62c0d9ce510b4147654d2ae6a'
|
7
|
+
data.tar.gz: cd5bd2713cfd2314fa146c554d44b417252cbfe8b1fc2f66ec9666742e8220c390fb26508ec85abfb94278798362d9b61876f77db5efe24907c6ce2b24795b15
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
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,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
|
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.
|
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:
|
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/
|
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.
|
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,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
|