@@ -9,126 +9,126 @@ def setup
99 end
1010
1111 def test_good_graphql_heredoc
12- result = investigate ( @cop , <<-RUBY )
12+ investigate ( @cop , <<-RUBY )
1313 Query = Client.parse <<'GRAPHQL'
1414 { version }
1515GRAPHQL
1616 RUBY
1717
18- assert_empty result . offenses . map ( &:message )
18+ assert_empty @cop . offenses . map ( &:message )
1919 end
2020
2121 def test_good_graphql_dash_heredoc
22- result = investigate ( @cop , <<-RUBY )
22+ investigate ( @cop , <<-RUBY )
2323 Query = Client.parse <<-'GRAPHQL'
2424 { version }
2525 GRAPHQL
2626 RUBY
2727
28- assert_empty result . offenses . map ( &:message )
28+ assert_empty @cop . offenses . map ( &:message )
2929 end
3030
3131 def test_good_graphql_squiggly_heredoc
32- result = investigate ( @cop , <<-RUBY )
32+ investigate ( @cop , <<-RUBY )
3333 Query = Client.parse <<~'GRAPHQL'
3434 { version }
3535 GRAPHQL
3636 RUBY
3737
38- assert_empty result . offenses . map ( &:message )
38+ assert_empty @cop . offenses . map ( &:message )
3939 end
4040
4141 def test_bad_graphql_heredoc
42- result = investigate ( @cop , <<-RUBY )
42+ investigate ( @cop , <<-RUBY )
4343 Query = Client.parse <<GRAPHQL
4444 { version }
4545GRAPHQL
4646 RUBY
4747
48- assert_equal 1 , result . offenses . count
49- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses . first . message
48+ assert_equal 1 , @cop . offenses . count
49+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses . first . message
5050 end
5151
5252 def test_bad_graphql_dash_heredoc
53- result = investigate ( @cop , <<-RUBY )
53+ investigate ( @cop , <<-RUBY )
5454 Query = Client.parse <<-GRAPHQL
5555 { version }
5656 GRAPHQL
5757 RUBY
5858
59- assert_equal 1 , result . offenses . count
60- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses . first . message
59+ assert_equal 1 , @cop . offenses . count
60+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses . first . message
6161 end
6262
6363 def test_bad_graphql_squiggly_heredoc
6464 skip if RUBY_VERSION < "2.3"
6565
66- result = investigate ( @cop , <<-RUBY )
66+ investigate ( @cop , <<-RUBY )
6767 Query = Client.parse <<~GRAPHQL
6868 { version }
6969 GRAPHQL
7070 RUBY
7171
72- assert_equal 1 , result . offenses . count
73- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses . first . message
72+ assert_equal 1 , @cop . offenses . count
73+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses . first . message
7474 end
7575
7676 def test_bad_graphql_heredoc_with_interpolation
77- result = investigate ( @cop , <<-RUBY )
77+ investigate ( @cop , <<-RUBY )
7878 field = "version"
7979 Query = Client.parse <<-GRAPHQL
8080 { \# {field} }
8181 GRAPHQL
8282 RUBY
8383
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
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
8787 end
8888
8989 def test_bad_graphql_multiline_heredoc
90- result = investigate ( @cop , <<-RUBY )
90+ investigate ( @cop , <<-RUBY )
9191 Query = Client.parse <<GRAPHQL
9292 {
9393 version
9494 }
9595GRAPHQL
9696 RUBY
9797
98- assert_equal 1 , result . offenses . count
99- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 0 ] . message
98+ assert_equal 1 , @cop . offenses . count
99+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 0 ] . message
100100 end
101101
102102 def test_bad_graphql_multiline_dash_heredoc
103- result = investigate ( @cop , <<-RUBY )
103+ investigate ( @cop , <<-RUBY )
104104 Query = Client.parse <<-GRAPHQL
105105 {
106106 version
107107 }
108108 GRAPHQL
109109 RUBY
110110
111- assert_equal 1 , result . offenses . count
112- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 0 ] . message
111+ assert_equal 1 , @cop . offenses . count
112+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 0 ] . message
113113 end
114114
115115 def test_bad_graphql_multiline_squiggly_heredoc
116116 skip if RUBY_VERSION < "2.3"
117117
118- result = investigate ( @cop , <<-RUBY )
118+ investigate ( @cop , <<-RUBY )
119119 Query = Client.parse <<~GRAPHQL
120120 {
121121 version
122122 }
123123 GRAPHQL
124124 RUBY
125125
126- assert_equal 1 , result . offenses . count
127- assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , result . offenses [ 0 ] . message
126+ assert_equal 1 , @cop . offenses . count
127+ assert_equal "GraphQL/Heredoc: GraphQL heredocs should be quoted. <<-'GRAPHQL'" , @cop . offenses [ 0 ] . message
128128 end
129129
130130 def test_bad_graphql_multiline_heredoc_with_interpolation
131- result = investigate ( @cop , <<-RUBY )
131+ investigate ( @cop , <<-RUBY )
132132 field = "version"
133133 Query = Client.parse <<-GRAPHQL
134134 {
@@ -137,9 +137,9 @@ def test_bad_graphql_multiline_heredoc_with_interpolation
137137 GRAPHQL
138138 RUBY
139139
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
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
143143 end
144144
145145 private
@@ -148,5 +148,6 @@ def investigate(cop, src)
148148 processed_source = RuboCop ::ProcessedSource . new ( src , RUBY_VERSION . to_f )
149149 commissioner = RuboCop ::Cop ::Commissioner . new ( [ cop ] , [ ] , raise_error : true )
150150 commissioner . investigate ( processed_source )
151+ commissioner
151152 end
152153end
0 commit comments