rails-forward_compatible_controller_tests 2.3.2 → 2.4.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
- SHA1:
3
- metadata.gz: 85e6930e64c6444606585111e29e1aad38521760
4
- data.tar.gz: 62b5815dae3600c17d2d99839009907ce04f87df
2
+ SHA256:
3
+ metadata.gz: c1889c50e09fc0c07f49f045fae935eb895de92bbdef352557644a9206c68fe4
4
+ data.tar.gz: 604cba70d018fb92869bd54ea7555227bcc36b4253059a62175bbd71fb6cc882
5
5
  SHA512:
6
- metadata.gz: 79f78351a8b03ddf19f2ea260966c7c899d926ddf043440e34b028465473e249c17ed9b130f923f0a4da9800e58240dfbe72be3ca46d04e595f6969f0dd30530
7
- data.tar.gz: 15e97383f8958589d226d022d810213ad32005a91ff4c84fe3003b4918180a6538df3a9f3ccc7c1999f422ffa0293d09aceeace5edb75c0ba4fd12c7d5930c0e
6
+ metadata.gz: 8ad5fbafa83c703986e24c2e4a166dff56bc7ac0c986ddb392f158949d61427a32df6ac3aa0465ca0c573f557f1b28e940c967fa006b5075fe12dc0a1fa508a0
7
+ data.tar.gz: c381f1d167748da53d6793cadcd6f4cf9d5b5fb63de3db37035695713dfa4f4b1c110285f4cb2b5d45cdeda0ebfc9305d88bbe8cc73808e14d438952644484a8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rails::ForwardCompatibleControllerTests
2
2
 
3
- Backport Rails 5 style controller/integration testing syntax using kwargs to Rails 4
3
+ Backport Rails 5 style controller/integration testing syntax using kwargs to Rails 4. Supports minitest and rspec.
4
4
 
5
5
  ## Installation
6
6
 
@@ -24,6 +24,13 @@ At the appropriate spot in your `test_helper.rb`, `spec_helper.rb`, or similar f
24
24
  require 'rails/forward_compatible_controller_tests'
25
25
  ```
26
26
 
27
+ If using rspec, add the following lines to your rspec config:
28
+
29
+ ```ruby
30
+ config.include Rails::ForwardCompatibleControllerTests, type: :controller
31
+ config.include Rails::ForwardCompatibleControllerTests, type: :request
32
+ ```
33
+
27
34
  ## Usage
28
35
 
29
36
  Allows you to simultaneously use the old and new syntax while making HTTP calls to your controllers
@@ -65,7 +72,15 @@ to make the switch to Rails 5.
65
72
 
66
73
  ## Development
67
74
 
68
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
75
+ After checking out the repo, run `bin/setup` to install dependencies.
76
+
77
+ This library uses [Appraisal](https://github.com/thoughtbot/appraisal) to run specs in Rails 4 and 5:
78
+ - `bundle exec appraisal actionpack-4.2 rake`.
79
+ - `bundle exec appraisal actionpack-5.0 rake`.
80
+
81
+ The library is a no-op when used with Rails 5 (it doesn't affect the implementation of controller tests). You can run the tests in Rails 5 mode to ensure that the behaviour native to Rails 5 is the same as the behaviour in Rails 4 with the library.
82
+
83
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
69
84
 
70
85
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
71
86
 
data/Rakefile CHANGED
@@ -1,10 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
+ require "rspec/core/rake_task"
3
4
 
4
- Rake::TestTask.new(:test) do |t|
5
+ Rake::TestTask.new(:test_minitest) do |t|
5
6
  t.libs << "test"
6
7
  t.libs << "lib"
7
8
  t.test_files = FileList['test/**/*_test.rb']
8
9
  end
9
10
 
10
- task :default => :test
11
+ RSpec::Core::RakeTask.new(:test_rspec)
12
+
13
+ task :default => [:test_minitest, :test_rspec]
@@ -1,5 +1,4 @@
1
1
  require "rails/forward_compatible_controller_tests/version"
2
- require "rails/test_help"
3
2
 
4
3
  module Rails
5
4
  module ForwardCompatibleControllerTests
@@ -45,7 +44,7 @@ module Rails
45
44
 
46
45
  %i[get post patch put head delete].each do |method|
47
46
  define_method(method) do |action, *args|
48
- controller_test = self.class < ActionController::TestCase
47
+ controller_test = self.class.try(:metadata)&.[](:type) == :controller || self.class < ActionController::TestCase
49
48
  request_params = args[0]&.dup
50
49
  request_session = args[1]&.dup if controller_test
51
50
  request_headers = args[1]&.dup unless controller_test
@@ -62,6 +61,11 @@ module Rails
62
61
  request_headers = request_params.delete(:headers) || request_headers unless controller_test
63
62
  request_flash = request_params.delete(:flash) || request_flash if controller_test
64
63
  request_params.merge!(request_params.delete(:params) || {})
64
+ elsif request_params[:params].is_a?(String) && !controller_test
65
+ request_flash = nil
66
+ request_session = nil
67
+ request_headers = request_params.delete(:headers)
68
+ request_params = request_params.delete(:params) || ""
65
69
  elsif request_params.key?(:headers) && !controller_test
66
70
  request_flash = nil
67
71
  request_session = nil
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module ForwardCompatibleControllerTests
3
- VERSION = "2.3.2"
3
+ VERSION = "2.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-forward_compatible_controller_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-21 00:00:00.000000000 Z
11
+ date: 2018-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '5.1'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec-rails
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '='
80
+ - !ruby/object:Gem::Version
81
+ version: 3.8.0
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '='
87
+ - !ruby/object:Gem::Version
88
+ version: 3.8.0
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: appraisal
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -138,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
152
  version: '0'
139
153
  requirements: []
140
154
  rubyforge_project:
141
- rubygems_version: 2.6.8
155
+ rubygems_version: 2.7.6
142
156
  signing_key:
143
157
  specification_version: 4
144
158
  summary: Back-porting Rails 5 controller & integration tests into Rails 4