rails_test_params_backport 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: 93bbcda59b60c75f92f0d6897f123fdcf20749ac
4
- data.tar.gz: 2a4b42950f02662b72ead546f5245e446515fd7d
3
+ metadata.gz: b7edb81ac6f46027c420b6e86701614fc4d18056
4
+ data.tar.gz: d5f88be4d18052c18219bb22c02df923b9c7dc33
5
5
  SHA512:
6
- metadata.gz: 0d1423aafcc23433beb4f115ebe2849ea20d8cb5791c00fb8b2bec32fe9b38e85cb0e9edcc24474d2d1964a862735d9cd6f219f62b7c2d1ffaca74c51f7ecbc1
7
- data.tar.gz: 484380ede8712c21f99e1f0c7436653b43b82c3cb96269aa9c8fc16bd1b311d085f32a3126aa0cb5c4f0793dc35d4a9d9e85e58d1cf7d88b2313e4b98dfd2a97
6
+ metadata.gz: 9d8b6fcabe876616e7404d5bb4bc6e00d816a48d469ce5ab88c541626c8eca95b639eb5a99f7eea380ff5c08eaf97eb0f9108d9b6b1e7b19808f0fee9382f5a6
7
+ data.tar.gz: 25538da8a2b103ab9329ca5a5e76f0cf5bb5b50a294566197547ea2c06c0ee8e35fb37d745d144ff1253c95bd738a17aac7f85dd874bb25684beb878e4ce65b2
@@ -3,6 +3,8 @@ require 'active_support'
3
3
  require 'action_dispatch'
4
4
 
5
5
  module RailsTestParamsBackport
6
+ ParameterError = Class.new(RuntimeError)
7
+
6
8
  ERROR_MESSAGE = <<-EOS.gsub(/^ {4}/, '')
7
9
  Test HTTP request methods will accept only
8
10
  the following keyword arguments in future Rails versions:
@@ -16,15 +18,11 @@ module RailsTestParamsBackport
16
18
  EOS
17
19
 
18
20
  class << self
19
- def verify_parameters(parameters)
21
+ def offensive_parameters?(parameters)
20
22
  offensive_parameters = parameters.keys - %i(params headers env)
21
- return if offensive_parameters.none?
22
- raise RailsTestParamsBackport::ParameterError, ERROR_MESSAGE
23
+ offensive_parameters.any?
23
24
  end
24
25
  end
25
-
26
- class ParameterError < RuntimeError
27
- end
28
26
  end
29
27
 
30
28
  require 'rails_test_params_backport/rails3' if ActiveSupport::VERSION::MAJOR == 3
@@ -3,7 +3,9 @@ module RailsTestParamsBackport
3
3
  def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
4
4
  parameters = parameters.to_h
5
5
 
6
- RailsTestParamsBackport.verify_parameters(parameters)
6
+ if RailsTestParamsBackport.offensive_parameters?(parameters) || session || flash
7
+ raise(ParameterError, ERROR_MESSAGE)
8
+ end
7
9
 
8
10
  headers = parameters.fetch(:headers, {})
9
11
  env = parameters.fetch(:env, {})
@@ -17,7 +19,9 @@ module RailsTestParamsBackport
17
19
  def process(method, path, parameters = nil, rack_env = nil)
18
20
  parameters = parameters.to_h
19
21
 
20
- RailsTestParamsBackport.verify_parameters(parameters)
22
+ if RailsTestParamsBackport.offensive_parameters?(parameters) || rack_env
23
+ raise(ParameterError, ERROR_MESSAGE)
24
+ end
21
25
 
22
26
  headers = parameters.fetch(:headers, {})
23
27
  env = parameters.fetch(:env, {})
@@ -3,7 +3,9 @@ module RailsTestParamsBackport
3
3
  def process(action, http_method = 'GET', *args)
4
4
  parameters = args[0].to_h
5
5
 
6
- RailsTestParamsBackport.verify_parameters(parameters)
6
+ if RailsTestParamsBackport.offensive_parameters?(parameters) || args.length > 1
7
+ raise(ParameterError, ERROR_MESSAGE)
8
+ end
7
9
 
8
10
  headers = parameters.fetch(:headers, {})
9
11
  env = parameters.fetch(:env, {})
@@ -17,7 +19,9 @@ module RailsTestParamsBackport
17
19
  def process(method, path, parameters = nil, headers_or_env = nil)
18
20
  parameters = parameters.to_h
19
21
 
20
- RailsTestParamsBackport.verify_parameters(parameters)
22
+ if RailsTestParamsBackport.offensive_parameters?(parameters) || headers_or_env
23
+ raise(ParameterError, ERROR_MESSAGE)
24
+ end
21
25
 
22
26
  headers = parameters.fetch(:headers, {})
23
27
  env = parameters.fetch(:env, {})
@@ -1,3 +1,3 @@
1
1
  module RailsTestParamsBackport
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_test_params_backport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Schambacher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-05 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  requirements: []
181
181
  rubyforge_project:
182
- rubygems_version: 2.4.5.1
182
+ rubygems_version: 2.5.1
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: Write Rails 5 style tests in your Rails 3 or Rails 4 application.