Skip to content

Commit 800221e

Browse files
committed
re: RuboCop - replace rocket style hashes
1 parent 26aa062 commit 800221e

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.2
2+
TargetRubyVersion: 2.1
33
Exclude:
44
- config/initializers/forbidden_yaml.rb
55
- !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/

test/active_model_serializers/key_transform_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def test_camel
66
obj = Object.new
77
scenarios = [
88
{
9-
value: { "some-key": 'value' },
9+
value: { :"some-key" => 'value' },
1010
expected: { SomeKey: 'value' }
1111
},
1212
{
@@ -72,7 +72,7 @@ def test_camel_lower
7272
obj = Object.new
7373
scenarios = [
7474
{
75-
value: { "some-key": 'value' },
75+
value: { :"some-key" => 'value' },
7676
expected: { someKey: 'value' }
7777
},
7878
{
@@ -139,23 +139,23 @@ def test_dash
139139
scenarios = [
140140
{
141141
value: { some_key: 'value' },
142-
expected: { "some-key": 'value' }
142+
expected: { :"some-key" => 'value' }
143143
},
144144
{
145145
value: { 'some_key' => 'value' },
146146
expected: { 'some-key' => 'value' }
147147
},
148148
{
149149
value: { SomeKey: 'value' },
150-
expected: { "some-key": 'value' }
150+
expected: { :"some-key" => 'value' }
151151
},
152152
{
153153
value: { 'SomeKey' => 'value' },
154154
expected: { 'some-key' => 'value' }
155155
},
156156
{
157157
value: { someKey: 'value' },
158-
expected: { "some-key": 'value' }
158+
expected: { :"some-key" => 'value' }
159159
},
160160
{
161161
value: { 'someKey' => 'value' },
@@ -200,7 +200,7 @@ def test_underscore
200200
obj = Object.new
201201
scenarios = [
202202
{
203-
value: { "some-key": 'value' },
203+
value: { :"some-key" => 'value' },
204204
expected: { some_key: 'value' }
205205
},
206206
{

test/adapter/json/transform_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_transform_undefined
6363
def test_transform_dash
6464
mock_request(:dash)
6565
assert_equal({
66-
blog: { id: 1, "special-attribute": 'neat', articles: nil }
66+
blog: { id: 1, :"special-attribute" => 'neat', articles: nil }
6767
}, @adapter.serializable_hash)
6868
end
6969

test/adapter/json_api/linked_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def test_no_duplicates_global
370370
expected = [
371371
type: 'nested-posts', id: '2',
372372
relationships: {
373-
"nested-posts": {
373+
:"nested-posts" => {
374374
data: [
375375
{ type: 'nested-posts', id: '1' },
376376
{ type: 'nested-posts', id: '2' }

test/adapter/json_api/links_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ def test_resource_links
8282
}
8383
},
8484
author: 'http://example.com/link_authors/1337',
85-
"link-authors": 'http://example.com/link_authors',
85+
:"link-authors" => 'http://example.com/link_authors',
8686
resource: 'http://example.com/resource',
8787
posts: 'http://example.com/link_authors/1337/posts',
88-
"yet-another": 'http://example.com/resource/1337'
88+
:"yet-another" => 'http://example.com/resource/1337'
8989
}
9090
assert_equal(expected, hash[:data][:links])
9191
end

test/adapter/json_api/resource_meta_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_meta_block_object_resource
5454
adapter: :json_api
5555
).serializable_hash
5656
expected = {
57-
"comments-count": @post.comments.count
57+
:"comments-count" => @post.comments.count
5858
}
5959
assert_equal(expected, hash[:data][:meta])
6060
end
@@ -69,8 +69,8 @@ def test_meta_object_resource_in_array
6969
).serializable_hash
7070
expected = {
7171
data: [
72-
{ id: '1337', type: 'posts', meta: { "comments-count": 0 } },
73-
{ id: '1339', type: 'posts', meta: { "comments-count": 1 } }
72+
{ id: '1337', type: 'posts', meta: { :"comments-count" => 0 } },
73+
{ id: '1339', type: 'posts', meta: { :"comments-count" => 1 } }
7474
]
7575
}
7676
assert_equal(expected, hash)

test/adapter/json_api/transform_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_success_document_transform_default
7676
attributes: {
7777
title: 'Title 1',
7878
body: 'Body 1',
79-
"publish-at": @publish_at
79+
:"publish-at" => @publish_at
8080
},
8181
relationships: {
8282
author: {
@@ -91,10 +91,10 @@ def test_success_document_transform_default
9191
},
9292
links: {
9393
self: 'http://example.com/posts/1337',
94-
"post-authors": 'http://example.com/posts/1337/authors',
95-
"subscriber-comments": 'http://example.com/posts/1337/comments'
94+
:"post-authors" => 'http://example.com/posts/1337/authors',
95+
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
9696
},
97-
meta: { rating: 5, "favorite-count": 10 }
97+
meta: { rating: 5, :"favorite-count" => 10 }
9898
}
9999
}, result)
100100
end
@@ -185,7 +185,7 @@ def test_success_document_transform_dash
185185
attributes: {
186186
title: 'Title 1',
187187
body: 'Body 1',
188-
"publish-at": @publish_at
188+
:"publish-at" => @publish_at
189189
},
190190
relationships: {
191191
author: {
@@ -200,10 +200,10 @@ def test_success_document_transform_dash
200200
},
201201
links: {
202202
self: 'http://example.com/posts/1337',
203-
"post-authors": 'http://example.com/posts/1337/authors',
204-
"subscriber-comments": 'http://example.com/posts/1337/comments'
203+
:"post-authors" => 'http://example.com/posts/1337/authors',
204+
:"subscriber-comments" => 'http://example.com/posts/1337/comments'
205205
},
206-
meta: { rating: 5, "favorite-count": 10 }
206+
meta: { rating: 5, :"favorite-count" => 10 }
207207
}
208208
}, result)
209209
end

0 commit comments

Comments
 (0)