@@ -9,126 +9,126 @@ def setup
9
9
end
10
10
11
11
def test_good_graphql_heredoc
12
- investigate ( @cop , <<-RUBY )
12
+ result = investigate ( @cop , <<-RUBY )
13
13
Query = Client.parse <<'GRAPHQL'
14
14
{ version }
15
15
GRAPHQL
16
16
RUBY
17
17
18
- assert_empty @cop . offenses . map ( &:message )
18
+ assert_empty result . offenses . map ( &:message )
19
19
end
20
20
21
21
def test_good_graphql_dash_heredoc
22
- investigate ( @cop , <<-RUBY )
22
+ result = investigate ( @cop , <<-RUBY )
23
23
Query = Client.parse <<-'GRAPHQL'
24
24
{ version }
25
25
GRAPHQL
26
26
RUBY
27
27
28
- assert_empty @cop . offenses . map ( &:message )
28
+ assert_empty result . offenses . map ( &:message )
29
29
end
30
30
31
31
def test_good_graphql_squiggly_heredoc
32
- investigate ( @cop , <<-RUBY )
32
+ result = investigate ( @cop , <<-RUBY )
33
33
Query = Client.parse <<~'GRAPHQL'
34
34
{ version }
35
35
GRAPHQL
36
36
RUBY
37
37
38
- assert_empty @cop . offenses . map ( &:message )
38
+ assert_empty result . offenses . map ( &:message )
39
39
end
40
40
41
41
def test_bad_graphql_heredoc
42
- investigate ( @cop , <<-RUBY )
42
+ result = investigate ( @cop , <<-RUBY )
43
43
Query = Client.parse <<GRAPHQL
44
44
{ version }
45
45
GRAPHQL
46
46
RUBY
47
47
48
- assert_equal 1 , @cop . offenses . count
49
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses . first . message
48
+ assert_equal 1 , result . offenses . count
49
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses . first . message
50
50
end
51
51
52
52
def test_bad_graphql_dash_heredoc
53
- investigate ( @cop , <<-RUBY )
53
+ result = investigate ( @cop , <<-RUBY )
54
54
Query = Client.parse <<-GRAPHQL
55
55
{ version }
56
56
GRAPHQL
57
57
RUBY
58
58
59
- assert_equal 1 , @cop . offenses . count
60
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses . first . message
59
+ assert_equal 1 , result . offenses . count
60
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses . first . message
61
61
end
62
62
63
63
def test_bad_graphql_squiggly_heredoc
64
64
skip if RUBY_VERSION < "2.3"
65
65
66
- investigate ( @cop , <<-RUBY )
66
+ result = investigate ( @cop , <<-RUBY )
67
67
Query = Client.parse <<~GRAPHQL
68
68
{ version }
69
69
GRAPHQL
70
70
RUBY
71
71
72
- assert_equal 1 , @cop . offenses . count
73
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses . first . message
72
+ assert_equal 1 , result . offenses . count
73
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses . first . message
74
74
end
75
75
76
76
def test_bad_graphql_heredoc_with_interpolation
77
- investigate ( @cop , <<-RUBY )
77
+ result = investigate ( @cop , <<-RUBY )
78
78
field = "version"
79
79
Query = Client.parse <<-GRAPHQL
80
80
{ \# {field} }
81
81
GRAPHQL
82
82
RUBY
83
83
84
- assert_equal 2 , @cop . offenses . count
85
- assert_equal "GraphQL/Heredoc: Do not interpolate variables into GraphQL queries, used variables instead." , @cop . offenses [ 0 ] . message
86
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 1 ] . message
84
+ assert_equal 2 , result . offenses . count
85
+ assert_equal "GraphQL/Heredoc: Do not interpolate variables into GraphQL queries, used variables instead." , result . offenses [ 0 ] . message
86
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 1 ] . message
87
87
end
88
88
89
89
def test_bad_graphql_multiline_heredoc
90
- investigate ( @cop , <<-RUBY )
90
+ result = investigate ( @cop , <<-RUBY )
91
91
Query = Client.parse <<GRAPHQL
92
92
{
93
93
version
94
94
}
95
95
GRAPHQL
96
96
RUBY
97
97
98
- assert_equal 1 , @cop . offenses . count
99
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 0 ] . message
98
+ assert_equal 1 , result . offenses . count
99
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 0 ] . message
100
100
end
101
101
102
102
def test_bad_graphql_multiline_dash_heredoc
103
- investigate ( @cop , <<-RUBY )
103
+ result = investigate ( @cop , <<-RUBY )
104
104
Query = Client.parse <<-GRAPHQL
105
105
{
106
106
version
107
107
}
108
108
GRAPHQL
109
109
RUBY
110
110
111
- assert_equal 1 , @cop . offenses . count
112
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 0 ] . message
111
+ assert_equal 1 , result . offenses . count
112
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 0 ] . message
113
113
end
114
114
115
115
def test_bad_graphql_multiline_squiggly_heredoc
116
116
skip if RUBY_VERSION < "2.3"
117
117
118
- investigate ( @cop , <<-RUBY )
118
+ result = investigate ( @cop , <<-RUBY )
119
119
Query = Client.parse <<~GRAPHQL
120
120
{
121
121
version
122
122
}
123
123
GRAPHQL
124
124
RUBY
125
125
126
- assert_equal 1 , @cop . offenses . count
127
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 0 ] . message
126
+ assert_equal 1 , result . offenses . count
127
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 0 ] . message
128
128
end
129
129
130
130
def test_bad_graphql_multiline_heredoc_with_interpolation
131
- investigate ( @cop , <<-RUBY )
131
+ result = investigate ( @cop , <<-RUBY )
132
132
field = "version"
133
133
Query = Client.parse <<-GRAPHQL
134
134
{
@@ -137,9 +137,9 @@ def test_bad_graphql_multiline_heredoc_with_interpolation
137
137
GRAPHQL
138
138
RUBY
139
139
140
- assert_equal 2 , @cop . offenses . count
141
- assert_equal "GraphQL/Heredoc: Do not interpolate variables into GraphQL queries, used variables instead." , @cop . offenses [ 0 ] . message
142
- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 1 ] . message
140
+ assert_equal 2 , result . offenses . count
141
+ assert_equal "GraphQL/Heredoc: Do not interpolate variables into GraphQL queries, used variables instead." , result . offenses [ 0 ] . message
142
+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 1 ] . message
143
143
end
144
144
145
145
private
@@ -148,6 +148,5 @@ def investigate(cop, src)
148
148
processed_source = RuboCop ::ProcessedSource . new ( src , RUBY_VERSION . to_f )
149
149
commissioner = RuboCop ::Cop ::Commissioner . new ( [ cop ] , [ ] , raise_error : true )
150
150
commissioner . investigate ( processed_source )
151
- commissioner
152
151
end
153
152
end
0 commit comments