puppet-lint 0.4.0.pre1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.travis.yml +3 -4
  2. data/Gemfile +2 -5
  3. data/README.md +2 -149
  4. data/Rakefile +0 -5
  5. data/lib/puppet-lint.rb +74 -20
  6. data/lib/puppet-lint/bin.rb +20 -85
  7. data/lib/puppet-lint/checkplugin.rb +158 -12
  8. data/lib/puppet-lint/checks.rb +39 -222
  9. data/lib/puppet-lint/configuration.rb +12 -31
  10. data/lib/puppet-lint/data.rb +329 -0
  11. data/lib/puppet-lint/lexer.rb +37 -30
  12. data/lib/puppet-lint/lexer/token.rb +14 -16
  13. data/lib/puppet-lint/monkeypatches/string_prepend.rb +6 -0
  14. data/lib/puppet-lint/optparser.rb +105 -0
  15. data/lib/puppet-lint/plugins.rb +28 -9
  16. data/lib/puppet-lint/plugins/check_classes.rb +162 -238
  17. data/lib/puppet-lint/plugins/check_comments.rb +40 -25
  18. data/lib/puppet-lint/plugins/check_conditionals.rb +16 -20
  19. data/lib/puppet-lint/plugins/check_documentation.rb +14 -20
  20. data/lib/puppet-lint/plugins/check_nodes.rb +23 -0
  21. data/lib/puppet-lint/plugins/check_resources.rb +127 -141
  22. data/lib/puppet-lint/plugins/check_strings.rb +133 -107
  23. data/lib/puppet-lint/plugins/check_variables.rb +11 -11
  24. data/lib/puppet-lint/plugins/check_whitespace.rb +86 -92
  25. data/lib/puppet-lint/tasks/puppet-lint.rb +17 -1
  26. data/lib/puppet-lint/version.rb +1 -1
  27. data/puppet-lint.gemspec +4 -2
  28. data/spec/fixtures/test/manifests/ignore.pp +1 -0
  29. data/spec/fixtures/test/manifests/ignore_reason.pp +1 -0
  30. data/spec/puppet-lint/bin_spec.rb +104 -84
  31. data/spec/puppet-lint/configuration_spec.rb +19 -19
  32. data/spec/puppet-lint/ignore_overrides_spec.rb +97 -0
  33. data/spec/puppet-lint/lexer/token_spec.rb +9 -9
  34. data/spec/puppet-lint/lexer_spec.rb +352 -325
  35. data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +77 -23
  36. data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +14 -12
  37. data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +18 -14
  38. data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +30 -30
  39. data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +31 -26
  40. data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +34 -28
  41. data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +14 -12
  42. data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +74 -30
  43. data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +27 -20
  44. data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +78 -13
  45. data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +17 -12
  46. data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +13 -10
  47. data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +21 -16
  48. data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +69 -0
  49. data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +42 -38
  50. data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +22 -10
  51. data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +81 -18
  52. data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +69 -112
  53. data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +27 -20
  54. data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +177 -171
  55. data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +165 -88
  56. data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +97 -22
  57. data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +25 -0
  58. data/spec/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +97 -111
  59. data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +10 -9
  60. data/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +53 -53
  61. data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +26 -14
  62. data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +10 -9
  63. data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +31 -15
  64. data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +340 -322
  65. data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +30 -23
  66. data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +42 -41
  67. data/spec/puppet-lint_spec.rb +3 -3
  68. data/spec/spec_helper.rb +109 -116
  69. metadata +109 -50
  70. data/spec/puppet-lint/plugins/check_classes/class_parameter_defaults_spec.rb +0 -60
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'quoted_booleans', :type => :lint do
4
+ let(:msg) { 'quoted boolean value found' }
5
+
6
+ context 'with a single line ignore' do
7
+ let(:code) { "
8
+ 'true'
9
+ 'true' # lint:ignore:quoted_booleans
10
+ 'false'
11
+ " }
12
+
13
+ it 'should detect three problems' do
14
+ expect(problems).to have(3).problems
15
+ end
16
+
17
+ it 'should have two warnings' do
18
+ expect(problems).to contain_warning(msg).on_line(2).in_column(7)
19
+ expect(problems).to contain_warning(msg).on_line(4).in_column(7)
20
+ end
21
+
22
+ it 'should have one ignored problem' do
23
+ expect(problems).to contain_ignored(msg).on_line(3).in_column(7)
24
+ end
25
+ end
26
+
27
+ context 'with a single line ignore and a reason' do
28
+ let(:code) { "
29
+ 'true'
30
+ 'true' # lint:ignore:quoted_booleans some good reason
31
+ 'false'
32
+ " }
33
+
34
+ it 'should detect three problems' do
35
+ expect(problems).to have(3).problems
36
+ end
37
+
38
+ it 'should have two warnings' do
39
+ expect(problems).to contain_warning(msg).on_line(2).in_column(7)
40
+ expect(problems).to contain_warning(msg).on_line(4).in_column(7)
41
+ end
42
+
43
+ it 'should have one ignored problem with a reason' do
44
+ expect(problems).to contain_ignored(msg).on_line(3).in_column(7).with_reason('some good reason')
45
+ end
46
+ end
47
+
48
+ context 'with a block ignore' do
49
+ let(:code) { "
50
+ 'true'
51
+ # lint:ignore:quoted_booleans
52
+ 'false'
53
+ 'true'
54
+ # lint:endignore
55
+ 'true'
56
+ " }
57
+
58
+ it 'should detect four problems' do
59
+ expect(problems).to have(4).problems
60
+ end
61
+
62
+ it 'should have two warnings' do
63
+ expect(problems).to contain_warning(msg).on_line(2).in_column(7)
64
+ expect(problems).to contain_warning(msg).on_line(7).in_column(7)
65
+ end
66
+
67
+ it 'should have two ignored problems' do
68
+ expect(problems).to contain_ignored(msg).on_line(4).in_column(7)
69
+ expect(problems).to contain_ignored(msg).on_line(5).in_column(7)
70
+ end
71
+ end
72
+
73
+ context 'with a block ignore and a reason' do
74
+ let(:code) { "
75
+ 'true'
76
+ # lint:ignore:quoted_booleans another reason
77
+ 'false'
78
+ 'true'
79
+ # lint:endignore
80
+ 'true'
81
+ " }
82
+
83
+ it 'should detect four problems' do
84
+ expect(problems).to have(4).problems
85
+ end
86
+
87
+ it 'should have two warnings' do
88
+ expect(problems).to contain_warning(msg).on_line(2).in_column(7)
89
+ expect(problems).to contain_warning(msg).on_line(7).in_column(7)
90
+ end
91
+
92
+ it 'should have two ignored problems with a reason' do
93
+ expect(problems).to contain_ignored(msg).on_line(4).in_column(7).with_reason('another reason')
94
+ expect(problems).to contain_ignored(msg).on_line(5).in_column(7).with_reason('another reason')
95
+ end
96
+ end
97
+ end
@@ -5,14 +5,14 @@ describe PuppetLint::Lexer::Token do
5
5
  PuppetLint::Lexer::Token.new(:NAME, 'foo', 1, 2)
6
6
  end
7
7
 
8
- it { should respond_to(:type) }
9
- it { should respond_to(:value) }
10
- it { should respond_to(:line) }
11
- it { should respond_to(:column) }
8
+ it { is_expected.to respond_to(:type) }
9
+ it { is_expected.to respond_to(:value) }
10
+ it { is_expected.to respond_to(:line) }
11
+ it { is_expected.to respond_to(:column) }
12
12
 
13
- its(:type) { should == :NAME }
14
- its(:value) { should == 'foo' }
15
- its(:line) { should == 1 }
16
- its(:column) { should == 2 }
17
- its(:inspect) { should == "<Token :NAME (foo) @1:2>" }
13
+ its(:type) { is_expected.to eq(:NAME) }
14
+ its(:value) { is_expected.to eq('foo') }
15
+ its(:line) { is_expected.to eq(1) }
16
+ its(:column) { is_expected.to eq(2) }
17
+ its(:inspect) { is_expected.to eq("<Token :NAME (foo) @1:2>") }
18
18
  end
@@ -7,34 +7,34 @@ describe PuppetLint::Lexer do
7
7
 
8
8
  context 'invalid code' do
9
9
  it 'should bork' do
10
- expect { @lexer.tokenise('%') }.to raise_error(PuppetLint::LexerError)
10
+ expect { @lexer.tokenise('^') }.to raise_error(PuppetLint::LexerError)
11
11
  end
12
12
  end
13
13
 
14
14
  context '#new_token' do
15
15
  it 'should calculate the line number for an empty string' do
16
16
  token = @lexer.new_token(:TEST, 'test', :chunk => '')
17
- token.line.should == 1
17
+ expect(token.line).to eq(1)
18
18
  end
19
19
 
20
20
  it 'should calculate the line number for a multi line string' do
21
21
  token = @lexer.new_token(:TEST, 'test', :chunk => "foo\nbar")
22
- token.line.should == 2
22
+ expect(token.line).to eq(2)
23
23
  end
24
24
 
25
25
  it 'should calculate the column number for an empty string' do
26
26
  token = @lexer.new_token(:TEST, 'test', :chunk => '')
27
- token.column.should == 1
27
+ expect(token.column).to eq(1)
28
28
  end
29
29
 
30
30
  it 'should calculate the column number for a single line string' do
31
31
  token = @lexer.new_token(:TEST, 'test', :chunk => 'this is a test')
32
- token.column.should == 14
32
+ expect(token.column).to eq(14)
33
33
  end
34
34
 
35
35
  it 'should calculate the column number for a multi line string' do
36
36
  token = @lexer.new_token(:TEST, 'test', :chunk => "foo\nbar\nbaz\ngronk")
37
- token.column.should == 5
37
+ expect(token.column).to eq(5)
38
38
  end
39
39
  end
40
40
 
@@ -42,22 +42,22 @@ describe PuppetLint::Lexer do
42
42
  it 'should get a segment with a single terminator' do
43
43
  data = StringScanner.new('foo"bar')
44
44
  value, terminator = @lexer.get_string_segment(data, '"')
45
- value.should == 'foo'
46
- terminator.should == '"'
45
+ expect(value).to eq('foo')
46
+ expect(terminator).to eq('"')
47
47
  end
48
48
 
49
49
  it 'should get a segment with multiple terminators' do
50
50
  data = StringScanner.new('foo"bar$baz')
51
51
  value, terminator = @lexer.get_string_segment(data, "'$")
52
- value.should == 'foo"bar'
53
- terminator.should == '$'
52
+ expect(value).to eq('foo"bar')
53
+ expect(terminator).to eq('$')
54
54
  end
55
55
 
56
56
  it 'should not get a segment with an escaped terminator' do
57
57
  data = StringScanner.new('foo"bar')
58
58
  value, terminator = @lexer.get_string_segment(data, '$')
59
- value.should be_nil
60
- terminator.should be_nil
59
+ expect(value).to be_nil
60
+ expect(terminator).to be_nil
61
61
  end
62
62
  end
63
63
 
@@ -66,410 +66,432 @@ describe PuppetLint::Lexer do
66
66
  @lexer.interpolate_string('foo bar baz"',1, 1)
67
67
  token = @lexer.tokens.first
68
68
 
69
- @lexer.tokens.length.should == 1
70
- token.type.should == :STRING
71
- token.value.should == 'foo bar baz'
72
- token.line.should == 1
73
- token.column.should == 1
69
+ expect(@lexer.tokens.length).to eq(1)
70
+ expect(token.type).to eq(:STRING)
71
+ expect(token.value).to eq('foo bar baz')
72
+ expect(token.line).to eq(1)
73
+ expect(token.column).to eq(1)
74
74
  end
75
75
 
76
76
  it 'should handle a string with a newline' do
77
77
  @lexer.interpolate_string(%{foo\nbar"}, 1, 1)
78
78
  token = @lexer.tokens.first
79
79
 
80
- @lexer.tokens.length.should == 1
81
- token.type.should == :STRING
82
- token.value.should == "foo\nbar"
83
- token.line.should == 1
84
- token.column.should == 1
80
+ expect(@lexer.tokens.length).to eq(1)
81
+ expect(token.type).to eq(:STRING)
82
+ expect(token.value).to eq("foo\nbar")
83
+ expect(token.line).to eq(1)
84
+ expect(token.column).to eq(1)
85
85
  end
86
86
 
87
87
  it 'should handle a string with a single variable and suffix' do
88
88
  @lexer.interpolate_string('${foo}bar"', 1, 1)
89
89
  tokens = @lexer.tokens
90
90
 
91
- tokens.length.should == 3
91
+ expect(tokens.length).to eq(3)
92
92
 
93
- tokens[0].type.should == :DQPRE
94
- tokens[0].value.should == ''
95
- tokens[0].line.should == 1
96
- tokens[0].column.should == 1
93
+ expect(tokens[0].type).to eq(:DQPRE)
94
+ expect(tokens[0].value).to eq('')
95
+ expect(tokens[0].line).to eq(1)
96
+ expect(tokens[0].column).to eq(1)
97
97
 
98
- tokens[1].type.should == :VARIABLE
99
- tokens[1].value.should == 'foo'
100
- tokens[1].line.should == 1
101
- tokens[1].column.should == 3
98
+ expect(tokens[1].type).to eq(:VARIABLE)
99
+ expect(tokens[1].value).to eq('foo')
100
+ expect(tokens[1].line).to eq(1)
101
+ expect(tokens[1].column).to eq(3)
102
102
 
103
- tokens[2].type.should == :DQPOST
104
- tokens[2].value.should == 'bar'
105
- tokens[2].line.should == 1
106
- tokens[2].column.should == 8
103
+ expect(tokens[2].type).to eq(:DQPOST)
104
+ expect(tokens[2].value).to eq('bar')
105
+ expect(tokens[2].line).to eq(1)
106
+ expect(tokens[2].column).to eq(8)
107
107
  end
108
108
 
109
109
  it 'should handle a string with a single variable and surrounding text' do
110
110
  @lexer.interpolate_string('foo${bar}baz"', 1, 1)
111
111
  tokens = @lexer.tokens
112
112
 
113
- tokens.length.should == 3
113
+ expect(tokens.length).to eq(3)
114
114
 
115
- tokens[0].type.should == :DQPRE
116
- tokens[0].value.should == 'foo'
117
- tokens[0].line.should == 1
118
- tokens[0].column.should == 1
115
+ expect(tokens[0].type).to eq(:DQPRE)
116
+ expect(tokens[0].value).to eq('foo')
117
+ expect(tokens[0].line).to eq(1)
118
+ expect(tokens[0].column).to eq(1)
119
119
 
120
- tokens[1].type.should == :VARIABLE
121
- tokens[1].value.should == 'bar'
122
- tokens[1].line.should == 1
123
- tokens[1].column.should == 6
120
+ expect(tokens[1].type).to eq(:VARIABLE)
121
+ expect(tokens[1].value).to eq('bar')
122
+ expect(tokens[1].line).to eq(1)
123
+ expect(tokens[1].column).to eq(6)
124
124
 
125
- tokens[2].type.should == :DQPOST
126
- tokens[2].value.should == 'baz'
127
- tokens[2].line.should == 1
128
- tokens[2].column.should == 11
125
+ expect(tokens[2].type).to eq(:DQPOST)
126
+ expect(tokens[2].value).to eq('baz')
127
+ expect(tokens[2].line).to eq(1)
128
+ expect(tokens[2].column).to eq(11)
129
129
  end
130
130
 
131
131
  it 'should handle a string with multiple variables and surrounding text' do
132
132
  @lexer.interpolate_string('foo${bar}baz${gronk}meh"', 1, 1)
133
133
  tokens = @lexer.tokens
134
134
 
135
- tokens.length.should == 5
135
+ expect(tokens.length).to eq(5)
136
136
 
137
- tokens[0].type.should == :DQPRE
138
- tokens[0].value.should == 'foo'
139
- tokens[0].line.should == 1
140
- tokens[0].column.should == 1
137
+ expect(tokens[0].type).to eq(:DQPRE)
138
+ expect(tokens[0].value).to eq('foo')
139
+ expect(tokens[0].line).to eq(1)
140
+ expect(tokens[0].column).to eq(1)
141
141
 
142
- tokens[1].type.should == :VARIABLE
143
- tokens[1].value.should == 'bar'
144
- tokens[1].line.should == 1
145
- tokens[1].column.should == 6
142
+ expect(tokens[1].type).to eq(:VARIABLE)
143
+ expect(tokens[1].value).to eq('bar')
144
+ expect(tokens[1].line).to eq(1)
145
+ expect(tokens[1].column).to eq(6)
146
146
 
147
- tokens[2].type.should == :DQMID
148
- tokens[2].value.should == 'baz'
149
- tokens[2].line.should == 1
150
- tokens[2].column.should == 11
147
+ expect(tokens[2].type).to eq(:DQMID)
148
+ expect(tokens[2].value).to eq('baz')
149
+ expect(tokens[2].line).to eq(1)
150
+ expect(tokens[2].column).to eq(11)
151
151
 
152
- tokens[3].type.should == :VARIABLE
153
- tokens[3].value.should == 'gronk'
154
- tokens[3].line.should == 1
155
- tokens[3].column.should == 15
152
+ expect(tokens[3].type).to eq(:VARIABLE)
153
+ expect(tokens[3].value).to eq('gronk')
154
+ expect(tokens[3].line).to eq(1)
155
+ expect(tokens[3].column).to eq(15)
156
156
 
157
- tokens[4].type.should == :DQPOST
158
- tokens[4].value.should == 'meh'
159
- tokens[4].line.should == 1
160
- tokens[4].column.should == 22
157
+ expect(tokens[4].type).to eq(:DQPOST)
158
+ expect(tokens[4].value).to eq('meh')
159
+ expect(tokens[4].line).to eq(1)
160
+ expect(tokens[4].column).to eq(22)
161
161
  end
162
162
 
163
163
  it 'should handle a string with only a single variable' do
164
164
  @lexer.interpolate_string('${bar}"', 1, 1)
165
165
  tokens = @lexer.tokens
166
166
 
167
- tokens.length.should == 3
167
+ expect(tokens.length).to eq(3)
168
168
 
169
- tokens[0].type.should == :DQPRE
170
- tokens[0].value.should == ''
171
- tokens[0].line.should == 1
172
- tokens[0].column.should == 1
169
+ expect(tokens[0].type).to eq(:DQPRE)
170
+ expect(tokens[0].value).to eq('')
171
+ expect(tokens[0].line).to eq(1)
172
+ expect(tokens[0].column).to eq(1)
173
173
 
174
- tokens[1].type.should == :VARIABLE
175
- tokens[1].value.should == 'bar'
176
- tokens[1].line.should == 1
177
- tokens[1].column.should == 3
174
+ expect(tokens[1].type).to eq(:VARIABLE)
175
+ expect(tokens[1].value).to eq('bar')
176
+ expect(tokens[1].line).to eq(1)
177
+ expect(tokens[1].column).to eq(3)
178
178
 
179
- tokens[2].type.should == :DQPOST
180
- tokens[2].value.should == ''
181
- tokens[2].line.should == 1
182
- tokens[2].column.should == 8
179
+ expect(tokens[2].type).to eq(:DQPOST)
180
+ expect(tokens[2].value).to eq('')
181
+ expect(tokens[2].line).to eq(1)
182
+ expect(tokens[2].column).to eq(8)
183
+ end
184
+
185
+ it 'should handle a variable with an array reference' do
186
+ @lexer.interpolate_string('${foo[bar][baz]}"', 1, 1)
187
+ tokens = @lexer.tokens
188
+
189
+ expect(tokens.length).to eq(3)
190
+
191
+ expect(tokens[0].type).to eq(:DQPRE)
192
+ expect(tokens[0].value).to eq('')
193
+ expect(tokens[0].line).to eq(1)
194
+ expect(tokens[0].column).to eq(1)
195
+
196
+ expect(tokens[1].type).to eq(:VARIABLE)
197
+ expect(tokens[1].value).to eq('foo[bar][baz]')
198
+ expect(tokens[1].line).to eq(1)
199
+ expect(tokens[1].column).to eq(3)
200
+
201
+ expect(tokens[2].type).to eq(:DQPOST)
202
+ expect(tokens[2].value).to eq('')
203
+ expect(tokens[2].line).to eq(1)
204
+ expect(tokens[2].column).to eq(18)
183
205
  end
184
206
 
185
207
  it 'should handle a string with only many variables' do
186
208
  @lexer.interpolate_string('${bar}${gronk}"', 1, 1)
187
209
  tokens = @lexer.tokens
188
210
 
189
- tokens.length.should == 5
211
+ expect(tokens.length).to eq(5)
190
212
 
191
- tokens[0].type.should == :DQPRE
192
- tokens[0].value.should == ''
193
- tokens[0].line.should == 1
194
- tokens[0].column.should == 1
213
+ expect(tokens[0].type).to eq(:DQPRE)
214
+ expect(tokens[0].value).to eq('')
215
+ expect(tokens[0].line).to eq(1)
216
+ expect(tokens[0].column).to eq(1)
195
217
 
196
- tokens[1].type.should == :VARIABLE
197
- tokens[1].value.should == 'bar'
198
- tokens[1].line.should == 1
199
- tokens[1].column.should == 3
218
+ expect(tokens[1].type).to eq(:VARIABLE)
219
+ expect(tokens[1].value).to eq('bar')
220
+ expect(tokens[1].line).to eq(1)
221
+ expect(tokens[1].column).to eq(3)
200
222
 
201
- tokens[2].type.should == :DQMID
202
- tokens[2].value.should == ''
203
- tokens[2].line.should == 1
204
- tokens[2].column.should == 8
223
+ expect(tokens[2].type).to eq(:DQMID)
224
+ expect(tokens[2].value).to eq('')
225
+ expect(tokens[2].line).to eq(1)
226
+ expect(tokens[2].column).to eq(8)
205
227
 
206
- tokens[3].type.should == :VARIABLE
207
- tokens[3].value.should == 'gronk'
208
- tokens[3].line.should == 1
209
- tokens[3].column.should == 9
228
+ expect(tokens[3].type).to eq(:VARIABLE)
229
+ expect(tokens[3].value).to eq('gronk')
230
+ expect(tokens[3].line).to eq(1)
231
+ expect(tokens[3].column).to eq(9)
210
232
 
211
- tokens[4].type.should == :DQPOST
212
- tokens[4].value.should == ''
213
- tokens[4].line.should == 1
214
- tokens[4].column.should == 16
233
+ expect(tokens[4].type).to eq(:DQPOST)
234
+ expect(tokens[4].value).to eq('')
235
+ expect(tokens[4].line).to eq(1)
236
+ expect(tokens[4].column).to eq(16)
215
237
  end
216
238
 
217
239
  it 'should handle a string with only an unenclosed variable' do
218
240
  @lexer.interpolate_string('$foo"', 1, 1)
219
241
  tokens = @lexer.tokens
220
242
 
221
- tokens.length.should == 3
243
+ expect(tokens.length).to eq(3)
222
244
 
223
- tokens[0].type.should == :DQPRE
224
- tokens[0].value.should == ''
225
- tokens[0].line.should == 1
226
- tokens[0].column.should == 1
245
+ expect(tokens[0].type).to eq(:DQPRE)
246
+ expect(tokens[0].value).to eq('')
247
+ expect(tokens[0].line).to eq(1)
248
+ expect(tokens[0].column).to eq(1)
227
249
 
228
- tokens[1].type.should == :UNENC_VARIABLE
229
- tokens[1].value.should == 'foo'
230
- tokens[1].line.should == 1
231
- tokens[1].column.should == 2
250
+ expect(tokens[1].type).to eq(:UNENC_VARIABLE)
251
+ expect(tokens[1].value).to eq('foo')
252
+ expect(tokens[1].line).to eq(1)
253
+ expect(tokens[1].column).to eq(2)
232
254
 
233
- tokens[2].type.should == :DQPOST
234
- tokens[2].value.should == ''
235
- tokens[2].line.should == 1
236
- tokens[2].column.should == 6
255
+ expect(tokens[2].type).to eq(:DQPOST)
256
+ expect(tokens[2].value).to eq('')
257
+ expect(tokens[2].line).to eq(1)
258
+ expect(tokens[2].column).to eq(6)
237
259
  end
238
260
 
239
261
  it 'should handle a string with a nested string inside it' do
240
262
  @lexer.interpolate_string(%q{string with ${'a nested single quoted string'} inside it"}, 1, 1)
241
263
  tokens = @lexer.tokens
242
264
 
243
- tokens.length.should == 3
265
+ expect(tokens.length).to eq(3)
244
266
 
245
- tokens[0].type.should == :DQPRE
246
- tokens[0].value.should == 'string with '
247
- tokens[0].line.should == 1
248
- tokens[0].column.should == 1
267
+ expect(tokens[0].type).to eq(:DQPRE)
268
+ expect(tokens[0].value).to eq('string with ')
269
+ expect(tokens[0].line).to eq(1)
270
+ expect(tokens[0].column).to eq(1)
249
271
 
250
- tokens[1].type.should == :SSTRING
251
- tokens[1].value.should == 'a nested single quoted string'
252
- tokens[1].line.should == 1
253
- tokens[1].column.should == 16
272
+ expect(tokens[1].type).to eq(:SSTRING)
273
+ expect(tokens[1].value).to eq('a nested single quoted string')
274
+ expect(tokens[1].line).to eq(1)
275
+ expect(tokens[1].column).to eq(16)
254
276
 
255
- tokens[2].type.should == :DQPOST
256
- tokens[2].value.should == ' inside it'
257
- tokens[2].line.should == 1
258
- tokens[2].column.should == 48
277
+ expect(tokens[2].type).to eq(:DQPOST)
278
+ expect(tokens[2].value).to eq(' inside it')
279
+ expect(tokens[2].line).to eq(1)
280
+ expect(tokens[2].column).to eq(48)
259
281
  end
260
282
 
261
283
  it 'should handle a string with nested math' do
262
284
  @lexer.interpolate_string(%q{string with ${(3+5)/4} nested math"}, 1, 1)
263
285
  tokens = @lexer.tokens
264
286
 
265
- tokens.length.should == 9
287
+ expect(tokens.length).to eq(9)
266
288
 
267
- tokens[0].type.should == :DQPRE
268
- tokens[0].value.should == 'string with '
269
- tokens[0].line.should == 1
270
- tokens[0].column.should == 1
289
+ expect(tokens[0].type).to eq(:DQPRE)
290
+ expect(tokens[0].value).to eq('string with ')
291
+ expect(tokens[0].line).to eq(1)
292
+ expect(tokens[0].column).to eq(1)
271
293
 
272
- tokens[1].type.should == :LPAREN
273
- tokens[1].line.should == 1
274
- tokens[1].column.should == 16
294
+ expect(tokens[1].type).to eq(:LPAREN)
295
+ expect(tokens[1].line).to eq(1)
296
+ expect(tokens[1].column).to eq(16)
275
297
 
276
- tokens[2].type.should == :NUMBER
277
- tokens[2].value.should == '3'
278
- tokens[2].line.should == 1
279
- tokens[2].column.should == 17
298
+ expect(tokens[2].type).to eq(:NUMBER)
299
+ expect(tokens[2].value).to eq('3')
300
+ expect(tokens[2].line).to eq(1)
301
+ expect(tokens[2].column).to eq(17)
280
302
 
281
- tokens[3].type.should == :PLUS
282
- tokens[3].line.should == 1
283
- tokens[3].column.should == 18
303
+ expect(tokens[3].type).to eq(:PLUS)
304
+ expect(tokens[3].line).to eq(1)
305
+ expect(tokens[3].column).to eq(18)
284
306
 
285
- tokens[4].type.should == :NUMBER
286
- tokens[4].value.should == '5'
287
- tokens[4].line.should == 1
288
- tokens[4].column.should == 19
307
+ expect(tokens[4].type).to eq(:NUMBER)
308
+ expect(tokens[4].value).to eq('5')
309
+ expect(tokens[4].line).to eq(1)
310
+ expect(tokens[4].column).to eq(19)
289
311
 
290
- tokens[5].type.should == :RPAREN
291
- tokens[5].line.should == 1
292
- tokens[5].column.should == 20
312
+ expect(tokens[5].type).to eq(:RPAREN)
313
+ expect(tokens[5].line).to eq(1)
314
+ expect(tokens[5].column).to eq(20)
293
315
 
294
- tokens[6].type.should == :DIV
295
- tokens[6].line.should == 1
296
- tokens[6].column.should == 21
316
+ expect(tokens[6].type).to eq(:DIV)
317
+ expect(tokens[6].line).to eq(1)
318
+ expect(tokens[6].column).to eq(21)
297
319
 
298
- tokens[7].type.should == :NUMBER
299
- tokens[7].value.should == '4'
300
- tokens[7].line.should == 1
301
- tokens[7].column.should == 22
320
+ expect(tokens[7].type).to eq(:NUMBER)
321
+ expect(tokens[7].value).to eq('4')
322
+ expect(tokens[7].line).to eq(1)
323
+ expect(tokens[7].column).to eq(22)
302
324
 
303
- tokens[8].type.should == :DQPOST
304
- tokens[8].value.should == ' nested math'
305
- tokens[8].line.should == 1
306
- tokens[8].column.should == 24
325
+ expect(tokens[8].type).to eq(:DQPOST)
326
+ expect(tokens[8].value).to eq(' nested math')
327
+ expect(tokens[8].line).to eq(1)
328
+ expect(tokens[8].column).to eq(24)
307
329
  end
308
330
 
309
331
  it 'should handle a string with a nested array' do
310
332
  @lexer.interpolate_string(%q{string with ${['an array ', $v2]} in it"}, 1, 1)
311
333
  tokens = @lexer.tokens
312
334
 
313
- tokens.length.should == 8
335
+ expect(tokens.length).to eq(8)
314
336
 
315
- tokens[0].type.should == :DQPRE
316
- tokens[0].value.should == 'string with '
317
- tokens[0].line.should == 1
318
- tokens[0].column.should == 1
337
+ expect(tokens[0].type).to eq(:DQPRE)
338
+ expect(tokens[0].value).to eq('string with ')
339
+ expect(tokens[0].line).to eq(1)
340
+ expect(tokens[0].column).to eq(1)
319
341
 
320
- tokens[1].type.should == :LBRACK
321
- tokens[1].line.should == 1
322
- tokens[1].column.should == 16
342
+ expect(tokens[1].type).to eq(:LBRACK)
343
+ expect(tokens[1].line).to eq(1)
344
+ expect(tokens[1].column).to eq(16)
323
345
 
324
- tokens[2].type.should == :SSTRING
325
- tokens[2].value.should == 'an array '
326
- tokens[2].line.should == 1
327
- tokens[2].column.should == 17
346
+ expect(tokens[2].type).to eq(:SSTRING)
347
+ expect(tokens[2].value).to eq('an array ')
348
+ expect(tokens[2].line).to eq(1)
349
+ expect(tokens[2].column).to eq(17)
328
350
 
329
- tokens[3].type.should == :COMMA
330
- tokens[3].line.should == 1
331
- tokens[3].column.should == 28
351
+ expect(tokens[3].type).to eq(:COMMA)
352
+ expect(tokens[3].line).to eq(1)
353
+ expect(tokens[3].column).to eq(28)
332
354
 
333
- tokens[4].type.should == :WHITESPACE
334
- tokens[4].value.should == ' '
335
- tokens[4].line.should == 1
336
- tokens[4].column.should == 29
355
+ expect(tokens[4].type).to eq(:WHITESPACE)
356
+ expect(tokens[4].value).to eq(' ')
357
+ expect(tokens[4].line).to eq(1)
358
+ expect(tokens[4].column).to eq(29)
337
359
 
338
- tokens[5].type.should == :VARIABLE
339
- tokens[5].value.should == 'v2'
340
- tokens[5].line.should == 1
341
- tokens[5].column.should == 30
360
+ expect(tokens[5].type).to eq(:VARIABLE)
361
+ expect(tokens[5].value).to eq('v2')
362
+ expect(tokens[5].line).to eq(1)
363
+ expect(tokens[5].column).to eq(30)
342
364
 
343
- tokens[6].type.should == :RBRACK
344
- tokens[6].line.should == 1
345
- tokens[6].column.should == 33
365
+ expect(tokens[6].type).to eq(:RBRACK)
366
+ expect(tokens[6].line).to eq(1)
367
+ expect(tokens[6].column).to eq(33)
346
368
 
347
- tokens[7].type.should == :DQPOST
348
- tokens[7].value.should == ' in it'
349
- tokens[7].line.should == 1
350
- tokens[7].column.should == 35
369
+ expect(tokens[7].type).to eq(:DQPOST)
370
+ expect(tokens[7].value).to eq(' in it')
371
+ expect(tokens[7].line).to eq(1)
372
+ expect(tokens[7].column).to eq(35)
351
373
  end
352
374
 
353
375
  it 'should handle a string of $s' do
354
376
  @lexer.interpolate_string(%q{$$$$"}, 1, 1)
355
377
  tokens = @lexer.tokens
356
378
 
357
- tokens.length.should == 1
379
+ expect(tokens.length).to eq(1)
358
380
 
359
- tokens[0].type.should == :STRING
360
- tokens[0].value.should == '$$$$'
361
- tokens[0].line.should == 1
362
- tokens[0].column.should == 1
381
+ expect(tokens[0].type).to eq(:STRING)
382
+ expect(tokens[0].value).to eq('$$$$')
383
+ expect(tokens[0].line).to eq(1)
384
+ expect(tokens[0].column).to eq(1)
363
385
  end
364
386
 
365
387
  it 'should handle "$foo$bar"' do
366
388
  @lexer.interpolate_string(%q{$foo$bar"}, 1, 1)
367
389
  tokens = @lexer.tokens
368
390
 
369
- tokens.length.should == 5
391
+ expect(tokens.length).to eq(5)
370
392
 
371
- tokens[0].type.should == :DQPRE
372
- tokens[0].value.should == ''
373
- tokens[0].line.should == 1
374
- tokens[0].column.should == 1
393
+ expect(tokens[0].type).to eq(:DQPRE)
394
+ expect(tokens[0].value).to eq('')
395
+ expect(tokens[0].line).to eq(1)
396
+ expect(tokens[0].column).to eq(1)
375
397
 
376
- tokens[1].type.should == :UNENC_VARIABLE
377
- tokens[1].value.should == 'foo'
378
- tokens[1].line.should == 1
379
- tokens[1].column.should == 2
398
+ expect(tokens[1].type).to eq(:UNENC_VARIABLE)
399
+ expect(tokens[1].value).to eq('foo')
400
+ expect(tokens[1].line).to eq(1)
401
+ expect(tokens[1].column).to eq(2)
380
402
 
381
- tokens[2].type.should == :DQMID
382
- tokens[2].value.should == ''
383
- tokens[2].line.should == 1
384
- tokens[2].column.should == 6
403
+ expect(tokens[2].type).to eq(:DQMID)
404
+ expect(tokens[2].value).to eq('')
405
+ expect(tokens[2].line).to eq(1)
406
+ expect(tokens[2].column).to eq(6)
385
407
 
386
- tokens[3].type.should == :UNENC_VARIABLE
387
- tokens[3].value.should == 'bar'
388
- tokens[3].line.should == 1
389
- tokens[3].column.should == 6
408
+ expect(tokens[3].type).to eq(:UNENC_VARIABLE)
409
+ expect(tokens[3].value).to eq('bar')
410
+ expect(tokens[3].line).to eq(1)
411
+ expect(tokens[3].column).to eq(6)
390
412
 
391
- tokens[4].type.should == :DQPOST
392
- tokens[4].value.should == ''
393
- tokens[4].line.should == 1
394
- tokens[4].column.should == 10
413
+ expect(tokens[4].type).to eq(:DQPOST)
414
+ expect(tokens[4].value).to eq('')
415
+ expect(tokens[4].line).to eq(1)
416
+ expect(tokens[4].column).to eq(10)
395
417
  end
396
418
 
397
419
  it 'should handle "foo$bar$"' do
398
420
  @lexer.interpolate_string(%q{foo$bar$"}, 1, 1)
399
421
  tokens = @lexer.tokens
400
422
 
401
- tokens.length.should == 3
423
+ expect(tokens.length).to eq(3)
402
424
 
403
- tokens[0].type.should == :DQPRE
404
- tokens[0].value.should == 'foo'
405
- tokens[0].line.should == 1
406
- tokens[0].column.should == 1
425
+ expect(tokens[0].type).to eq(:DQPRE)
426
+ expect(tokens[0].value).to eq('foo')
427
+ expect(tokens[0].line).to eq(1)
428
+ expect(tokens[0].column).to eq(1)
407
429
 
408
- tokens[1].type.should == :UNENC_VARIABLE
409
- tokens[1].value.should == 'bar'
410
- tokens[1].line.should == 1
411
- tokens[1].column.should == 5
430
+ expect(tokens[1].type).to eq(:UNENC_VARIABLE)
431
+ expect(tokens[1].value).to eq('bar')
432
+ expect(tokens[1].line).to eq(1)
433
+ expect(tokens[1].column).to eq(5)
412
434
 
413
- tokens[2].type.should == :DQPOST
414
- tokens[2].value.should == '$'
415
- tokens[2].line.should == 1
416
- tokens[2].column.should == 9
435
+ expect(tokens[2].type).to eq(:DQPOST)
436
+ expect(tokens[2].value).to eq('$')
437
+ expect(tokens[2].line).to eq(1)
438
+ expect(tokens[2].column).to eq(9)
417
439
  end
418
440
 
419
441
  it 'should handle "foo$$bar"' do
420
442
  @lexer.interpolate_string(%q{foo$$bar"}, 1, 1)
421
443
  tokens = @lexer.tokens
422
444
 
423
- tokens.length.should == 3
445
+ expect(tokens.length).to eq(3)
424
446
 
425
- tokens[0].type.should == :DQPRE
426
- tokens[0].value.should == 'foo$'
427
- tokens[0].line.should == 1
428
- tokens[0].column.should == 1
447
+ expect(tokens[0].type).to eq(:DQPRE)
448
+ expect(tokens[0].value).to eq('foo$')
449
+ expect(tokens[0].line).to eq(1)
450
+ expect(tokens[0].column).to eq(1)
429
451
 
430
- tokens[1].type.should == :UNENC_VARIABLE
431
- tokens[1].value.should == 'bar'
432
- tokens[1].line.should == 1
433
- tokens[1].column.should == 6
452
+ expect(tokens[1].type).to eq(:UNENC_VARIABLE)
453
+ expect(tokens[1].value).to eq('bar')
454
+ expect(tokens[1].line).to eq(1)
455
+ expect(tokens[1].column).to eq(6)
434
456
 
435
- tokens[2].type.should == :DQPOST
436
- tokens[2].value.should == ''
437
- tokens[2].line.should == 1
438
- tokens[2].column.should == 10
457
+ expect(tokens[2].type).to eq(:DQPOST)
458
+ expect(tokens[2].value).to eq('')
459
+ expect(tokens[2].line).to eq(1)
460
+ expect(tokens[2].column).to eq(10)
439
461
  end
440
462
 
441
463
  it 'should handle an empty string' do
442
464
  @lexer.interpolate_string(%q{"}, 1, 1)
443
465
  tokens = @lexer.tokens
444
466
 
445
- tokens.length.should == 1
467
+ expect(tokens.length).to eq(1)
446
468
 
447
- tokens[0].type.should == :STRING
448
- tokens[0].value.should == ''
449
- tokens[0].line.should == 1
450
- tokens[0].column.should == 1
469
+ expect(tokens[0].type).to eq(:STRING)
470
+ expect(tokens[0].value).to eq('')
471
+ expect(tokens[0].line).to eq(1)
472
+ expect(tokens[0].column).to eq(1)
451
473
  end
452
474
 
453
475
  it 'should handle "$foo::::bar"' do
454
476
  @lexer.interpolate_string(%q{$foo::::bar"}, 1, 1)
455
477
  tokens = @lexer.tokens
456
478
 
457
- tokens.length.should == 3
479
+ expect(tokens.length).to eq(3)
458
480
 
459
- tokens[0].type.should == :DQPRE
460
- tokens[0].value.should == ''
461
- tokens[0].line.should == 1
462
- tokens[0].column.should == 1
481
+ expect(tokens[0].type).to eq(:DQPRE)
482
+ expect(tokens[0].value).to eq('')
483
+ expect(tokens[0].line).to eq(1)
484
+ expect(tokens[0].column).to eq(1)
463
485
 
464
- tokens[1].type.should == :UNENC_VARIABLE
465
- tokens[1].value.should == 'foo'
466
- tokens[1].line.should == 1
467
- tokens[1].column.should == 2
486
+ expect(tokens[1].type).to eq(:UNENC_VARIABLE)
487
+ expect(tokens[1].value).to eq('foo')
488
+ expect(tokens[1].line).to eq(1)
489
+ expect(tokens[1].column).to eq(2)
468
490
 
469
- tokens[2].type.should == :DQPOST
470
- tokens[2].value.should == '::::bar'
471
- tokens[2].line.should == 1
472
- tokens[2].column.should == 6
491
+ expect(tokens[2].type).to eq(:DQPOST)
492
+ expect(tokens[2].value).to eq('::::bar')
493
+ expect(tokens[2].line).to eq(1)
494
+ expect(tokens[2].column).to eq(6)
473
495
  end
474
496
  end
475
497
 
@@ -494,8 +516,8 @@ describe PuppetLint::Lexer do
494
516
  ].each do |keyword|
495
517
  it "should handle '#{keyword}' as a keyword" do
496
518
  token = @lexer.tokenise(keyword).first
497
- token.type.should == keyword.upcase.to_sym
498
- token.value.should == keyword
519
+ expect(token.type).to eq(keyword.upcase.to_sym)
520
+ expect(token.value).to eq(keyword)
499
521
  end
500
522
  end
501
523
 
@@ -532,6 +554,8 @@ describe PuppetLint::Lexer do
532
554
  [:MINUS, '-'],
533
555
  [:DIV, '/'],
534
556
  [:TIMES, '*'],
557
+ [:MODULO, '%'],
558
+ [:PIPE, '|'],
535
559
  [:LSHIFT, '<<'],
536
560
  [:RSHIFT, '>>'],
537
561
  [:MATCH, '=~'],
@@ -540,205 +564,208 @@ describe PuppetLint::Lexer do
540
564
  [:OUT_EDGE, '<-'],
541
565
  [:IN_EDGE_SUB, '~>'],
542
566
  [:OUT_EDGE_SUB, '<~'],
567
+ [:NEWLINE, "\r"],
568
+ [:NEWLINE, "\n"],
569
+ [:NEWLINE, "\r\n"],
543
570
  ].each do |name, string|
544
571
  it "should have a token named '#{name.to_s}'" do
545
572
  token = @lexer.tokenise(string).first
546
- token.type.should == name
547
- token.value.should == string
573
+ expect(token.type).to eq(name)
574
+ expect(token.value).to eq(string)
548
575
  end
549
576
  end
550
577
 
551
578
  context ':CLASSREF' do
552
579
  it 'should match single capitalised alphanumeric term' do
553
580
  token = @lexer.tokenise('One').first
554
- token.type.should == :CLASSREF
555
- token.value.should == 'One'
581
+ expect(token.type).to eq(:CLASSREF)
582
+ expect(token.value).to eq('One')
556
583
  end
557
584
 
558
585
  it 'should match two capitalised alphanumeric terms sep by ::' do
559
586
  token = @lexer.tokenise('One::Two').first
560
- token.type.should == :CLASSREF
561
- token.value.should == 'One::Two'
587
+ expect(token.type).to eq(:CLASSREF)
588
+ expect(token.value).to eq('One::Two')
562
589
  end
563
590
 
564
591
  it 'should match many capitalised alphanumeric terms sep by ::' do
565
592
  token = @lexer.tokenise('One::Two::Three::Four::Five').first
566
- token.type.should == :CLASSREF
567
- token.value.should == 'One::Two::Three::Four::Five'
593
+ expect(token.type).to eq(:CLASSREF)
594
+ expect(token.value).to eq('One::Two::Three::Four::Five')
568
595
  end
569
596
 
570
597
  it 'should match capitalised terms prefixed by ::' do
571
598
  token = @lexer.tokenise('::One').first
572
- token.type.should == :CLASSREF
573
- token.value.should == '::One'
599
+ expect(token.type).to eq(:CLASSREF)
600
+ expect(token.value).to eq('::One')
574
601
  end
575
602
  end
576
603
 
577
604
  context ':NAME' do
578
605
  it 'should match lowercase alphanumeric terms' do
579
606
  token = @lexer.tokenise('one-two').first
580
- token.type.should == :NAME
581
- token.value.should == 'one-two'
607
+ expect(token.type).to eq(:NAME)
608
+ expect(token.value).to eq('one-two')
582
609
  end
583
610
 
584
611
  it 'should match lowercase alphanumeric terms sep by ::' do
585
612
  token = @lexer.tokenise('one::two').first
586
- token.type.should == :NAME
587
- token.value.should == 'one::two'
613
+ expect(token.type).to eq(:NAME)
614
+ expect(token.value).to eq('one::two')
588
615
  end
589
616
 
590
617
  it 'should match many lowercase alphanumeric terms sep by ::' do
591
618
  token = @lexer.tokenise('one::two::three::four::five').first
592
- token.type.should == :NAME
593
- token.value.should == 'one::two::three::four::five'
619
+ expect(token.type).to eq(:NAME)
620
+ expect(token.value).to eq('one::two::three::four::five')
594
621
  end
595
622
 
596
623
  it 'should match lowercase alphanumeric terms prefixed by ::' do
597
624
  token = @lexer.tokenise('::1one::2two::3three').first
598
- token.type.should == :NAME
599
- token.value.should == '::1one::2two::3three'
625
+ expect(token.type).to eq(:NAME)
626
+ expect(token.value).to eq('::1one::2two::3three')
600
627
  end
601
628
  end
602
629
 
603
630
  context ':NUMBER' do
604
631
  it 'should match numeric terms' do
605
632
  token = @lexer.tokenise('1234567890').first
606
- token.type.should == :NUMBER
607
- token.value.should == '1234567890'
633
+ expect(token.type).to eq(:NUMBER)
634
+ expect(token.value).to eq('1234567890')
608
635
  end
609
636
 
610
637
  it 'should match float terms' do
611
638
  token = @lexer.tokenise('12345.6789').first
612
- token.type.should == :NUMBER
613
- token.value.should == '12345.6789'
639
+ expect(token.type).to eq(:NUMBER)
640
+ expect(token.value).to eq('12345.6789')
614
641
  end
615
642
 
616
643
  it 'should match hexadecimal terms' do
617
644
  token = @lexer.tokenise('0xCAFE1029').first
618
- token.type.should == :NUMBER
619
- token.value.should == '0xCAFE1029'
645
+ expect(token.type).to eq(:NUMBER)
646
+ expect(token.value).to eq('0xCAFE1029')
620
647
  end
621
648
 
622
649
  it 'should match float with exponent terms' do
623
650
  token = @lexer.tokenise('10e23').first
624
- token.type.should == :NUMBER
625
- token.value.should == '10e23'
651
+ expect(token.type).to eq(:NUMBER)
652
+ expect(token.value).to eq('10e23')
626
653
  end
627
654
 
628
655
  it 'should match float with negative exponent terms' do
629
656
  token = @lexer.tokenise('10e-23').first
630
- token.type.should == :NUMBER
631
- token.value.should == '10e-23'
657
+ expect(token.type).to eq(:NUMBER)
658
+ expect(token.value).to eq('10e-23')
632
659
  end
633
660
 
634
661
  it 'should match float with exponent terms' do
635
662
  token = @lexer.tokenise('1.234e5').first
636
- token.type.should == :NUMBER
637
- token.value.should == '1.234e5'
663
+ expect(token.type).to eq(:NUMBER)
664
+ expect(token.value).to eq('1.234e5')
638
665
  end
639
666
  end
640
667
 
641
668
  context ':COMMENT' do
642
669
  it 'should match everything on a line after #' do
643
670
  token = @lexer.tokenise('foo # bar baz')[2]
644
- token.type.should == :COMMENT
645
- token.value.should == 'bar baz'
671
+ expect(token.type).to eq(:COMMENT)
672
+ expect(token.value).to eq(' bar baz')
646
673
  end
647
674
  end
648
675
 
649
676
  context ':MLCOMMENT' do
650
677
  it 'should match comments on a single line' do
651
678
  token = @lexer.tokenise('/* foo bar */').first
652
- token.type.should == :MLCOMMENT
653
- token.value.should == 'foo bar'
679
+ expect(token.type).to eq(:MLCOMMENT)
680
+ expect(token.value).to eq('foo bar')
654
681
  end
655
682
 
656
683
  it 'should match comments on multiple lines' do
657
684
  token = @lexer.tokenise("/* foo\n * bar\n*/").first
658
- token.type.should == :MLCOMMENT
659
- token.value.should == "foo\nbar"
685
+ expect(token.type).to eq(:MLCOMMENT)
686
+ expect(token.value).to eq("foo\nbar")
660
687
  end
661
688
  end
662
689
 
663
690
  context ':SLASH_COMMENT' do
664
691
  it 'should match everyone on a line after //' do
665
692
  token = @lexer.tokenise('foo // bar baz')[2]
666
- token.type.should == :SLASH_COMMENT
667
- token.value.should == 'bar baz'
693
+ expect(token.type).to eq(:SLASH_COMMENT)
694
+ expect(token.value).to eq(' bar baz')
668
695
  end
669
696
  end
670
697
 
671
698
  context ':SSTRING' do
672
699
  it 'should match a single quoted string' do
673
700
  token = @lexer.tokenise("'single quoted string'").first
674
- token.type.should == :SSTRING
675
- token.value.should == 'single quoted string'
701
+ expect(token.type).to eq(:SSTRING)
702
+ expect(token.value).to eq('single quoted string')
676
703
  end
677
704
 
678
705
  it "should match a single quoted string with an escaped '" do
679
706
  token = @lexer.tokenise(%q{'single quoted string with "\\'"'}).first
680
- token.type.should == :SSTRING
681
- token.value.should == 'single quoted string with "\\\'"'
707
+ expect(token.type).to eq(:SSTRING)
708
+ expect(token.value).to eq('single quoted string with "\\\'"')
682
709
  end
683
710
 
684
711
  it "should match a single quoted string with an escaped $" do
685
712
  token = @lexer.tokenise(%q{'single quoted string with "\$"'}).first
686
- token.type.should == :SSTRING
687
- token.value.should == 'single quoted string with "\\$"'
713
+ expect(token.type).to eq(:SSTRING)
714
+ expect(token.value).to eq('single quoted string with "\\$"')
688
715
  end
689
716
 
690
717
  it "should match a single quoted string with an escaped ." do
691
718
  token = @lexer.tokenise(%q{'single quoted string with "\."'}).first
692
- token.type.should == :SSTRING
693
- token.value.should == 'single quoted string with "\\."'
719
+ expect(token.type).to eq(:SSTRING)
720
+ expect(token.value).to eq('single quoted string with "\\."')
694
721
  end
695
722
 
696
723
  it "should match a single quoted string with an escaped \\n" do
697
724
  token = @lexer.tokenise(%q{'single quoted string with "\n"'}).first
698
- token.type.should == :SSTRING
699
- token.value.should == 'single quoted string with "\\n"'
725
+ expect(token.type).to eq(:SSTRING)
726
+ expect(token.value).to eq('single quoted string with "\\n"')
700
727
  end
701
728
 
702
729
  it "should match a single quoted string with an escaped \\" do
703
730
  token = @lexer.tokenise(%q{'single quoted string with "\\\\"'}).first
704
- token.type.should == :SSTRING
705
- token.value.should == 'single quoted string with "\\\\"'
731
+ expect(token.type).to eq(:SSTRING)
732
+ expect(token.value).to eq('single quoted string with "\\\\"')
706
733
  end
707
734
 
708
735
  it "should match an empty string" do
709
736
  token = @lexer.tokenise("''").first
710
- token.type.should == :SSTRING
711
- token.value.should == ''
737
+ expect(token.type).to eq(:SSTRING)
738
+ expect(token.value).to eq('')
712
739
  end
713
740
 
714
741
  it "should match an empty string ending with \\\\" do
715
742
  token = @lexer.tokenise("'foo\\\\'").first
716
- token.type.should == :SSTRING
717
- token.value.should == %{foo\\\\}
743
+ expect(token.type).to eq(:SSTRING)
744
+ expect(token.value).to eq(%{foo\\\\})
718
745
  end
719
746
  end
720
747
 
721
748
  context ':REGEX' do
722
749
  it 'should match anything enclosed in //' do
723
750
  token = @lexer.tokenise('/this is a regex/').first
724
- token.type.should == :REGEX
725
- token.value.should == 'this is a regex'
751
+ expect(token.type).to eq(:REGEX)
752
+ expect(token.value).to eq('this is a regex')
726
753
  end
727
754
 
728
755
  it 'should not match if there is \n in the regex' do
729
756
  token = @lexer.tokenise("/this is \n a regex/").first
730
- token.type.should_not == :REGEX
757
+ expect(token.type).to_not eq(:REGEX)
731
758
  end
732
759
 
733
760
  it 'should not consider \/ to be the end of the regex' do
734
761
  token = @lexer.tokenise('/this is \/ a regex/').first
735
- token.type.should == :REGEX
736
- token.value.should == 'this is \\/ a regex'
762
+ expect(token.type).to eq(:REGEX)
763
+ expect(token.value).to eq('this is \\/ a regex')
737
764
  end
738
765
 
739
766
  it 'should not match chained division' do
740
767
  tokens = @lexer.tokenise('$x = $a/$b/$c')
741
- tokens.select { |r| r.type == :REGEX }.should == []
768
+ expect(tokens.select { |r| r.type == :REGEX }).to be_empty
742
769
  end
743
770
  end
744
771
 
@@ -746,7 +773,7 @@ describe PuppetLint::Lexer do
746
773
  it 'should parse strings with \\\\\\' do
747
774
  expect {
748
775
  @lexer.tokenise("exec { \"/bin/echo \\\\\\\"${environment}\\\\\\\"\": }")
749
- }.to_not raise_error(PuppetLint::LexerError)
776
+ }.to_not raise_error
750
777
  end
751
778
  end
752
779
  end