rails5-spec-converter 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -0
- data/lib/rails5/spec_converter/text_transformer.rb +5 -0
- data/lib/rails5/spec_converter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5358fe3940ec49c5084895afcffe7cf51a07d06a
|
4
|
+
data.tar.gz: b0363014912a09bf02040da8f8b2f738358f4613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d1f2a9f62a860a713aed9450112d3964aab94b626e09352d262082cb2a9a649ee473e2c017c5220b122a4a3df1106616bb3c26631911bc2594eced205f4c901
|
7
|
+
data.tar.gz: 65f4b19f4086ec55cb1d24cadb0473e9277005d977e4ceddf6b53d0d10e07b529d52aa7350d3c5985ad4f8f957d54f4ce82db0c148eec8ae33fce99390a2f726
|
data/README.md
CHANGED
@@ -85,6 +85,45 @@ To force hashes to be written without extra whitespace in all files regardless o
|
|
85
85
|
|
86
86
|
To force hashes to be written WITH extra whitespace in all files regardless of context, use the argument `--hash-spacing`.
|
87
87
|
|
88
|
+
## Limitations
|
89
|
+
|
90
|
+
`rails5-spec-converter` wants to partition your arguments into two sets, those that belong in `params` and those that don't.
|
91
|
+
|
92
|
+
But it doesn't do any runtime analysis, so it can only effectively sort out non-`params` keys if they're included in a hash literal on the test invocation site. Hence:
|
93
|
+
|
94
|
+
```
|
95
|
+
all_the_params = {
|
96
|
+
search: 'bayleef',
|
97
|
+
format: :json
|
98
|
+
}
|
99
|
+
|
100
|
+
get :users, all_the_params
|
101
|
+
```
|
102
|
+
|
103
|
+
will become
|
104
|
+
|
105
|
+
```
|
106
|
+
get :users, params: all_the_params
|
107
|
+
```
|
108
|
+
|
109
|
+
even though `format` should be **outside** the params hash.
|
110
|
+
|
111
|
+
#### Future Work
|
112
|
+
|
113
|
+
In cases where the hash keys are unknowable at parse time, future versions may optionally attempt to produce this sort of result:
|
114
|
+
|
115
|
+
```
|
116
|
+
all_the_params = {
|
117
|
+
search: 'bayleef',
|
118
|
+
format: :json
|
119
|
+
}
|
120
|
+
|
121
|
+
r5sc_user_params, r5sc_other_params = all_the_params.partition { |k,v| %i{session flash method body xhr format}.include?(k) }.map { |a| Hash[a] }
|
122
|
+
get :users, r5sc_other_params.merge(params: r5sc_user_params)
|
123
|
+
```
|
124
|
+
|
125
|
+
...which should allow your tests to pass without deprecation warnings while introducing an enticing code cleanup oppurtunity.
|
126
|
+
|
88
127
|
## Development
|
89
128
|
|
90
129
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -32,6 +32,7 @@ module Rails5
|
|
32
32
|
|
33
33
|
if args[0].hash_type? && args[0].children.length > 0
|
34
34
|
next if looks_like_route_definition?(args[0])
|
35
|
+
next if has_kwsplat?(args[0])
|
35
36
|
next if has_key?(args[0], :params)
|
36
37
|
|
37
38
|
write_params_hash(
|
@@ -68,6 +69,10 @@ module Rails5
|
|
68
69
|
false
|
69
70
|
end
|
70
71
|
|
72
|
+
def has_kwsplat?(hash_node)
|
73
|
+
hash_node.children.any? { |node| node.kwsplat_type? }
|
74
|
+
end
|
75
|
+
|
71
76
|
def has_key?(hash_node, key)
|
72
77
|
hash_node.children.any? { |pair| pair.children[0].children[0] == key }
|
73
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails5-spec-converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Grathwell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|