rails_kwargs_testing 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +113 -0
- data/LICENSE.txt +21 -0
- data/README.md +97 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rails_kwargs_testing.rb +3 -0
- data/lib/rails_kwargs_testing/controller_methods.rb +33 -0
- data/lib/rails_kwargs_testing/request_methods.rb +31 -0
- data/lib/rails_kwargs_testing/version.rb +3 -0
- data/rails_kwargs_testing.gemspec +24 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6963ead74447c7ad715bd25576a8819f265ce1fe
|
4
|
+
data.tar.gz: '0280bb0894142181e7672d8f3caed92a8c67bc76'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4e04cf893a2a68c673ad6379943daaf3fbbc426273fc114f9040b2e7c91ba7dda64bc1c17e5ae3fc538c5b12cab9d59433d8984072c969ce0a68e9ef2182645
|
7
|
+
data.tar.gz: c771205e39785cb0d3a22c8f83aa1373b233a1df1ba62129537d8ff1f2bc343d251c3ebfe0cbe021174ad72f1f7ef3ec470ff8d9e93161ec5d122b5715516746
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rails_kwargs_testing (0.1.0)
|
5
|
+
rails (< 5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.2.10)
|
11
|
+
actionpack (= 4.2.10)
|
12
|
+
actionview (= 4.2.10)
|
13
|
+
activejob (= 4.2.10)
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
actionpack (4.2.10)
|
17
|
+
actionview (= 4.2.10)
|
18
|
+
activesupport (= 4.2.10)
|
19
|
+
rack (~> 1.6)
|
20
|
+
rack-test (~> 0.6.2)
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
23
|
+
actionview (4.2.10)
|
24
|
+
activesupport (= 4.2.10)
|
25
|
+
builder (~> 3.1)
|
26
|
+
erubis (~> 2.7.0)
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
29
|
+
activejob (4.2.10)
|
30
|
+
activesupport (= 4.2.10)
|
31
|
+
globalid (>= 0.3.0)
|
32
|
+
activemodel (4.2.10)
|
33
|
+
activesupport (= 4.2.10)
|
34
|
+
builder (~> 3.1)
|
35
|
+
activerecord (4.2.10)
|
36
|
+
activemodel (= 4.2.10)
|
37
|
+
activesupport (= 4.2.10)
|
38
|
+
arel (~> 6.0)
|
39
|
+
activesupport (4.2.10)
|
40
|
+
i18n (~> 0.7)
|
41
|
+
minitest (~> 5.1)
|
42
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
43
|
+
tzinfo (~> 1.1)
|
44
|
+
arel (6.0.4)
|
45
|
+
builder (3.2.3)
|
46
|
+
concurrent-ruby (1.0.5)
|
47
|
+
crass (1.0.4)
|
48
|
+
erubis (2.7.0)
|
49
|
+
globalid (0.4.1)
|
50
|
+
activesupport (>= 4.2.0)
|
51
|
+
i18n (0.9.5)
|
52
|
+
concurrent-ruby (~> 1.0)
|
53
|
+
loofah (2.2.2)
|
54
|
+
crass (~> 1.0.2)
|
55
|
+
nokogiri (>= 1.5.9)
|
56
|
+
mail (2.7.0)
|
57
|
+
mini_mime (>= 0.1.1)
|
58
|
+
mini_mime (1.0.0)
|
59
|
+
mini_portile2 (2.3.0)
|
60
|
+
minitest (5.11.3)
|
61
|
+
nokogiri (1.8.2)
|
62
|
+
mini_portile2 (~> 2.3.0)
|
63
|
+
rack (1.6.9)
|
64
|
+
rack-test (0.6.3)
|
65
|
+
rack (>= 1.0)
|
66
|
+
rails (4.2.10)
|
67
|
+
actionmailer (= 4.2.10)
|
68
|
+
actionpack (= 4.2.10)
|
69
|
+
actionview (= 4.2.10)
|
70
|
+
activejob (= 4.2.10)
|
71
|
+
activemodel (= 4.2.10)
|
72
|
+
activerecord (= 4.2.10)
|
73
|
+
activesupport (= 4.2.10)
|
74
|
+
bundler (>= 1.3.0, < 2.0)
|
75
|
+
railties (= 4.2.10)
|
76
|
+
sprockets-rails
|
77
|
+
rails-deprecated_sanitizer (1.0.3)
|
78
|
+
activesupport (>= 4.2.0.alpha)
|
79
|
+
rails-dom-testing (1.0.9)
|
80
|
+
activesupport (>= 4.2.0, < 5.0)
|
81
|
+
nokogiri (~> 1.6)
|
82
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
83
|
+
rails-html-sanitizer (1.0.4)
|
84
|
+
loofah (~> 2.2, >= 2.2.2)
|
85
|
+
railties (4.2.10)
|
86
|
+
actionpack (= 4.2.10)
|
87
|
+
activesupport (= 4.2.10)
|
88
|
+
rake (>= 0.8.7)
|
89
|
+
thor (>= 0.18.1, < 2.0)
|
90
|
+
rake (10.5.0)
|
91
|
+
sprockets (3.7.1)
|
92
|
+
concurrent-ruby (~> 1.0)
|
93
|
+
rack (> 1, < 3)
|
94
|
+
sprockets-rails (3.2.1)
|
95
|
+
actionpack (>= 4.0)
|
96
|
+
activesupport (>= 4.0)
|
97
|
+
sprockets (>= 3.0.0)
|
98
|
+
thor (0.20.0)
|
99
|
+
thread_safe (0.3.6)
|
100
|
+
tzinfo (1.2.5)
|
101
|
+
thread_safe (~> 0.1)
|
102
|
+
|
103
|
+
PLATFORMS
|
104
|
+
ruby
|
105
|
+
|
106
|
+
DEPENDENCIES
|
107
|
+
bundler (~> 1.16)
|
108
|
+
minitest (~> 5.0)
|
109
|
+
rails_kwargs_testing!
|
110
|
+
rake (~> 10.0)
|
111
|
+
|
112
|
+
BUNDLED WITH
|
113
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ryo Nakamura
|
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,97 @@
|
|
1
|
+
# RailsKwargsTesting
|
2
|
+
|
3
|
+
[![Gem](https://img.shields.io/gem/v/rails_kwargs_testing.svg)](https://rubygems.org/gems/rails_kwargs_testing)
|
4
|
+
[![Build Status](https://travis-ci.org/r7kamura/rails_kwargs_testing.png)](https://travis-ci.org/r7kamura/rails_kwargs_testing)
|
5
|
+
|
6
|
+
Provides Rails 5 compatible testing methods for gradual migration from Rails 4 to 5.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem "rails_kwargs_testing"
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem install rails_kwargs_testing
|
26
|
+
```
|
27
|
+
|
28
|
+
## Minitest
|
29
|
+
|
30
|
+
### ActionController::TestCase
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class ArticlesControllerTest < ::ActionController::TestCase
|
34
|
+
prepend ::RailsKwargsTesting::ControllerMethods
|
35
|
+
|
36
|
+
def test_create
|
37
|
+
post :create, params: { name: "Hello, World!" }
|
38
|
+
assert_equal 200, response.status
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
### ActionDispatch::IntegrationTest
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
class CreateArticleTest < ActionDispatch::IntegrationTest
|
47
|
+
prepend ::RailsKwargsTesting::RequestMethods
|
48
|
+
|
49
|
+
def test_create_article
|
50
|
+
# `post "/articles", name: "Hello, World!"` in Rails 4
|
51
|
+
post "/articles", params: { name: "Hello, World!" }
|
52
|
+
assert_equal 200, response.status
|
53
|
+
end
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
## RSpec
|
58
|
+
|
59
|
+
### Controller-specs
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
RSpec.describe ArticlesController do
|
63
|
+
prepend RailsKwargsTesting::ControllerMethods
|
64
|
+
|
65
|
+
describe "#create" do
|
66
|
+
subject do
|
67
|
+
# `post :create, name: "Hello, World!"` in Rails 4
|
68
|
+
post :create, params: { name: "Hello, World!" }
|
69
|
+
end
|
70
|
+
|
71
|
+
it { is_expected.to eq 200 }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
### Request-specs
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
RSpec.describe "POST /articles" do
|
80
|
+
prepend RailsKwargsTesting::RequestMethods
|
81
|
+
|
82
|
+
subject do
|
83
|
+
# `post "/articles", name: "Hello, World!"` in Rails 4
|
84
|
+
post "/articles", params: { name: "Hello, World!" }
|
85
|
+
end
|
86
|
+
|
87
|
+
it { is_expected.to eq 200 }
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/r7kamura/rails_kwargs_testing.
|
94
|
+
|
95
|
+
## License
|
96
|
+
|
97
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails_kwargs_testing"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module RailsKwargsTesting
|
2
|
+
module ControllerMethods
|
3
|
+
%i[
|
4
|
+
delete
|
5
|
+
get
|
6
|
+
head
|
7
|
+
patch
|
8
|
+
post
|
9
|
+
put
|
10
|
+
].each do |method_name|
|
11
|
+
define_method(method_name) do |path, flash: nil, format: nil, params: nil, session: nil|
|
12
|
+
if format
|
13
|
+
params = (params || {}).merge(format: format)
|
14
|
+
end
|
15
|
+
super(path, params, session, flash)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
%i[
|
20
|
+
xhr
|
21
|
+
xml_http_request
|
22
|
+
].each do |method_name|
|
23
|
+
define_method(method_name) do |request_method, action, flash: nil, format: nil, params: nil, session: nil|
|
24
|
+
@request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
|
25
|
+
@request.env['HTTP_ACCEPT'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ')
|
26
|
+
__send__(request_method, action, flash: flash, format: format, params: params, session: session).tap do
|
27
|
+
@request.env.delete 'HTTP_X_REQUESTED_WITH'
|
28
|
+
@request.env.delete 'HTTP_ACCEPT'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RailsKwargsTesting
|
2
|
+
module RequestMethods
|
3
|
+
%i[
|
4
|
+
delete
|
5
|
+
get
|
6
|
+
head
|
7
|
+
patch
|
8
|
+
post
|
9
|
+
put
|
10
|
+
get_via_redirect
|
11
|
+
head_via_redirect
|
12
|
+
patch_via_redirect
|
13
|
+
post_via_redirect
|
14
|
+
put_via_redirect
|
15
|
+
].each do |method_name|
|
16
|
+
define_method(method_name) do |path, env: {}, headers: {}, params: nil|
|
17
|
+
super(path, params, env.merge(headers))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
%i[
|
22
|
+
request_via_redirect
|
23
|
+
xhr
|
24
|
+
xml_http_request
|
25
|
+
].each do |method_name|
|
26
|
+
define_method(method_name) do |request_method, path, env: {}, headers: {}, params: nil|
|
27
|
+
super(request_method, path, params, env.merge(headers))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "rails_kwargs_testing/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_kwargs_testing"
|
8
|
+
spec.version = RailsKwargsTesting::VERSION
|
9
|
+
spec.authors = ["r7kamura"]
|
10
|
+
spec.email = ["r7kamura@gmail.com"]
|
11
|
+
spec.summary = "Provides Rails 5 compatible testing methods for gradual migration from Rails 4 to 5."
|
12
|
+
spec.homepage = "https://github.com/r7kamura/rails_kwargs_testing"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "rails", "< 5"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_kwargs_testing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- r7kamura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "<"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "<"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- r7kamura@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/rails_kwargs_testing.rb
|
86
|
+
- lib/rails_kwargs_testing/controller_methods.rb
|
87
|
+
- lib/rails_kwargs_testing/request_methods.rb
|
88
|
+
- lib/rails_kwargs_testing/version.rb
|
89
|
+
- rails_kwargs_testing.gemspec
|
90
|
+
homepage: https://github.com/r7kamura/rails_kwargs_testing
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.6.11
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Provides Rails 5 compatible testing methods for gradual migration from Rails
|
114
|
+
4 to 5.
|
115
|
+
test_files: []
|