rack-rest-rspec 0.0.2 → 0.0.3

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: 991c3ce92453468607c170e5546f355d3ce1cec02c970651906599af34e3ec0e
4
+ data.tar.gz: 77955b805aed17ad1639496176821b9203dde097228b5aebaf237db9727c8947
5
5
  SHA512:
6
- metadata.gz: 34d61192e292c62781d039766a19aabc8baf5d601aabb626b715303bccce6c1e84bd670f5cf49df83271d727421784c59a9cf2d0f1045165beaeed467dceb920
7
- data.tar.gz: 6e487bec4bc746d540ee2668635f8fa03fdfafc44f24e5811e6fad54527071a5b20b7a761a2d7a5c503f02d5635779d58552e9be2ffb9a90e1e8468f1bace39a
6
+ metadata.gz: 5ba8ada8c6a9d413484b75b71fa368e9e9b59a09f1e903e1d8728a3a49a59f516054937e316b0f6d5948c155ef0cf4b304f55eeace61c479757a15c32497c880
7
+ data.tar.gz: b8ce3dad6fcac708eac0b5f0d50fc140dd5f6e98a4455c5b0e275a9d5a307740ec9f934f0da98297e80baf5f652a98abe8b6f52514e92741a1f07fe4826351a2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -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,25 @@
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
+ 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,7 +1,7 @@
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain GEORGES
@@ -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
@@ -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