rack-rest-rspec 0.0.5 → 1.0.0

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: 71ef01252294ee9e868956d7022e23990f81557cc4025940da96b2783b4c2d04
4
- data.tar.gz: ab4553953c6cb4bc1f428741133889fa3defd63fa4309be087db6ba95b7f9cb8
3
+ metadata.gz: b5eeab5a42b95fad3925b35beb70d00b9b5ba87cb0813e42d45dd1f7f3f9f7da
4
+ data.tar.gz: bc8e33415d1fd2ebc6b9f9a4095a575c0f37c5d24792355c9c914082edeefcf6
5
5
  SHA512:
6
- metadata.gz: 7e2fe753acd7375aa77f1672768b6c150e68df0a1f2ff5d58f68fba12c0290ea7906510b6ca29d2d877aaf4b185e80a0a50e78955c62b867b8e538445a434bfb
7
- data.tar.gz: f6b5c79124bcf35173281e7b66ce0a22348d3892b7b8ff547d15c3ed1018541550712fdf97102e30e0f55fe013b10e5aca8204f67844c7ff6c282c2e083dc49e
6
+ metadata.gz: a0204cb39a36df05af11f9de67cfa808d5754861de3ca86931c848a974b2f6d6c625f44e90adfdb636f708291216dfea3b59e91f651d5b53fa5642b29754e58c
7
+ data.tar.gz: 955bb74528ca5ec0d4945fd53564990f1ee0d9c19be86f669137dbdabeef0bedff4f99b3e0c871ba36c2b15b23512d24e4800cc18ec439829f4c354d98181afb
@@ -0,0 +1,6 @@
1
+ path
2
+ returned_data
3
+ service
4
+ get_file
5
+ memorize
6
+ retrieve
@@ -0,0 +1,23 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.2.3
14
+ - name: Getting dependencies (Bundle)
15
+ run: |
16
+ gem install bundler -v 2.2.3
17
+ bundle install
18
+ - name: Running test Rspec
19
+ run: |
20
+ bundle exec rake
21
+ - name: Running CVE security audit
22
+ run: |
23
+ bundle exec rake audit
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,44 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ # This configuration was generated by
5
+ # `rubocop --auto-gen-config`
6
+ # on 2024-05-03 14:08:48 UTC using RuboCop version 1.63.4.
7
+ # The point is for the user to remove these configuration records
8
+ # one by one as the offenses are removed from the code base.
9
+ # Note that changes in the inspected code, or installation of new
10
+ # versions of RuboCop, may require this file to be generated again.
11
+
12
+ # Offense count: 2
13
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
14
+ # AllowedMethods: refine
15
+ Metrics/BlockLength:
16
+ Max: 32
17
+
18
+ Gemspec/DevelopmentDependencies:
19
+ Enabled: false
20
+
21
+ # Offense count: 3
22
+ # Configuration parameters: AllowedConstants.
23
+ Style/Documentation:
24
+ Exclude:
25
+ - 'spec/**/*'
26
+ - 'test/**/*'
27
+ - 'lib/rack-rest-rspec/lib/rest_service.rb'
28
+ - 'lib/rack-rest-rspec/version.rb'
29
+ - 'samples/app.rb'
30
+
31
+ # Offense count: 23
32
+ # Configuration parameters: AllowedVariables.
33
+ Style/GlobalVars:
34
+ Exclude:
35
+ - 'lib/rack-rest-rspec/helpers/memorizer.rb'
36
+ - 'samples/spec/api_spec.rb'
37
+ - 'spec/api_spec.rb'
38
+
39
+ # Offense count: 1
40
+ # This cop supports safe autocorrection (--autocorrect).
41
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
42
+ # URISchemes: http, https
43
+ Layout/LineLength:
44
+ Max: 122
data/Gemfile CHANGED
@@ -1,20 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
-
7
- group :test, :development do
8
- gem "roodi", "~> 5.0"
9
- gem "rake", "~> 13.0"
10
- gem "code_statistics", "~> 0.2.13"
11
- gem "rspec", "~> 3.11"
12
- gem "yard", "~> 0.9.28"
13
- gem "yard-rspec", "~> 0.1"
14
- end
15
-
16
- gem "rack-test", "~> 2.0"
17
-
18
-
19
-
20
- gem "version", "~> 1.1"
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Romain GEORGES
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -130,16 +130,110 @@ Finished in 0.01585 seconds (files took 0.25845 seconds to load)
130
130
 
131
131
  ## Available matchers :
132
132
 
133
- * be_correctly_send : check if return is HTTP valid
134
- * respond_with_a_collection_of_record OPTIONAL[root: <:symbol>] : check if the return is a JSON Array, could be chroot with root:
135
- * respond_a_record OPTIONAL[root: <:symbol>] : check if the return is a JSON Hash, could be chroot with root:
136
- * respond_with_collection size: <Integer> OPTIONAL[root: <:symbol>] : check if the collection have the good size, could be chroot with root:
137
- * respond_with data: <Object> OPTIONAL[root: <:symbol>] : check if the return match the given object, could be chroot with root:
138
- * respond_with_status <Integer> : check if the HTTP response code is the good.
139
133
 
134
+ ### be_correctly_send
140
135
 
136
+ * check if return is HTTP valid
141
137
 
138
+ ### respond_with_a_collection_of_record
142
139
 
140
+ * params :
141
+ - OPTIONAL[root: <:symbol>]
142
+ * goal : check if the return is a JSON Array, could be chroot with *root:*
143
143
 
144
+
145
+ ### respond_a_record
146
+
147
+ * params :
148
+ - OPTIONAL[root: <:symbol>] :
149
+ * goal : check if the return is a JSON Hash, could be chroot with *root:*
150
+
151
+ ### respond_with_collection
152
+ * params :
153
+ - size: Integer
154
+ - OPTIONAL[root: <:symbol>]
155
+ * goal : check if the collection have the good size, could be chroot with *root:*
156
+
157
+ ### respond_with
158
+ * params :
159
+ - data: Object
160
+ - OPTIONAL[root: <:symbol>]
161
+ * goal : check if the return match the given object, could be chroot with root:
162
+
163
+ ### respond_with_status
164
+ * params :
165
+ - code: Integer
166
+ * goal : check if the HTTP response code is the good.
167
+
168
+
169
+ ## More
170
+
171
+ ### Data dumper RestService#returned_data
172
+
173
+ You could, for debug your tests and during dev, dump your data with
174
+
175
+ ```ruby
176
+ describe 'Test REST API' do
177
+ before :all do
178
+ $service = RestService::new :service => Application
179
+ end
180
+
181
+ subject { $service }
182
+ context "GET /data" do
183
+ it { expect(subject.get('/data')).to be_correctly_sent }
184
+ it { subject.returned_data }
185
+ end
186
+ end
187
+ ```
144
188
 
189
+ It display the returned data of API.
190
+
191
+ ### Fixtures getter
192
+
193
+ If you want to compare or inject data you could create fixture YAML files with :
194
+
195
+
196
+ ```ruby
197
+
198
+ describe 'Test REST API' do
199
+ before :all do
200
+ $service = RestService::new :service => Application
201
+ $mydata = get_file 'spec/fixtures/mydata.yml'
202
+ end
203
+
204
+ subject { $service }
205
+ context "POST /data : test" do
206
+ it { expect(subject.post('/data',$mydata.to_json)).to be_correctly_sent }
207
+ end
208
+
209
+
210
+ end
211
+ ```
212
+
213
+ ### Statefullies helpers
214
+
215
+ To be able to record ids of record, rack-rest-spec offer two helpers, to transit data from tests to tests.
216
+
217
+ ```ruby
218
+
219
+ describe 'Test REST API' do
220
+ before :all do
221
+ $service = RestService::new :service => Application
222
+ $mydata = get_file 'spec/fixtures/mydata.yml'
223
+ end
224
+
225
+ subject { $service }
226
+ context "POST /data : test" do
227
+ it { expect(subject.post('/data',$mydata.to_json)).to be_correctly_sent }
228
+ it { memorize id: subject.returned_data[:id] }
229
+ end
230
+
231
+ context "GET /data/<id> : test" do
232
+ it { expect(subject.get("/data#{retrieve(:id)}")).to be_correctly_sent }
233
+ end
234
+ end
235
+
236
+ end
237
+ ```
238
+
145
239
 
data/Rakefile CHANGED
@@ -1,54 +1,61 @@
1
- require "bundler/gem_tasks"
2
- require 'rubygems'
3
- require 'version'
4
- require 'rake/version_task'
5
- require 'rspec'
6
- require 'rake'
7
- require "rake/clean"
8
- require "rubygems/package_task"
9
- require "rdoc/task"
10
- require 'code_statistics'
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
11
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop//rake_task'
6
+
12
7
  require 'yard'
13
- require 'yard/rake/yardoc_task.rb'
14
- require "rake/tasklib"
15
- require "roodi"
16
- require "roodi_task"
8
+ require 'yard/rake/yardoc_task'
17
9
 
10
+ require 'code_statistics'
11
+
12
+ RuboCop::RakeTask.new
13
+ RSpec::Core::RakeTask.new(:spec)
18
14
 
19
15
  task default: :spec
20
16
 
17
+ require 'version'
18
+ require 'rake/version_task'
21
19
  Rake::VersionTask.new
22
20
 
23
- RoodiTask.new() do | t |
24
- t.patterns = %w(lib/**/*.rb)
25
- t.config = "ultragreen_roodi_coding_convention.yml"
26
- end
27
-
28
-
29
- CLEAN.include('*.tmp','*.old')
30
- CLOBBER.include('*.tmp', 'build/*','#*#')
31
-
32
-
33
- content = File::readlines(File.join(File.dirname(__FILE__), 'rack-rest-rspec.gemspec')).join
34
- spec = eval(content)
35
-
36
- RSpec::Core::RakeTask.new('spec')
37
-
38
21
  YARD::Rake::YardocTask.new do |t|
39
- t.files = [ 'lib/**/*.rb', '-', 'doc/**/*','spec/**/*_spec.rb']
40
- t.options += ['--title', "Gem Documentation"]
41
- t.options += ['-o', "yardoc"]
22
+ t.files = ['lib/**/*.rb', '-', 'doc/**/*', 'spec/**/*_spec.rb']
23
+ t.options += ['-o', 'yardoc']
42
24
  end
43
25
  YARD::Config.load_plugin('yard-rspec')
44
26
 
45
27
  namespace :yardoc do
46
28
  task :clobber do
47
- rm_r "yardoc" rescue nil
48
- rm_r ".yardoc" rescue nil
29
+ begin
30
+ rm_r 'yardoc'
31
+ rescue StandardError
32
+ nil
33
+ end
34
+ begin
35
+ rm_r '.yardoc'
36
+ rescue StandardError
37
+ nil
38
+ end
39
+ begin
40
+ rm_r 'pkg'
41
+ rescue StandardError
42
+ nil
43
+ end
49
44
  end
50
45
  end
51
- task :clobber => "yardoc:clobber"
46
+ task clobber: 'yardoc:clobber'
52
47
 
48
+ desc 'Run CVE security audit over bundle'
49
+ task :audit do
50
+ system('bundle audit')
51
+ end
53
52
 
53
+ desc 'Run dead line of code detection'
54
+ task :debride do
55
+ system('debride -w .debride_whitelist .')
56
+ end
54
57
 
58
+ desc 'Run SBOM CycloneDX Xml format file'
59
+ task :sbom do
60
+ system('cyclonedx-ruby -p .')
61
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 1.0.0