rspec_request_helpers 0.3.2 → 0.3.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/generators/rspec/endpoint/endpoint_generator.rb +6 -0
- data/lib/generators/rspec/endpoint/templates/action_request_spec.rb +6 -0
- data/lib/generators/rspec_request_helpers/install/install_generator.rb +6 -0
- data/lib/generators/rspec_request_helpers/install/templates/default_configuration.rb +6 -0
- data/lib/rspec_request_helpers.rb +6 -0
- data/lib/rspec_request_helpers/configuration.rb +6 -0
- data/lib/rspec_request_helpers/helpers.rb +12 -4
- data/lib/rspec_request_helpers/version.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeae8a0b4cf752d0e4806632dc361462130f9d76
|
4
|
+
data.tar.gz: 5b0ca97b3c760d617eac637ac9e2147608bb46b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7e0cb5580153eb9d610fcc210d961c90e8fd8a138b211be68a332f4e226c84407bd17075f5b16e7a854235524a3314c3ec20200484699d81b59035104bbcbc
|
7
|
+
data.tar.gz: 9a0d3034eca5fbd86636483bb25bb4e2aa7a027eef78222905148f9c0cb21fd1b043d6b96813cf1aa71fce9b44d8abdc6171f45513e38fc6e7f4b225751fbec0
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# @Author: Andrii Baran
|
3
|
+
# @Date: 2019-12-18 13:04:57
|
4
|
+
# @Last Modified by: Andrii Baran
|
5
|
+
# @Last Modified time: 2020-01-16 12:17:23
|
6
|
+
|
1
7
|
module Rspec
|
2
8
|
class EndpointGenerator < Rails::Generators::NamedBase
|
3
9
|
source_root File.expand_path('../templates', __FILE__)
|
@@ -1,3 +1,9 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# @Author: Andrii Baran
|
3
|
+
# @Date: 2019-12-18 11:29:56
|
4
|
+
# @Last Modified by: Andrii Baran
|
5
|
+
# @Last Modified time: 2020-01-16 12:17:16
|
6
|
+
|
1
7
|
RSpec.describe '', type: :request do
|
2
8
|
<% @path_params.each do |param| %>
|
3
9
|
<%= "let(#{param}) { #{rand(99..500)} }" %>
|
@@ -1,3 +1,9 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# @Author: Andrii Baran
|
3
|
+
# @Date: 2019-12-09 15:05:38
|
4
|
+
# @Last Modified by: Andrii Baran
|
5
|
+
# @Last Modified time: 2020-01-16 12:17:32
|
6
|
+
|
1
7
|
module RspecRequestHelpers
|
2
8
|
class InstallGenerator < Rails::Generators::Base
|
3
9
|
source_root File.expand_path('../templates', __FILE__)
|
@@ -1,3 +1,9 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# @Author: Andrii Baran
|
3
|
+
# @Date: 2019-12-09 15:05:38
|
4
|
+
# @Last Modified by: Andrii Baran
|
5
|
+
# @Last Modified time: 2020-01-16 12:17:28
|
6
|
+
|
1
7
|
RspecRequestHelpers.configure do |config|
|
2
8
|
# Responces content type and shorthand as key
|
3
9
|
# The key will be used for the generation of helpers names
|
@@ -1,3 +1,9 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# @Author: Andrii Baran
|
3
|
+
# @Date: 2019-12-09 15:05:38
|
4
|
+
# @Last Modified by: Andrii Baran
|
5
|
+
# @Last Modified time: 2020-01-16 12:18:25
|
6
|
+
|
1
7
|
require 'rspec_request_helpers/version'
|
2
8
|
require 'rspec_request_helpers/configuration'
|
3
9
|
require 'rspec_request_helpers/helpers'
|
@@ -1,3 +1,9 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# @Author: Andrii Baran
|
3
|
+
# @Date: 2020-01-10 17:30:02
|
4
|
+
# @Last Modified by: Andrii Baran
|
5
|
+
# @Last Modified time: 2020-01-16 12:17:47
|
6
|
+
|
1
7
|
module RspecRequestHelpers
|
2
8
|
module Helpers
|
3
9
|
module ClassMethods
|
@@ -57,10 +63,12 @@ module RspecRequestHelpers
|
|
57
63
|
def self.generate_helpers
|
58
64
|
%i(get post put patch delete).each do |http_verb|
|
59
65
|
define_method :"do_#{http_verb}" do
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
66
|
+
is_not_get = http_verb != :get
|
67
|
+
is_json = headers['Content-Type'] == 'application/json'
|
68
|
+
is_new_rails = 3 < Rails::VERSION::MAJOR
|
69
|
+
params_require_normalization = is_new_rails && is_json && is_not_get
|
70
|
+
normalized_params = params_require_normalization ? params.to_json : params
|
71
|
+
if 4 < Rails::VERSION::MAJOR
|
64
72
|
public_send(http_verb, path, params: normalized_params, headers: headers)
|
65
73
|
else
|
66
74
|
public_send(http_verb, path, normalized_params, headers)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_request_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrii Baran
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|