controller-testing-kwargs 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1cfbdf0a08f8925a6725626f947e766e79075ec8
4
+ data.tar.gz: dd0db95be2052e95f41bd762b092a60104b542f5
5
+ SHA512:
6
+ metadata.gz: 7ac2b59d33909eaf0881d465493bef526bf942a0105ab29ba150b04ff47a022c5e05df76b7df16c00a0ef9b4f7ffdddc228823a271a3016701554af8a15311f9
7
+ data.tar.gz: 122f134d856a219171d7f57680d298376c4370cbfcd0631f79fe1841ebe929579f4234c2f5c8456636aeeac2a672222f1a96f02f1d8f90eceac65ddcb2c524cc
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 AppFolio, Inc.
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 ADDED
@@ -0,0 +1,53 @@
1
+ # Controller::Testing::Kwargs
2
+
3
+ Backport Rails 5 style controller/integration testing syntax using kwargs to Rails 4
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'controller-testing-kwargs'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install controller-testing-kwargs
20
+
21
+ ## Usage
22
+
23
+ Allows you to simultaneously use the old and new syntax while making HTTP calls to your controllers
24
+ in your test suite. So both:
25
+
26
+ ```ruby
27
+ get #{url_or_action}, params, headers
28
+ xhr :post, #{url_or_action}, params, headers
29
+ ```
30
+
31
+ and
32
+
33
+ ```ruby
34
+ get #{url_or_action}, params: params, headers: headers
35
+ get #{url_or_action}, xhr: true, params: params, headers: headers
36
+ ```
37
+
38
+ should work while you transition your test suite.
39
+
40
+ ## Development
41
+
42
+ 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.
43
+
44
+ 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).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/appfolio/controller-testing-kwargs.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
53
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,33 @@
1
+ require "controller/testing/kwargs/version"
2
+ require "rails/test_help"
3
+
4
+ module Controller
5
+ module Testing
6
+ module Kwargs
7
+ %i[get post patch put head delete].each do |method|
8
+ define_method(method) do |action, *args|
9
+ request_params = args[0]&.dup
10
+ request_headers = args[1]&.dup
11
+ if request_params && request_params.is_a?(Hash)
12
+ xhr = request_params.delete(:xhr) || false
13
+ if request_params[:params].is_a?(Hash)
14
+ request_params.merge!(request_params.delete(:params) || {})
15
+ request_headers = request_params.delete(:headers) || request_headers
16
+ elsif request_params[:params]
17
+ request_headers = request_params[:headers]
18
+ request_params = request_params[:params]
19
+ elsif request_params[:headers]
20
+ request_headers = request_params[:headers]
21
+ request_params = nil
22
+ end
23
+ return xhr(method, action, request_params, request_headers) if xhr
24
+ end
25
+ super(action, request_params, request_headers)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ ActionController::TestCase.prepend(Controller::Testing::Kwargs)
33
+ ActionDispatch::IntegrationTest.prepend(Controller::Testing::Kwargs)
@@ -0,0 +1,7 @@
1
+ module Controller
2
+ module Testing
3
+ module Kwargs
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: controller-testing-kwargs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chad Shaffer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: railties
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: actionpack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.2'
83
+ description: Makes upgrading to Rails 5 from Rails 4 easier
84
+ email:
85
+ - chad.shaffer@mycase.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE.txt
91
+ - README.md
92
+ - Rakefile
93
+ - lib/controller/testing/kwargs.rb
94
+ - lib/controller/testing/kwargs/version.rb
95
+ homepage: https://github.com/appfolio/controller-testing-kwargs
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.6.8
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Back-porting Rails 5 controller & integration tests into Rails 4
119
+ test_files: []