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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f06e38a3cbd6caac785e84b1df502e7150350925
4
- data.tar.gz: b1dd35e25ebc837110fdac4af2fce28873a3d561
3
+ metadata.gz: aeae8a0b4cf752d0e4806632dc361462130f9d76
4
+ data.tar.gz: 5b0ca97b3c760d617eac637ac9e2147608bb46b6
5
5
  SHA512:
6
- metadata.gz: 825be90b4f66e4fd48f717df79cba2a4fc46c381ae828c362892c9611645c36200f0aa298afcb7516c5890fe2f8d83df1eab32284c09285c8a3e66754b42f0b9
7
- data.tar.gz: 59104db5de15210b9e361b13d387d8a19c1ce964edef8fc01ce1917576352c8ef4616a61eb74740c227ce6e4ae4c44171fd6da82806c89059d3b9f9cc11593c5
6
+ metadata.gz: 5e7e0cb5580153eb9d610fcc210d961c90e8fd8a138b211be68a332f4e226c84407bd17075f5b16e7a854235524a3314c3ec20200484699d81b59035104bbcbc
7
+ data.tar.gz: 9a0d3034eca5fbd86636483bb25bb4e2aa7a027eef78222905148f9c0cb21fd1b043d6b96813cf1aa71fce9b44d8abdc6171f45513e38fc6e7f4b225751fbec0
@@ -48,7 +48,7 @@ GEM
48
48
  pry (0.11.3)
49
49
  coderay (~> 1.1.0)
50
50
  method_source (~> 0.9.0)
51
- rack (2.0.7)
51
+ rack (2.0.8)
52
52
  rack-test (1.1.0)
53
53
  rack (>= 1.0, < 3)
54
54
  rails-dom-testing (2.0.3)
@@ -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: 2019-12-09 15:05:38
4
+ # @Last Modified by: Andrii Baran
5
+ # @Last Modified time: 2020-01-16 12:17:37
6
+
1
7
  module RspecRequestHelpers
2
8
  class Configuration
3
9
  attr_accessor :content_types, :status_codes
@@ -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
- is_not_json_get = (http_verb == :get || headers['Content-Type'] != 'application/json')
61
- params_require_normalization = Rails::VERSION::MAJOR < 4 && is_not_json_get
62
- normalized_params = params_require_normalization ? params : params.to_json
63
- if Rails::VERSION::MAJOR >= 5
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)
@@ -1,3 +1,9 @@
1
+ #!/usr/bin/ruby
2
+ # @Author: Andrii Baran
3
+ # @Date: 2019-12-18 13:05:03
4
+ # @Last Modified by: Andrii Baran
5
+ # @Last Modified time: 2020-01-16 12:19:29
6
+
1
7
  module RspecRequestHelpers
2
- VERSION = '0.3.2'
8
+ VERSION = '0.3.3'
3
9
  end
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.2
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: 2019-12-18 00:00:00.000000000 Z
11
+ date: 2020-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport