foodcritic 7.0.1 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Given 'a cookbook attributes file that declares and refers to a local variable' do
1
+ Given "a cookbook attributes file that declares and refers to a local variable" do
2
2
  write_attributes %q{
3
3
  master = search(:nodes, 'foo:master')
4
4
  default[:foo][:master] = master
@@ -11,21 +11,21 @@ Given /^a cookbook attributes file that refers to an attribute with (.*)$/ do |r
11
11
  }
12
12
  end
13
13
 
14
- Given 'a cookbook attributes file that sets an attribute to be the result of a library call' do
14
+ Given "a cookbook attributes file that sets an attribute to be the result of a library call" do
15
15
  write_attributes %q{
16
16
  ::Chef::Node.send(:include, Opscode::OpenSSL::Password)
17
17
  default[:admin_password] = secure_password
18
18
  }
19
19
  end
20
20
 
21
- Given 'a cookbook attributes file with a brace block that takes arguments' do
21
+ Given "a cookbook attributes file with a brace block that takes arguments" do
22
22
  write_attributes %q{
23
23
  foo = {'foo' => 'bar'}
24
24
  foo.each{|k, v| default['waka'][k] = v}
25
25
  }
26
26
  end
27
27
 
28
- Given 'a cookbook attributes file with a do block that takes arguments' do
28
+ Given "a cookbook attributes file with a do block that takes arguments" do
29
29
  write_attributes %q{
30
30
  foo = {'foo' => 'bar'}
31
31
  foo.each do |k, v|
@@ -34,14 +34,14 @@ Given 'a cookbook attributes file with a do block that takes arguments' do
34
34
  }
35
35
  end
36
36
 
37
- Given 'a cookbook attributes file that sets an attribute to have line break' do
37
+ Given "a cookbook attributes file that sets an attribute to have line break" do
38
38
  write_attributes %q{
39
39
  default['foo']['bar']['baz'][
40
40
  'bing']['blonk'] = 'stupendous'
41
41
  }
42
42
  end
43
43
 
44
- Given 'a cookbook attributes file that sets an attribute to have line break and arguments' do
44
+ Given "a cookbook attributes file that sets an attribute to have line break and arguments" do
45
45
  write_attributes %q{
46
46
  %w{ foo bar }.each do |baz|
47
47
  default['foo']["bing_#{baz}"][
@@ -51,7 +51,7 @@ Given 'a cookbook attributes file that sets an attribute to have line break and
51
51
  end
52
52
 
53
53
  Given /^a cookbook (attributes|recipe) file with assignment (.*)$/ do |type, assignment|
54
- if type == 'attributes'
54
+ if type == "attributes"
55
55
  write_attributes assignment
56
56
  else
57
57
  write_recipe assignment
@@ -117,8 +117,8 @@ Given /^a cookbook recipe that spawns a sub-process with (.*)$/ do |command|
117
117
  write_recipe command
118
118
  end
119
119
 
120
- Given 'a provider that contains a ruby_block resource that spawns a sub-process with system' do
121
- write_provider 'site', %q{
120
+ Given "a provider that contains a ruby_block resource that spawns a sub-process with system" do
121
+ write_provider "site", %q{
122
122
  action :install do
123
123
  ruby_block "ruby" do
124
124
  block do
@@ -129,7 +129,7 @@ Given 'a provider that contains a ruby_block resource that spawns a sub-process
129
129
  }
130
130
  end
131
131
 
132
- Given 'a cookbook recipe with a deploy resource that contains a template resource' do
132
+ Given "a cookbook recipe with a deploy resource that contains a template resource" do
133
133
  write_recipe %q{
134
134
  deploy '/foo/bar' do
135
135
  before_restart do
@@ -147,7 +147,7 @@ Given 'a cookbook recipe with a deploy resource that contains a template resourc
147
147
  }
148
148
  end
149
149
 
150
- Given 'a cookbook recipe with a resource that notifies where the action is an expression' do
150
+ Given "a cookbook recipe with a resource that notifies where the action is an expression" do
151
151
  write_recipe %q{
152
152
  notify_action = node['platform_family'] == "mac_os_x" ? :restart : :reload
153
153
 
@@ -184,7 +184,7 @@ Given /^a cookbook recipe that refers to (node.*)$/ do |reference|
184
184
  }
185
185
  end
186
186
 
187
- Given 'a cookbook recipe that refers to an attribute with a bare keyword' do
187
+ Given "a cookbook recipe that refers to an attribute with a bare keyword" do
188
188
  write_recipe %q{
189
189
  node['myhostname'] = hostname
190
190
  }
@@ -198,8 +198,8 @@ Given /^a cookbook recipe that wraps a platform\-specific resource in a (.*) con
198
198
  }
199
199
  end
200
200
 
201
- Given 'a cookbook provider that declares execute resources varying only in the command in separate actions' do
202
- write_provider 'site', %q{
201
+ Given "a cookbook provider that declares execute resources varying only in the command in separate actions" do
202
+ write_provider "site", %q{
203
203
  action :start do
204
204
  execute "foo" do
205
205
  action :run
@@ -221,8 +221,8 @@ Given 'a cookbook provider that declares execute resources varying only in the c
221
221
  }.strip
222
222
  end
223
223
 
224
- Given 'a cookbook provider that declares execute resources varying only in the command in the same action' do
225
- write_provider 'site', %q{
224
+ Given "a cookbook provider that declares execute resources varying only in the command in the same action" do
225
+ write_provider "site", %q{
226
226
  action :start do
227
227
  execute "foo" do
228
228
  action :run
@@ -239,10 +239,10 @@ Given 'a cookbook provider that declares execute resources varying only in the c
239
239
  end
240
240
 
241
241
  Given /^a cookbook recipe that attempts to perform a search with (.*)$/ do |search_type|
242
- recipe_with_search(search_type.include?('subexpression') ? :with_subexpression : search_type.tr(' ', '_').to_sym)
242
+ recipe_with_search(search_type.include?("subexpression") ? :with_subexpression : search_type.tr(" ", "_").to_sym)
243
243
  end
244
244
 
245
- Given /^a cookbook recipe that declares a resource called ([^ ]+) with the condition (.*)(in|outside) a loop$/ do |name,condition,is_loop|
245
+ Given /^a cookbook recipe that declares a resource called ([^ ]+) with the condition (.*)(in|outside) a loop$/ do |name, condition, is_loop|
246
246
  write_recipe %Q{
247
247
  #{'%w{rover fido}.each do |pet_name|' if is_loop == 'in'}
248
248
  execute #{name} do
@@ -256,7 +256,7 @@ end
256
256
  Given /^a cookbook recipe that declares (a resource|multiple resources) nested in a ([a-z_]+) condition with (.*)$/ do |arity, wrapping_condition, condition_attribute|
257
257
  blk = "{ File.exists?('/etc/passwd') }"
258
258
  str = "'test -f /etc/passwd'"
259
- conds = wrapping_condition.split('_')
259
+ conds = wrapping_condition.split("_")
260
260
  write_recipe %Q{
261
261
  #{conds.first} node['foo'] == 'bar'
262
262
  service "apache" do
@@ -295,7 +295,7 @@ Given /^a cookbook recipe (?:that declares a resource with no conditions at all|
295
295
  }
296
296
  end
297
297
 
298
- Given 'a cookbook recipe that declares multiple directories with different file modes' do
298
+ Given "a cookbook recipe that declares multiple directories with different file modes" do
299
299
  write_recipe %q{
300
300
  directory "#{node["nagios"]["dir"]}/dist" do
301
301
  owner "nagios"
@@ -317,7 +317,7 @@ Given 'a cookbook recipe that declares multiple directories with different file
317
317
  }
318
318
  end
319
319
 
320
- Given 'a cookbook recipe that declares multiple package resources mixed with other resources' do
320
+ Given "a cookbook recipe that declares multiple package resources mixed with other resources" do
321
321
  write_recipe %q{
322
322
  package "erlang-base" do
323
323
  action :install
@@ -344,29 +344,29 @@ Given 'a cookbook recipe that declares multiple package resources mixed with oth
344
344
  end
345
345
 
346
346
  Given /^a cookbook recipe that declares multiple (varying|non-varying) template resources within a block$/ do |vary|
347
- do_vary = vary == 'varying'
348
- write_recipe %Q{
349
- node['apps'].each do |app|
350
- template "/etc/#\{app\}.conf" do
351
- owner "root"
352
- group "root"
353
- #{'mode "0600"' if do_vary}
354
- end
355
- template "/etc/init.d/#\{app\}" do
356
- owner "root"
357
- group "root"
358
- #{'mode "0700"' if do_vary}
359
- end
360
- template "/home/#\{app\}/foo" do
361
- owner "root"
362
- group "root"
363
- #{'mode "0600"' if do_vary}
364
- end
365
- end
366
- }
367
- end
368
-
369
- Given 'a cookbook recipe that declares multiple resources varying only in the package name' do
347
+ do_vary = vary == "varying"
348
+ write_recipe %Q{
349
+ node['apps'].each do |app|
350
+ template "/etc/#\{app\}.conf" do
351
+ owner "root"
352
+ group "root"
353
+ #{'mode "0600"' if do_vary}
354
+ end
355
+ template "/etc/init.d/#\{app\}" do
356
+ owner "root"
357
+ group "root"
358
+ #{'mode "0700"' if do_vary}
359
+ end
360
+ template "/home/#\{app\}/foo" do
361
+ owner "root"
362
+ group "root"
363
+ #{'mode "0600"' if do_vary}
364
+ end
365
+ end
366
+ }
367
+ end
368
+
369
+ Given "a cookbook recipe that declares multiple resources varying only in the package name" do
370
370
  write_recipe %q{
371
371
  package "erlang-base" do
372
372
  action :install
@@ -383,7 +383,7 @@ Given 'a cookbook recipe that declares multiple resources varying only in the pa
383
383
  }
384
384
  end
385
385
 
386
- Given 'a cookbook recipe that declares multiple resources with more variation' do
386
+ Given "a cookbook recipe that declares multiple resources with more variation" do
387
387
  write_recipe %q{
388
388
  package "erlang-base" do
389
389
  action :install
@@ -401,7 +401,7 @@ Given 'a cookbook recipe that declares multiple resources with more variation' d
401
401
  }
402
402
  end
403
403
 
404
- Given 'a cookbook recipe that declares non contiguous package resources mixed with other resources' do
404
+ Given "a cookbook recipe that declares non contiguous package resources mixed with other resources" do
405
405
  write_recipe %q{
406
406
  package "erlang-base" do
407
407
  action :install
@@ -424,7 +424,7 @@ Given 'a cookbook recipe that declares non contiguous package resources mixed wi
424
424
  }
425
425
  end
426
426
 
427
- Given 'a cookbook recipe that declares two or fewer resources varying only in the package name' do
427
+ Given "a cookbook recipe that declares two or fewer resources varying only in the package name" do
428
428
  write_recipe %q{
429
429
  package "erlang-base" do
430
430
  action :install
@@ -441,7 +441,7 @@ Given 'a cookbook recipe that has a confusingly named local variable "default"'
441
441
  }
442
442
  end
443
443
 
444
- Given 'a cookbook recipe that has a wrapping condition containing a resource with no condition attribute and a Ruby statement' do
444
+ Given "a cookbook recipe that has a wrapping condition containing a resource with no condition attribute and a Ruby statement" do
445
445
  write_recipe %q{
446
446
  if node['foo'] == 'bar'
447
447
  Chef::Log.info "Enabling apache to start at boot"
@@ -452,7 +452,7 @@ Given 'a cookbook recipe that has a wrapping condition containing a resource wit
452
452
  }
453
453
  end
454
454
 
455
- Given 'a cookbook recipe that has a wrapping condition containing a resource with no condition attribute within a loop' do
455
+ Given "a cookbook recipe that has a wrapping condition containing a resource with no condition attribute within a loop" do
456
456
  write_recipe %q{
457
457
  unless node['bar'].include? 'something'
458
458
  bars.each do |bar|
@@ -465,7 +465,7 @@ Given 'a cookbook recipe that has a wrapping condition containing a resource wit
465
465
  end
466
466
 
467
467
  Given /^a cookbook recipe that includes a local recipe(.*)$/ do |diff_name|
468
- cookbook = diff_name.empty? ? 'example' : 'foo'
468
+ cookbook = diff_name.empty? ? "example" : "foo"
469
469
  write_recipe %Q{
470
470
  include_recipe '#{cookbook}::server'
471
471
  }
@@ -484,17 +484,18 @@ Given /^a cookbook recipe that includes a recipe name from an( embedded)? expres
484
484
  include_recipe node['foo']['bar']
485
485
  }
486
486
  end
487
+
487
488
  write_metadata %q{
488
489
  depends "foo"
489
490
  }
490
491
  end
491
492
 
492
- Given /^a cookbook recipe that includes a(n un| )?declared recipe dependency(?: {0,1})(unscoped)?( with parentheses)?$/ do |undeclared,unscoped, parens|
493
+ Given /^a cookbook recipe that includes a(n un| )?declared recipe dependency(?: {0,1})(unscoped)?( with parentheses)?$/ do |undeclared, unscoped, parens|
493
494
  recipe_with_dependency(:is_declared => undeclared.strip.empty?,
494
495
  :is_scoped => unscoped.nil?, :parentheses => parens)
495
496
  end
496
497
 
497
- Given 'a cookbook recipe that includes both declared and undeclared recipe dependencies' do
498
+ Given "a cookbook recipe that includes both declared and undeclared recipe dependencies" do
498
499
  write_recipe %q{
499
500
  include_recipe "foo::default"
500
501
  include_recipe "bar::default"
@@ -513,20 +514,20 @@ Given /^a cookbook recipe that includes several declared recipe dependencies - (
513
514
  end
514
515
 
515
516
  Given /a cookbook recipe that (install|upgrade)s (a gem|multiple gems)(.*)$/ do |action, arity, approach|
516
- if arity == 'a gem'
517
+ if arity == "a gem"
517
518
  if approach.empty?
518
519
  recipe_installs_gem(:simple, action.to_sym)
519
520
  else
520
521
  recipe_installs_gem(:compile_time, action.to_sym)
521
522
  end
522
- elsif approach.include? 'array'
523
+ elsif approach.include? "array"
523
524
  recipe_installs_gem(:compile_time_from_array, action.to_sym)
524
525
  else
525
526
  recipe_installs_gem(:compile_time_from_word_list, action.to_sym)
526
527
  end
527
528
  end
528
529
 
529
- Given 'a cookbook recipe that refers to a hidden template' do
530
+ Given "a cookbook recipe that refers to a hidden template" do
530
531
  write_recipe %q{
531
532
  template '/etc/.s3cfg' do
532
533
  source '.s3cfg.erb'
@@ -538,7 +539,7 @@ Given 'a cookbook recipe that refers to a hidden template' do
538
539
  end
539
540
 
540
541
  Given /^a cookbook recipe that refers to a (missing |local )?template( in a subdirectory)?$/ do |missing_or_local, sub_dir|
541
- sub_dir = sub_dir ? 'sub_dir/' : ''
542
+ sub_dir = sub_dir ? "sub_dir/" : ""
542
543
  write_recipe %Q{
543
544
  template "/tmp/config.conf" do
544
545
  #{'local true' if missing_or_local == 'local '}
@@ -555,16 +556,16 @@ Given /^a cookbook recipe that refers to a (missing |local )?template( in a subd
555
556
  end
556
557
  end
557
558
 
558
- Given 'a cookbook recipe that refers to a template without an erb extension' do
559
+ Given "a cookbook recipe that refers to a template without an erb extension" do
559
560
  write_recipe %q{
560
561
  template '/etc/resolv.conf' do
561
562
  source 'resolv.conf'
562
563
  end
563
564
  }
564
- write_file 'cookbooks/example/templates/default/resolv.conf', ''
565
+ write_file "cookbooks/example/templates/default/resolv.conf", ""
565
566
  end
566
567
 
567
- Given 'a cookbook recipe that defines a template where name is a complex expression' do
568
+ Given "a cookbook recipe that defines a template where name is a complex expression" do
568
569
  write_recipe %q{
569
570
  template ::File.join(new_resource.foo.bar, "str", new_resource.baz) do
570
571
  variables({
@@ -572,12 +573,12 @@ Given 'a cookbook recipe that defines a template where name is a complex express
572
573
  })
573
574
  end
574
575
  }
575
- write_file 'cookbooks/example/templates/default/barstrbaz.conf.erb', %q{
576
+ write_file "cookbooks/example/templates/default/barstrbaz.conf.erb", %q{
576
577
  <%= @config_var %>
577
578
  }
578
579
  end
579
580
 
580
- Given 'a cookbook recipe that defines a template where both the name and source are complex expressions' do
581
+ Given "a cookbook recipe that defines a template where both the name and source are complex expressions" do
581
582
  write_recipe %q{
582
583
  template ::File.join(new_resource.foo.bar, "str", new_resource.baz) do
583
584
  source new_resource.foo.template
@@ -586,13 +587,12 @@ Given 'a cookbook recipe that defines a template where both the name and source
586
587
  })
587
588
  end
588
589
  }
589
- write_file 'cookbooks/example/templates/default/barstrbaz.conf.erb', %q{
590
+ write_file "cookbooks/example/templates/default/barstrbaz.conf.erb", %q{
590
591
  <%= @config_var %>
591
592
  }
592
593
  end
593
594
 
594
-
595
- Given 'a cookbook recipe that defines a template where name and source are both simple expressions' do
595
+ Given "a cookbook recipe that defines a template where name and source are both simple expressions" do
596
596
  write_recipe %q{
597
597
  template "/tmp/config-#{foo}.conf" do
598
598
  source "config-#{foo}.erb"
@@ -601,7 +601,7 @@ Given 'a cookbook recipe that defines a template where name and source are both
601
601
  })
602
602
  end
603
603
  }
604
- write_file 'cookbooks/example/templates/default/config-foo.conf.erb', %q{
604
+ write_file "cookbooks/example/templates/default/config-foo.conf.erb", %q{
605
605
  <%= @config_var %>
606
606
  }
607
607
  end
@@ -611,7 +611,7 @@ Given /^a cookbook recipe that (refers to|infers) a template with an expression$
611
611
  default['foo']['name'] = 'foo'
612
612
  }
613
613
  write_recipe case type
614
- when 'infers'
614
+ when "infers"
615
615
  %q{
616
616
  template "/tmp/config-#{node['foo']['name']}.conf" do
617
617
  variables({
@@ -629,12 +629,12 @@ Given /^a cookbook recipe that (refers to|infers) a template with an expression$
629
629
  end
630
630
  }
631
631
  end
632
- write_file 'cookbooks/example/templates/default/config-foo.conf.erb', %q{
632
+ write_file "cookbooks/example/templates/default/config-foo.conf.erb", %q{
633
633
  <%= @config_var %>
634
634
  }
635
635
  end
636
636
 
637
- Given 'a cookbook recipe that uses a template from another cookbook' do
637
+ Given "a cookbook recipe that uses a template from another cookbook" do
638
638
  write_recipe %q{
639
639
  template "foo" do
640
640
  cookbook "othercookbook"
@@ -652,18 +652,18 @@ Given /^a cookbook recipe that uses a(?:n)? (missing )?inferred template$/ do |m
652
652
  end
653
653
  }
654
654
  unless missing
655
- write_file 'cookbooks/example/templates/default/config.conf.erb', %q{
655
+ write_file "cookbooks/example/templates/default/config.conf.erb", %q{
656
656
  <%= @config_var %>
657
657
  }
658
658
  end
659
659
  end
660
660
 
661
661
  Given /^a cookbook recipe that uses execute to (sleep and then )?([^ ]+) a service via (.*)$/ do |sleep, action, method|
662
- method = 'service' if method == 'the service command'
663
- recipe_controls_service(method.include?('full path') ? :service_full_path : method.gsub(/[^a-z_]/, '_').to_sym, sleep, action)
662
+ method = "service" if method == "the service command"
663
+ recipe_controls_service(method.include?("full path") ? :service_full_path : method.gsub(/[^a-z_]/, "_").to_sym, sleep, action)
664
664
  end
665
665
 
666
- Given 'a cookbook recipe that uses execute to list a directory' do
666
+ Given "a cookbook recipe that uses execute to list a directory" do
667
667
  write_recipe %Q{
668
668
  execute "nothing-to-see-here" do
669
669
  command "ls"
@@ -672,7 +672,7 @@ Given 'a cookbook recipe that uses execute to list a directory' do
672
672
  }
673
673
  end
674
674
 
675
- Given 'a cookbook recipe that uses execute with a name attribute to start a service' do
675
+ Given "a cookbook recipe that uses execute with a name attribute to start a service" do
676
676
  write_recipe %Q{
677
677
  execute "/etc/init.d/foo start" do
678
678
  cwd "/tmp"
@@ -700,12 +700,12 @@ end
700
700
  Given /^a cookbook recipe with a ([^ ]+) resource with actions (.*)$/ do |resource, actions|
701
701
  write_recipe %Q{
702
702
  #{resource} "foo" do
703
- action [#{actions.split(', ').map{|a| ":#{a}"}.join(", ")}]
703
+ action [#{actions.split(', ').map { |a| ":#{a}" }.join(", ")}]
704
704
  end
705
705
  }
706
706
  end
707
707
 
708
- Given 'a cookbook recipe with a case condition unrelated to platform' do
708
+ Given "a cookbook recipe with a case condition unrelated to platform" do
709
709
  write_recipe %Q{
710
710
  case day_of_week
711
711
  when "Monday", "Tuesday"
@@ -720,7 +720,7 @@ Given 'a cookbook recipe with a case condition unrelated to platform' do
720
720
  }.strip
721
721
  end
722
722
 
723
- Given /^a cookbook recipe with a resource that ([^ ]+)(?: )?([^ ]+)?$/ do |type,notification_timing|
723
+ Given /^a cookbook recipe with a resource that ([^ ]+)(?: )?([^ ]+)?$/ do |type, notification_timing|
724
724
  write_recipe %Q{
725
725
  template "/etc/foo.conf" do
726
726
  #{type} :restart, "service[foo]"#{", :#{notification_timing}" if notification_timing}
@@ -730,8 +730,8 @@ end
730
730
 
731
731
  Given /^a cookbook recipe with a resource that (notifies|subscribes) a ([^ ]+) to ([^ ]+)$/ do |type, resource, action|
732
732
  notification = case type
733
- when 'notifies' then %Q{notifies :#{action}, "#{resource}[foo]"}
734
- when 'subscribes' then %Q{subscribes :#{action}, resources(:#{resource} => "foo")}
733
+ when "notifies" then %Q{notifies :#{action}, "#{resource}[foo]"}
734
+ when "subscribes" then %Q{subscribes :#{action}, resources(:#{resource} => "foo")}
735
735
  end
736
736
  write_recipe %Q{
737
737
  template "/etc/apache.conf" do
@@ -740,7 +740,7 @@ Given /^a cookbook recipe with a resource that (notifies|subscribes) a ([^ ]+) t
740
740
  }
741
741
  end
742
742
 
743
- Given 'a cookbook recipe with a resource that uses the old notification syntax' do
743
+ Given "a cookbook recipe with a resource that uses the old notification syntax" do
744
744
  write_recipe %q{
745
745
  template "/etc/www/configures-apache.conf" do
746
746
  notifies :restart, resources(:service => "apache")
@@ -748,9 +748,9 @@ Given 'a cookbook recipe with a resource that uses the old notification syntax'
748
748
  }
749
749
  end
750
750
 
751
- Given /^a cookbook recipe with a '([^']+)' condition for flavours (.*)$/ do |type,flavours|
751
+ Given /^a cookbook recipe with a '([^']+)' condition for flavours (.*)$/ do |type, flavours|
752
752
  platforms = %Q{"#{flavours.split(',').join('","')}"}
753
- if type == 'case'
753
+ if type == "case"
754
754
  @expected_line = 6
755
755
  write_recipe %Q{
756
756
  case node[:platform]
@@ -764,7 +764,7 @@ Given /^a cookbook recipe with a '([^']+)' condition for flavours (.*)$/ do |typ
764
764
  end
765
765
  end
766
766
  }.strip
767
- elsif type == 'platform?'
767
+ elsif type == "platform?"
768
768
  @expected_line = 1
769
769
  write_recipe %Q{
770
770
  if platform?(#{platforms})
@@ -774,11 +774,11 @@ Given /^a cookbook recipe with a '([^']+)' condition for flavours (.*)$/ do |typ
774
774
  end
775
775
  }.strip
776
776
  else
777
- fail "Unrecognised type: #{type}"
777
+ raise "Unrecognised type: #{type}"
778
778
  end
779
779
  end
780
780
 
781
- Given 'a cookbook recipe with a service resource that does not specify an action' do
781
+ Given "a cookbook recipe with a service resource that does not specify an action" do
782
782
  write_recipe %q{
783
783
  service "foo" do
784
784
  start_command "/sbin/service foo start"
@@ -786,7 +786,7 @@ Given 'a cookbook recipe with a service resource that does not specify an action
786
786
  }.strip
787
787
  end
788
788
 
789
- Given 'a cookbook recipe with a service resource with an action specified via a variable' do
789
+ Given "a cookbook recipe with a service resource with an action specified via a variable" do
790
790
  write_recipe %q{
791
791
  service "foo" do
792
792
  action action
@@ -794,7 +794,7 @@ Given 'a cookbook recipe with a service resource with an action specified via a
794
794
  }.strip
795
795
  end
796
796
 
797
- Given 'a cookbook recipe with multiple execute resources where the last uses git' do
797
+ Given "a cookbook recipe with multiple execute resources where the last uses git" do
798
798
  write_recipe %q{
799
799
  execute "one" do
800
800
  command "ls -al"
@@ -808,7 +808,7 @@ Given 'a cookbook recipe with multiple execute resources where the last uses git
808
808
  }.strip
809
809
  end
810
810
 
811
- Given 'a cookbook template that uses all variables passed' do
811
+ Given "a cookbook template that uses all variables passed" do
812
812
  write_recipe %q{
813
813
  template "/tmp/config.conf" do
814
814
  source "config.conf.erb"
@@ -817,7 +817,7 @@ Given 'a cookbook template that uses all variables passed' do
817
817
  )
818
818
  end
819
819
  }
820
- write_file 'cookbooks/example/templates/default/config.conf.erb', %q{
820
+ write_file "cookbooks/example/templates/default/config.conf.erb", %q{
821
821
  <%= @config_var %>
822
822
  }
823
823
  end
@@ -835,7 +835,7 @@ Given /^a cookbook that passes variables (.*) to a template with extension (.*)$
835
835
  template "/tmp/config.conf" do
836
836
  source "config#{ext}"
837
837
  variables(
838
- :#{vars.split(',').map{|v| "#{v} => node[:#{v}]"}.join(",\n:")}
838
+ :#{vars.split(',').map { |v| "#{v} => node[:#{v}]" }.join(",\n:")}
839
839
  )
840
840
  end
841
841
  }
@@ -845,7 +845,7 @@ Given /^a cookbook that passes variables (.*) to an inferred template$/ do |vars
845
845
  write_recipe %Q{
846
846
  template "/tmp/config.conf" do
847
847
  variables(
848
- :#{vars.split(',').map{|v| "#{v} => node[:#{v}]"}.join(",\n:")}
848
+ :#{vars.split(',').map { |v| "#{v} => node[:#{v}]" }.join(",\n:")}
849
849
  )
850
850
  end
851
851
  }
@@ -855,7 +855,7 @@ Given /^a cookbook that contains a (short|long) ruby block$/ do |length|
855
855
  recipe_with_ruby_block(length.to_sym)
856
856
  end
857
857
 
858
- Given 'a cookbook that contains a definition' do
858
+ Given "a cookbook that contains a definition" do
859
859
  write_definition("apache_site", %q{
860
860
  define :apache_site, :enable => true do
861
861
  log "I am a definition"
@@ -867,14 +867,14 @@ Given 'a cookbook that contains a definition' do
867
867
  end
868
868
 
869
869
  Given /^a cookbook that contains a LWRP (?:with a single notification|that uses the current notification syntax)$/ do
870
- cookbook_with_lwrp({:notifies => :does_notify})
870
+ cookbook_with_lwrp({ :notifies => :does_notify })
871
871
  end
872
872
 
873
- Given 'a cookbook that contains a LWRP with a single notification without parentheses' do
874
- cookbook_with_lwrp({:notifies => :does_notify_without_parens})
873
+ Given "a cookbook that contains a LWRP with a single notification without parentheses" do
874
+ cookbook_with_lwrp({ :notifies => :does_notify_without_parens })
875
875
  end
876
876
 
877
- Given /^a cookbook that contains a LWRP that declares a resource called ([^ ]+) with the condition (.*)$/ do |name,condition|
877
+ Given /^a cookbook that contains a LWRP that declares a resource called ([^ ]+) with the condition (.*)$/ do |name, condition|
878
878
  write_resource("site", %q{
879
879
  actions :create
880
880
  attribute :name, :name_attribute => true
@@ -906,14 +906,14 @@ Given /^a cookbook that contains a LWRP that uses converge_by - (brace|do) block
906
906
  actions :create
907
907
  attribute :name, :kind_of => String, :name_attribute => true
908
908
  })
909
- if block_type == 'brace'
909
+ if block_type == "brace"
910
910
  write_provider("site", %q{
911
911
  action :create do
912
912
  converge_by("Creating site #{new_resource.name}"){ Site.new(new_resource.name).create }
913
913
  end
914
914
  })
915
915
  else
916
- if with_parens == 'with'
916
+ if with_parens == "with"
917
917
  write_provider("site", %q{
918
918
  action :create do
919
919
  converge_by("Creating site #{new_resource.name}") do
@@ -934,14 +934,14 @@ Given /^a cookbook that contains a LWRP that uses converge_by - (brace|do) block
934
934
  end
935
935
 
936
936
  Given /^a cookbook that contains a LWRP that uses the deprecated notification syntax(.*)$/ do |qualifier|
937
- cookbook_with_lwrp({:notifies => qualifier.include?('class variable') ? :class_variable : :deprecated_syntax})
937
+ cookbook_with_lwrp({ :notifies => qualifier.include?("class variable") ? :class_variable : :deprecated_syntax })
938
938
  end
939
939
 
940
- Given 'a cookbook that contains a LWRP that uses use_inline_resources' do
941
- cookbook_with_lwrp({:use_inline_resources => true})
940
+ Given "a cookbook that contains a LWRP that uses use_inline_resources" do
941
+ cookbook_with_lwrp({ :use_inline_resources => true })
942
942
  end
943
943
 
944
- Given 'a cookbook that contains a LWRP with multiple notifications' do
944
+ Given "a cookbook that contains a LWRP with multiple notifications" do
945
945
  write_resource("site", %q{
946
946
  actions :create, :delete
947
947
  attribute :name, :kind_of => String, :name_attribute => true
@@ -958,19 +958,19 @@ Given 'a cookbook that contains a LWRP with multiple notifications' do
958
958
  })
959
959
  end
960
960
 
961
- Given /^a cookbook that contains a LWRP with (no|a) default action( defined via a constructor)?$/ do |has_default_action,no_dsl|
962
- default_action = if has_default_action == 'no'
963
- :no_default_action
964
- elsif no_dsl.nil?
965
- :dsl_default_action
966
- else
967
- :ruby_default_action
961
+ Given /^a cookbook that contains a LWRP with (no|a) default action( defined via a constructor)?$/ do |has_default_action, no_dsl|
962
+ default_action = if has_default_action == "no"
963
+ :no_default_action
964
+ elsif no_dsl.nil?
965
+ :dsl_default_action
966
+ else
967
+ :ruby_default_action
968
968
  end
969
- cookbook_with_lwrp({:default_action => default_action,
970
- :notifies => :does_notify})
969
+ cookbook_with_lwrp({ :default_action => default_action,
970
+ :notifies => :does_notify })
971
971
  end
972
972
 
973
- Given 'a cookbook that contains no ruby blocks' do
973
+ Given "a cookbook that contains no ruby blocks" do
974
974
  write_recipe %q{
975
975
  package "tar" do
976
976
  action :install
@@ -983,47 +983,47 @@ Given /^a cookbook that declares ([a-z]+) attributes via symbols$/ do |attribute
983
983
  end
984
984
 
985
985
  Given /^a cookbook that does not contain a definition and has (no|a) definitions directory$/ do |has_dir|
986
- create_directory 'cookbooks/example/definitions/' unless has_dir == 'no'
986
+ create_directory "cookbooks/example/definitions/" unless has_dir == "no"
987
987
  write_recipe %q{
988
988
  log "A defining characteristic of this cookbook is that it has no definitions"
989
989
  }
990
990
  end
991
991
 
992
- Given 'a cookbook that does not have a README at all' do
992
+ Given "a cookbook that does not have a README at all" do
993
993
  write_recipe %q{
994
994
  log "Use the source luke"
995
995
  }
996
996
  end
997
997
 
998
- Given 'a cookbook that does not have defined metadata' do
998
+ Given "a cookbook that does not have defined metadata" do
999
999
  write_recipe %q{
1000
1000
  include_recipe "foo::default"
1001
1001
  }
1002
1002
  end
1003
1003
 
1004
1004
  Given /^a cookbook that downloads a file to (.*)$/ do |path|
1005
- recipe_downloads_file({'/tmp' => :tmp_dir, '/tmp with an expression' => :tmp_dir_expr,
1006
- 'the Chef file cache' => :chef_file_cache_dir,
1007
- 'a users home directory' => :home_dir}[path])
1005
+ recipe_downloads_file({ "/tmp" => :tmp_dir, "/tmp with an expression" => :tmp_dir_expr,
1006
+ "the Chef file cache" => :chef_file_cache_dir,
1007
+ "a users home directory" => :home_dir }[path])
1008
1008
  end
1009
1009
 
1010
1010
  Given /^a cookbook that has ([^ ]+) problems$/ do |problems|
1011
1011
  cookbook_that_matches_rules(
1012
- problems.split(',').map do |problem|
1012
+ problems.split(",").map do |problem|
1013
1013
  case problem
1014
- when 'no ' then next
1015
- when 'style' then 'FC002'
1016
- when 'correctness' then 'FC006'
1014
+ when "no " then next
1015
+ when "style" then "FC002"
1016
+ when "correctness" then "FC006"
1017
1017
  end
1018
1018
  end
1019
1019
  )
1020
1020
  end
1021
1021
 
1022
- Given 'a cookbook that has a README in markdown format' do
1022
+ Given "a cookbook that has a README in markdown format" do
1023
1023
  write_recipe %q{
1024
1024
  log "Hello"
1025
1025
  }
1026
- write_file 'cookbooks/example/README.md', %q{
1026
+ write_file "cookbooks/example/README.md", %q{
1027
1027
  Description
1028
1028
  ===========
1029
1029
 
@@ -1031,30 +1031,30 @@ Given 'a cookbook that has a README in markdown format' do
1031
1031
  }
1032
1032
  end
1033
1033
 
1034
- Given 'a cookbook that has a README in RDoc format' do
1034
+ Given "a cookbook that has a README in RDoc format" do
1035
1035
  write_recipe %q{
1036
1036
  log "Hello"
1037
1037
  }
1038
- write_file 'cookbooks/example/README.rdoc', %q{
1038
+ write_file "cookbooks/example/README.rdoc", %q{
1039
1039
  = DESCRIPTION:
1040
1040
 
1041
1041
  I used to be the preferred format but not any more (sniff).
1042
1042
  }
1043
1043
  end
1044
1044
 
1045
- Given /^a cookbook that has maintainer metadata set to (.*) and ([^ ]+)$/ do |name,email|
1045
+ Given /^a cookbook that has maintainer metadata set to (.*) and ([^ ]+)$/ do |name, email|
1046
1046
  cookbook_with_maintainer(nil_if_unspecified(name), nil_if_unspecified(email))
1047
1047
  end
1048
1048
 
1049
- Given 'a cookbook that has the default boilerplate metadata generated by knife' do
1050
- cookbook_with_maintainer('YOUR_COMPANY_NAME', 'YOUR_EMAIL')
1049
+ Given "a cookbook that has the default boilerplate metadata generated by knife" do
1050
+ cookbook_with_maintainer("YOUR_COMPANY_NAME", "YOUR_EMAIL")
1051
1051
  end
1052
1052
 
1053
1053
  Given /^a cookbook that matches rules (.*)$/ do |rules|
1054
- cookbook_that_matches_rules(rules.split(','))
1054
+ cookbook_that_matches_rules(rules.split(","))
1055
1055
  end
1056
1056
 
1057
- Given 'a cookbook that matches that rule' do
1057
+ Given "a cookbook that matches that rule" do
1058
1058
  write_recipe %q{
1059
1059
  execute "bar" do
1060
1060
  action :run
@@ -1062,32 +1062,32 @@ Given 'a cookbook that matches that rule' do
1062
1062
  }
1063
1063
  end
1064
1064
 
1065
- Given /^a cookbook with a ([^ ]+) that (includes|does not include) a breakpoint$/ do |component,includes|
1065
+ Given /^a cookbook with a ([^ ]+) that (includes|does not include) a breakpoint$/ do |component, includes|
1066
1066
  content = case component
1067
- when 'template' then includes == 'includes' ? "Hello <% require 'pry'; binding.pry %>" : 'Hello World'
1068
- else includes == 'includes' ? 'binding.pry' : '# No breakpoint'
1067
+ when "template" then includes == "includes" ? "Hello <% require 'pry'; binding.pry %>" : "Hello World"
1068
+ else includes == "includes" ? "binding.pry" : '# No breakpoint'
1069
1069
  end
1070
- write_recipe ''
1070
+ write_recipe ""
1071
1071
  case component
1072
- when 'library' then write_library 'foo', content
1073
- when 'metadata' then write_metadata content
1074
- when 'provider' then write_provider 'foo', content
1075
- when 'recipe' then write_recipe content
1076
- when 'resource' then write_resource 'foo', content
1077
- when 'template' then write_file 'cookbooks/example/templates/default/foo.erb',
1072
+ when "library" then write_library "foo", content
1073
+ when "metadata" then write_metadata content
1074
+ when "provider" then write_provider "foo", content
1075
+ when "recipe" then write_recipe content
1076
+ when "resource" then write_resource "foo", content
1077
+ when "template" then write_file "cookbooks/example/templates/default/foo.erb",
1078
1078
  content
1079
- else fail "Unrecognised component: #{component}"
1079
+ else raise "Unrecognised component: #{component}"
1080
1080
  end
1081
1081
  end
1082
1082
 
1083
1083
  Given /^a cookbook with a single recipe for which the first hash (key|value) is an interpolated string$/ do |key_or_value|
1084
1084
  write_recipe case key_or_value
1085
- when 'key' then %q{{"#{foo}" => 'bar', 'bar' => 'foo'}}
1086
- when 'value' then %q{{'foo' => "#{bar}", 'bar' => 'foo'}}
1085
+ when "key" then %q{{"#{foo}" => 'bar', 'bar' => 'foo'}}
1086
+ when "value" then %q{{'foo' => "#{bar}", 'bar' => 'foo'}}
1087
1087
  end
1088
1088
  end
1089
1089
 
1090
- Given 'a cookbook with a single recipe that mixes node access types in an interpolated value' do
1090
+ Given "a cookbook with a single recipe that mixes node access types in an interpolated value" do
1091
1091
  write_recipe %q{
1092
1092
  execute "interpolated-example" do
1093
1093
  command "#{node['foo'][:bar]}'"
@@ -1095,18 +1095,18 @@ Given 'a cookbook with a single recipe that mixes node access types in an interp
1095
1095
  }
1096
1096
  end
1097
1097
 
1098
- Given 'a cookbook with a single recipe that accesses multiple node attributes via symbols' do
1098
+ Given "a cookbook with a single recipe that accesses multiple node attributes via symbols" do
1099
1099
  write_recipe %q{
1100
1100
  node[:foo] = 'bar'
1101
1101
  node[:testing] = 'bar'
1102
1102
  }
1103
1103
  end
1104
1104
 
1105
- Given 'a cookbook with a single recipe that accesses nested node attributes via symbols' do
1105
+ Given "a cookbook with a single recipe that accesses nested node attributes via symbols" do
1106
1106
  write_recipe %q{node[:foo][:foo2] = 'bar'}
1107
1107
  end
1108
1108
 
1109
- Given 'a cookbook with a single recipe that reads node attributes via symbols and quoted_symbols' do
1109
+ Given "a cookbook with a single recipe that reads node attributes via symbols and quoted_symbols" do
1110
1110
  write_recipe %q{default[:foo][:'bar-baz']}
1111
1111
  end
1112
1112
 
@@ -1119,8 +1119,8 @@ Given /^a cookbook with a single recipe that triggers FC019 with comment (.*)$/
1119
1119
  }.strip
1120
1120
  end
1121
1121
 
1122
- Given 'a cookbook with a single recipe that calls a patched node method' do
1123
- write_library 'search', %q{
1122
+ Given "a cookbook with a single recipe that calls a patched node method" do
1123
+ write_library "search", %q{
1124
1124
  class Chef
1125
1125
  class Node
1126
1126
  def in_tier?(*tier)
@@ -1144,7 +1144,7 @@ Given /^a cookbook with a single recipe that explicitly calls a node method( wit
1144
1144
  }
1145
1145
  end
1146
1146
 
1147
- Given 'a cookbook with a single recipe that passes node attributes accessed via symbols to a template' do
1147
+ Given "a cookbook with a single recipe that passes node attributes accessed via symbols to a template" do
1148
1148
  write_recipe %q{
1149
1149
  template "/etc/foo" do
1150
1150
  source "foo.erb"
@@ -1156,7 +1156,7 @@ Given 'a cookbook with a single recipe that passes node attributes accessed via
1156
1156
  }.strip
1157
1157
  end
1158
1158
 
1159
- Given 'a cookbook with a single recipe that uses a hash value to access a node attribute' do
1159
+ Given "a cookbook with a single recipe that uses a hash value to access a node attribute" do
1160
1160
  write_recipe %q{
1161
1161
  some_hash = {
1162
1162
  :key => "value"
@@ -1167,41 +1167,41 @@ Given 'a cookbook with a single recipe that uses a hash value to access a node a
1167
1167
  }.strip
1168
1168
  end
1169
1169
 
1170
- Given /a(nother)? cookbook with a single recipe that (reads|updates|ignores)(nested)? node attributes via ([a-z,]*)(?:(?: and calls node\.)?([a-z_?]+)?| with (.*)?)(?: only)?$/ do |more_than_one,op,nested,types,method,expr|
1171
- cookbook_name = more_than_one.nil? ? 'example' : 'another_example'
1170
+ Given /a(nother)? cookbook with a single recipe that (reads|updates|ignores)(nested)? node attributes via ([a-z,]*)(?:(?: and calls node\.)?([a-z_?]+)?| with (.*)?)(?: only)?$/ do |more_than_one, op, nested, types, method, expr|
1171
+ cookbook_name = more_than_one.nil? ? "example" : "another_example"
1172
1172
 
1173
- access = nested.nil? ? {:strings => "['foo']", :symbols => '[:foo]', :vivified => '.foo'} :
1174
- {:strings => "['bar']['baz']", :symbols => '[:fee][:fi][:fo][:fum]', :vivified => '.bar.baz'}
1173
+ access = nested.nil? ? { :strings => "['foo']", :symbols => "[:foo]", :vivified => ".foo" } :
1174
+ { :strings => "['bar']['baz']", :symbols => "[:fee][:fi][:fo][:fum]", :vivified => ".bar.baz" }
1175
1175
 
1176
1176
  recipe_content =
1177
- (if types == 'none'
1178
- "log 'hello world'"
1179
- elsif op == 'reads'
1180
- types.split(',').map{|type| "log node#{access[type.to_sym]}"}.join("\n")
1181
- else
1182
- types.split(',').map{|type| "node#{access[type.to_sym]} = 'foo'"}.join("\n")
1177
+ (if types == "none"
1178
+ "log 'hello world'"
1179
+ elsif op == "reads"
1180
+ types.split(",").map { |type| "log node#{access[type.to_sym]}" }.join("\n")
1181
+ else
1182
+ types.split(",").map { |type| "node#{access[type.to_sym]} = 'foo'" }.join("\n")
1183
1183
  end)
1184
1184
 
1185
1185
  recipe_content += "\n#{expr}"
1186
1186
 
1187
1187
  unless method.nil?
1188
- recipe_content += {:platform? => "node.platform?('redhat')",
1189
- :run_list => "log 'hello' if node.run_list.roles.include?(node[:foo][:bar])",
1190
- :run_state => "node.run_state[:reboot_requested] = true",
1191
- :set => "node.set['foo']['bar']['baz'] = 'secret'"}[method.to_sym]
1188
+ recipe_content += { :platform? => "node.platform?('redhat')",
1189
+ :run_list => "log 'hello' if node.run_list.roles.include?(node[:foo][:bar])",
1190
+ :run_state => "node.run_state[:reboot_requested] = true",
1191
+ :set => "node.set['foo']['bar']['baz'] = 'secret'" }[method.to_sym]
1192
1192
  end
1193
1193
 
1194
1194
  write_recipe(recipe_content, cookbook_name)
1195
1195
 
1196
1196
  end
1197
1197
 
1198
- Given 'a cookbook with a single recipe that searches based on a node attribute accessed via strings' do
1198
+ Given "a cookbook with a single recipe that searches based on a node attribute accessed via strings" do
1199
1199
  write_recipe %q{
1200
1200
  remote = search(:node, "name:#{node['drbd']['remote_host']}")[0]
1201
1201
  }.strip
1202
1202
  end
1203
1203
 
1204
- Given 'a cookbook with a single recipe which accesses node attributes with symbols on lines 2 and 10' do
1204
+ Given "a cookbook with a single recipe which accesses node attributes with symbols on lines 2 and 10" do
1205
1205
  write_recipe %q{
1206
1206
  # Here we access the node attributes via a symbol
1207
1207
  foo = node[:foo]
@@ -1216,20 +1216,20 @@ Given 'a cookbook with a single recipe which accesses node attributes with symbo
1216
1216
  }
1217
1217
  end
1218
1218
 
1219
- Given 'a cookbook with a single recipe that assigns node attributes accessed via symbols to a local variable' do
1219
+ Given "a cookbook with a single recipe that assigns node attributes accessed via symbols to a local variable" do
1220
1220
  write_recipe %q{baz = node[:foo]}
1221
1221
  end
1222
1222
 
1223
1223
  Given /^a cookbook with a single recipe that creates a directory resource with (.*)$/ do |path_type|
1224
- recipe_with_dir_path({'an interpolated name' => :interpolated_symbol,
1225
- 'an interpolated name from a string' => :interpolated_string,
1226
- 'a string literal' => :string_literal,
1227
- 'a compound expression' => :compound_symbols,
1228
- 'an interpolated variable and a literal' => :interpolated_symbol_and_literal,
1229
- 'a literal and interpolated variable' => :literal_and_interpolated_symbol}[path_type])
1224
+ recipe_with_dir_path({ "an interpolated name" => :interpolated_symbol,
1225
+ "an interpolated name from a string" => :interpolated_string,
1226
+ "a string literal" => :string_literal,
1227
+ "a compound expression" => :compound_symbols,
1228
+ "an interpolated variable and a literal" => :interpolated_symbol_and_literal,
1229
+ "a literal and interpolated variable" => :literal_and_interpolated_symbol }[path_type])
1230
1230
  end
1231
1231
 
1232
- Given 'a cookbook with a single recipe that logs an interpolated string heredoc' do
1232
+ Given "a cookbook with a single recipe that logs an interpolated string heredoc" do
1233
1233
  write_recipe %q(
1234
1234
  Chef::Log.warn <<-LOG
1235
1235
  Warning stuff has gone wrong: #{stuff}
@@ -1237,7 +1237,7 @@ Given 'a cookbook with a single recipe that logs an interpolated string heredoc'
1237
1237
  )
1238
1238
  end
1239
1239
 
1240
- Given 'a cookbook with a single recipe that searches but checks first (alternation) to see if this is server' do
1240
+ Given "a cookbook with a single recipe that searches but checks first (alternation) to see if this is server" do
1241
1241
  write_recipe %q{
1242
1242
  if Chef::Config[:solo] || we_dont_want_to_use_search
1243
1243
  # set up stuff from attributes
@@ -1258,7 +1258,7 @@ Given /^a cookbook with a single recipe that searches but checks first( \(string
1258
1258
  }
1259
1259
  end
1260
1260
 
1261
- Given 'a cookbook with a single recipe that searches but checks first (ternary) to see if this is server' do
1261
+ Given "a cookbook with a single recipe that searches but checks first (ternary) to see if this is server" do
1262
1262
  write_recipe %Q{
1263
1263
  required_node = Chef::Config[:solo] ? node : search(:node, query).first
1264
1264
  }
@@ -1285,7 +1285,7 @@ Given /^a cookbook with a single recipe that searches but checks first \(method\
1285
1285
  end
1286
1286
 
1287
1287
  Given /^a cookbook with a single recipe that searches but returns first \((oneline|multiline)\) if search is not supported$/ do |format|
1288
- if format == 'oneline'
1288
+ if format == "oneline"
1289
1289
  write_recipe %q{
1290
1290
  return Chef::Log.warn("This recipe uses search. Chef Solo does not support search.") if Chef::Config[:solo]
1291
1291
  nodes = search(:node, "hostname:[* TO *] AND chef_environment:#{node.chef_environment}")
@@ -1300,11 +1300,11 @@ Given /^a cookbook with a single recipe that searches but returns first \((oneli
1300
1300
  end
1301
1301
  end
1302
1302
 
1303
- Given 'a cookbook with a single recipe that searches without checking if this is server' do
1303
+ Given "a cookbook with a single recipe that searches without checking if this is server" do
1304
1304
  write_recipe %q{nodes = search(:node, "hostname:[* TO *] AND chef_environment:#{node.chef_environment}")}
1305
1305
  end
1306
1306
 
1307
- Given 'a cookbook with five recipes' do
1307
+ Given "a cookbook with five recipes" do
1308
1308
 
1309
1309
  end
1310
1310
 
@@ -1331,11 +1331,11 @@ Given /^a cookbook with metadata that (includes|does not include) a maintainer e
1331
1331
  }
1332
1332
  end
1333
1333
 
1334
- Given 'a cookbook with metadata that includes a maintainer expression' do
1334
+ Given "a cookbook with metadata that includes a maintainer expression" do
1335
1335
  write_metadata "maintainer an(expression)"
1336
1336
  end
1337
1337
 
1338
- Given 'a cookbook with metadata that includes a maintainer email expression' do
1338
+ Given "a cookbook with metadata that includes a maintainer email expression" do
1339
1339
  write_metadata "maintainer_email an(expression)"
1340
1340
  end
1341
1341
 
@@ -1357,23 +1357,23 @@ Given /^a directory that contains a role file ([^ ]+) in (json|ruby) that define
1357
1357
  role(:role_name => %Q{"#{role_name}"}, :file_name => file_name, :format => format.to_sym)
1358
1358
  end
1359
1359
 
1360
- Given 'a directory that contains a ruby role that declares the role name more than once' do
1361
- role(:role_name => ['"webserver"', '"apache"'], :file_name => 'webserver.rb')
1360
+ Given "a directory that contains a ruby role that declares the role name more than once" do
1361
+ role(:role_name => ['"webserver"', '"apache"'], :file_name => "webserver.rb")
1362
1362
  end
1363
1363
 
1364
- Given 'a directory that contains a ruby role with an expression as its name' do
1365
- role(:role_name => '"#{foo}#{bar}"', :file_name => 'webserver.rb')
1364
+ Given "a directory that contains a ruby role with an expression as its name" do
1365
+ role(:role_name => '"#{foo}#{bar}"', :file_name => "webserver.rb")
1366
1366
  end
1367
1367
 
1368
1368
  Given /^a directory that contains an environment file (.*) in ruby that defines environment name (.*)$/ do |file_name, env_name|
1369
- environment(:environment_name => %Q{"#{env_name}"}, :file_name => 'production.rb')
1369
+ environment(:environment_name => %Q{"#{env_name}"}, :file_name => "production.rb")
1370
1370
  end
1371
1371
 
1372
- Given /^a ([a-z_]+) resource declared with the mode ([^\s]+)(?: with comment (.*)?)?$/ do |resource,mode,comment|
1372
+ Given /^a ([a-z_]+) resource declared with the mode ([^\s]+)(?: with comment (.*)?)?$/ do |resource, mode, comment|
1373
1373
  recipe_resource_with_mode(resource, mode, comment)
1374
1374
  end
1375
1375
 
1376
- Given 'a file resource declared without a mode' do
1376
+ Given "a file resource declared without a mode" do
1377
1377
  write_recipe %q{
1378
1378
  file "/tmp/something" do
1379
1379
  action :delete
@@ -1387,8 +1387,8 @@ end
1387
1387
 
1388
1388
  Given(/^a LWRP with an action :create that notifies with (converge_by|updated_by_last_action) and another :delete that does not notify$/) do |notify_type|
1389
1389
  cookbook_with_lwrp_actions([
1390
- {:name => :create, :notify_type => notify_type.to_sym},
1391
- {:name => :delete, :notify_type => :none}
1390
+ { :name => :create, :notify_type => notify_type.to_sym },
1391
+ { :name => :delete, :notify_type => :none },
1392
1392
  ])
1393
1393
  end
1394
1394
 
@@ -1396,25 +1396,25 @@ Given /^(?:a roles|an environments) directory$/ do
1396
1396
 
1397
1397
  end
1398
1398
 
1399
- Given /^a Rakefile that defines (no lint task|a lint task with no block|a lint task with an empty block|a lint task with a block setting options to)(.*)?$/ do |task,options|
1399
+ Given /^a Rakefile that defines (no lint task|a lint task with no block|a lint task with an empty block|a lint task with a block setting options to)(.*)?$/ do |task, options|
1400
1400
  rakefile(
1401
1401
  case task
1402
1402
  when /no block/ then :no_block
1403
1403
  when /empty block/ then :empty_block
1404
1404
  when /a block/ then :block
1405
1405
  end,
1406
- options.strip.empty? ? {} : {:options => options.strip})
1406
+ options.strip.empty? ? {} : { :options => options.strip })
1407
1407
  end
1408
1408
 
1409
1409
  Given /^a Rakefile that defines a lint task specifying files to lint as (.*)$/ do |files|
1410
1410
  rakefile(:block, :files => files)
1411
1411
  end
1412
1412
 
1413
- Given 'a Rakefile that defines a lint task specifying a different name' do
1414
- rakefile(:block, :name => 'lint')
1413
+ Given "a Rakefile that defines a lint task specifying a different name" do
1414
+ rakefile(:block, :name => "lint")
1415
1415
  end
1416
1416
 
1417
- Given 'a recipe that contains a ruby block without a block attribute' do
1417
+ Given "a recipe that contains a ruby block without a block attribute" do
1418
1418
  write_recipe %q{
1419
1419
  ruby_block "missing block" do
1420
1420
  puts "Missing a block attribute"
@@ -1422,15 +1422,15 @@ Given 'a recipe that contains a ruby block without a block attribute' do
1422
1422
  }
1423
1423
  end
1424
1424
 
1425
- Given 'a recipe that contains both long and short ruby blocks' do
1425
+ Given "a recipe that contains both long and short ruby blocks" do
1426
1426
  recipe_with_ruby_block(:both)
1427
1427
  end
1428
1428
 
1429
- Given /^a recipe that declares a ([^ ]+) resource with these attributes: (.*)$/ do |type,attributes|
1430
- recipe_with_resource(type, attributes.split(','))
1429
+ Given /^a recipe that declares a ([^ ]+) resource with these attributes: (.*)$/ do |type, attributes|
1430
+ recipe_with_resource(type, attributes.split(","))
1431
1431
  end
1432
1432
 
1433
- Given 'a recipe that declares a resource with an attribute value set to the result of a method call' do
1433
+ Given "a recipe that declares a resource with an attribute value set to the result of a method call" do
1434
1434
  write_recipe %q{
1435
1435
  cron "run a command at a random minute" do
1436
1436
  user "root"
@@ -1440,13 +1440,13 @@ Given 'a recipe that declares a resource with an attribute value set to the resu
1440
1440
  }
1441
1441
  end
1442
1442
 
1443
- Given 'a recipe that declares a resource with only a name attribute' do
1443
+ Given "a recipe that declares a resource with only a name attribute" do
1444
1444
  write_recipe %q{
1445
1445
  package 'foo'
1446
1446
  }
1447
1447
  end
1448
1448
 
1449
- Given 'a recipe that declares a resource with recognised attributes and a conditional execution ruby block' do
1449
+ Given "a recipe that declares a resource with recognised attributes and a conditional execution ruby block" do
1450
1450
  write_recipe %q{
1451
1451
  file "/tmp/something" do
1452
1452
  owner "root"
@@ -1461,7 +1461,7 @@ Given 'a recipe that declares a resource with recognised attributes and a condit
1461
1461
  }
1462
1462
  end
1463
1463
 
1464
- Given 'a recipe that declares a resource with recognised attributes and a nested block' do
1464
+ Given "a recipe that declares a resource with recognised attributes and a nested block" do
1465
1465
  write_recipe %q{
1466
1466
  deploy_revision "foo" do
1467
1467
  revision "HEAD"
@@ -1478,7 +1478,7 @@ Given 'a recipe that declares a resource with recognised attributes and a nested
1478
1478
  }
1479
1479
  end
1480
1480
 
1481
- Given 'a recipe that declares a resource with standard attributes' do
1481
+ Given "a recipe that declares a resource with standard attributes" do
1482
1482
  write_recipe %q{
1483
1483
  file "/tmp/something" do
1484
1484
  owner "root"
@@ -1489,7 +1489,7 @@ Given 'a recipe that declares a resource with standard attributes' do
1489
1489
  }
1490
1490
  end
1491
1491
 
1492
- Given 'a recipe that declares a user-defined resource' do
1492
+ Given "a recipe that declares a user-defined resource" do
1493
1493
  write_recipe %q{
1494
1494
  apple "golden-delicious" do
1495
1495
  colour "yellow"
@@ -1498,7 +1498,7 @@ Given 'a recipe that declares a user-defined resource' do
1498
1498
  }
1499
1499
  end
1500
1500
 
1501
- Given 'a recipe that declares multiple resources of the same type of which one has a bad attribute' do
1501
+ Given "a recipe that declares multiple resources of the same type of which one has a bad attribute" do
1502
1502
  write_recipe %q{
1503
1503
  file "/tmp/something" do
1504
1504
  owner "root"
@@ -1518,7 +1518,7 @@ Given 'a recipe that declares multiple resources of the same type of which one h
1518
1518
  }
1519
1519
  end
1520
1520
 
1521
- Given 'a resource declared with a guard within a loop with multiple block arguments' do
1521
+ Given "a resource declared with a guard within a loop with multiple block arguments" do
1522
1522
  write_recipe %q{
1523
1523
  {
1524
1524
  'foo' => 'bar',
@@ -1532,7 +1532,7 @@ Given 'a resource declared with a guard within a loop with multiple block argume
1532
1532
  }
1533
1533
  end
1534
1534
 
1535
- Given 'a resource that declares a guard containing a block' do
1535
+ Given "a resource that declares a guard containing a block" do
1536
1536
  write_recipe %q{
1537
1537
  template '/etc/foo' do
1538
1538
  not_if do
@@ -1551,8 +1551,7 @@ Given 'a resource that declares a guard containing a block' do
1551
1551
  }
1552
1552
  end
1553
1553
 
1554
-
1555
- Given 'a resource declared within a definition' do
1554
+ Given "a resource declared within a definition" do
1556
1555
  write_recipe %q{
1557
1556
  define :toto, {
1558
1557
  } do
@@ -1572,7 +1571,7 @@ Given /^a rule that (declares|does not declare) a version constraint(?: of ([^ ]
1572
1571
  else
1573
1572
  from_version = case constraint
1574
1573
  when /not/ then nil
1575
- else '0.10.6'
1574
+ else "0.10.6"
1576
1575
  end
1577
1576
  rule_with_version_constraint(from_version, nil)
1578
1577
  end
@@ -1587,13 +1586,13 @@ Given /^a template that includes a partial( that includes the original template
1587
1586
  })
1588
1587
  end
1589
1588
  }
1590
- write_file 'cookbooks/example/templates/default/a.erb', '<%= render "b.erb" %>'
1589
+ write_file "cookbooks/example/templates/default/a.erb", '<%= render "b.erb" %>'
1591
1590
  content = if loops
1592
- '<%= render "a.erb" %>'
1593
- else
1594
- '<%= @config_var %>'
1591
+ '<%= render "a.erb" %>'
1592
+ else
1593
+ "<%= @config_var %>"
1595
1594
  end
1596
- write_file 'cookbooks/example/templates/default/b.erb', content
1595
+ write_file "cookbooks/example/templates/default/b.erb", content
1597
1596
  end
1598
1597
 
1599
1598
  Given /^a template that includes a (missing )?partial with a relative subdirectory path$/ do |missing|
@@ -1605,19 +1604,19 @@ Given /^a template that includes a (missing )?partial with a relative subdirecto
1605
1604
  })
1606
1605
  end
1607
1606
  }
1608
- write_file 'cookbooks/example/templates/default/a.erb', '<%= render "partials/b.erb" %>'
1607
+ write_file "cookbooks/example/templates/default/a.erb", '<%= render "partials/b.erb" %>'
1609
1608
  unless missing
1610
- write_file 'cookbooks/example/templates/default/partials/b.erb', 'Partial content'
1609
+ write_file "cookbooks/example/templates/default/partials/b.erb", "Partial content"
1611
1610
  end
1612
1611
  end
1613
1612
 
1614
- Given 'access to the man page documentation' do
1613
+ Given "access to the man page documentation" do
1615
1614
 
1616
1615
  end
1617
1616
 
1618
1617
  Given /^another cookbook that has (an older )?chef-solo-search installed$/ do |older|
1619
1618
  if older.nil?
1620
- write_library 'search', %q{
1619
+ write_library "search", %q{
1621
1620
  class Chef
1622
1621
  module Mixin
1623
1622
  module Language
@@ -1629,7 +1628,7 @@ Given /^another cookbook that has (an older )?chef-solo-search installed$/ do |o
1629
1628
  end
1630
1629
  }
1631
1630
  else
1632
- write_library 'search', %q{
1631
+ write_library "search", %q{
1633
1632
  class Chef
1634
1633
  class Recipe
1635
1634
  def search(bag_name, query=nil, sort=nil, start=0, rows=1000, &block)
@@ -1641,11 +1640,11 @@ Given /^another cookbook that has (an older )?chef-solo-search installed$/ do |o
1641
1640
  end
1642
1641
  end
1643
1642
 
1644
- Given 'I have installed the lint tool' do
1643
+ Given "I have installed the lint tool" do
1645
1644
 
1646
1645
  end
1647
1646
 
1648
- Given 'metadata' do
1647
+ Given "metadata" do
1649
1648
  write_metadata %q{
1650
1649
  name 'example'
1651
1650
  }.strip
@@ -1656,14 +1655,14 @@ Given /^(?:a cookbook that has|the cookbook has) a Gemfile that includes rake an
1656
1655
  end
1657
1656
 
1658
1657
  Given /^the current stable version of Chef (falls|does not fall) within it$/ do |falls_within|
1659
- rule_with_version_constraint("98.10", nil) unless falls_within.include?('falls')
1658
+ rule_with_version_constraint("98.10", nil) unless falls_within.include?("falls")
1660
1659
  end
1661
1660
 
1662
- Given 'the gems have been vendored' do
1661
+ Given "the gems have been vendored" do
1663
1662
  vendor_gems
1664
1663
  end
1665
1664
 
1666
- Given 'the last role name declared does not match the containing filename' do
1665
+ Given "the last role name declared does not match the containing filename" do
1667
1666
 
1668
1667
  end
1669
1668
 
@@ -1673,38 +1672,38 @@ Given /^the inferred template contains the expression (.*)$/ do |expr|
1673
1672
  }
1674
1673
  end
1675
1674
 
1676
- Given /^the template (.+)?contains the expression (.*)$/ do |ext,expr|
1675
+ Given /^the template (.+)?contains the expression (.*)$/ do |ext, expr|
1677
1676
  file = if ext
1678
- "templates/default/config#{ext.strip}"
1679
- else
1680
- 'templates/default/config.conf.erb'
1677
+ "templates/default/config#{ext.strip}"
1678
+ else
1679
+ "templates/default/config.conf.erb"
1681
1680
  end
1682
1681
  write_file "cookbooks/example/#{file}", %Q{
1683
1682
  <%= #{expr} %>
1684
1683
  }
1685
1684
  end
1686
1685
 
1687
- Given /^the template (.+)?contains partial includes of type (.*) with the expression (.*)$/ do |ext,type,expr|
1686
+ Given /^the template (.+)?contains partial includes of type (.*) with the expression (.*)$/ do |ext, type, expr|
1688
1687
  file = if ext
1689
- "config#{ext.strip}"
1690
- else
1691
- 'config.conf.erb'
1688
+ "config#{ext.strip}"
1689
+ else
1690
+ "config.conf.erb"
1692
1691
  end
1693
- if type == 'nested' and expr.split(',').length > 1
1694
- expressions = expr.split(',')
1695
- includes = (1..expressions.length).map{|i| "included_template_#{i}.erb"}
1692
+ if type == "nested" && expr.split(",").length > 1
1693
+ expressions = expr.split(",")
1694
+ includes = (1..expressions.length).map { |i| "included_template_#{i}.erb" }
1696
1695
  (Array(file) + includes).zip(includes).map do |parent, child|
1697
1696
  content = if child
1698
- "<%= render '#{child}' %>"
1699
- else
1700
- expressions.map{|e| "<%= #{e} %>"}.join("\n")
1697
+ "<%= render '#{child}' %>"
1698
+ else
1699
+ expressions.map { |e| "<%= #{e} %>" }.join("\n")
1701
1700
  end
1702
1701
  [parent, content]
1703
1702
  end.each do |template_name, content|
1704
1703
  write_file "cookbooks/example/templates/default/#{template_name}", content
1705
1704
  end
1706
1705
  else
1707
- if type == 'no parentheses'
1706
+ if type == "no parentheses"
1708
1707
  include_string = "<%= render 'included_template.erb' %>"
1709
1708
  else
1710
1709
  include_string = "<%= render('included_template.erb') %>"
@@ -1718,11 +1717,11 @@ Given /^the template (.+)?contains partial includes of type (.*) with the expres
1718
1717
  end
1719
1718
  end
1720
1719
 
1721
- Given 'unit tests under a top-level test directory' do
1720
+ Given "unit tests under a top-level test directory" do
1722
1721
  minitest_spec_attributes
1723
1722
  end
1724
1723
 
1725
- Given 'a recipe that installs a gem with 5 retries' do
1724
+ Given "a recipe that installs a gem with 5 retries" do
1726
1725
  write_recipe %q{
1727
1726
  gem_package "foo" do
1728
1727
  retries 5
@@ -1731,7 +1730,7 @@ Given 'a recipe that installs a gem with 5 retries' do
1731
1730
  }
1732
1731
  end
1733
1732
 
1734
- Given 'a recipe that creates a raid array with mdadm specifying layout' do
1733
+ Given "a recipe that creates a raid array with mdadm specifying layout" do
1735
1734
  write_recipe %q{
1736
1735
  mdadm '/dev/md0' do
1737
1736
  devices [ '/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd' ]
@@ -1742,7 +1741,7 @@ Given 'a recipe that creates a raid array with mdadm specifying layout' do
1742
1741
  }
1743
1742
  end
1744
1743
 
1745
- Given 'a recipe that tries to mask a systemd service' do
1744
+ Given "a recipe that tries to mask a systemd service" do
1746
1745
  write_recipe %q{
1747
1746
  service 'foo' do
1748
1747
  action :mask
@@ -1763,37 +1762,37 @@ Given /^a recipe that uses include_recipe$/ do
1763
1762
  end
1764
1763
 
1765
1764
  Given /^a ruby environment file that defines an environment with name (.*)$/ do |env_name|
1766
- environment(:environment_name => %Q{"#{env_name}"}, :file_name => 'production.rb')
1765
+ environment(:environment_name => %Q{"#{env_name}"}, :file_name => "production.rb")
1767
1766
  end
1768
1767
 
1769
1768
  Given /^a ruby environment that triggers FC050 with comment (.*)$/ do |comment|
1770
- write_file 'environments/production.rb', %Q{
1769
+ write_file "environments/production.rb", %Q{
1771
1770
  name "Production (eu-west-1)" #{comment}
1772
1771
  run_list "recipe[apache2]"
1773
1772
  }.strip
1774
1773
  end
1775
1774
 
1776
1775
  Given /^a ruby role file that defines a role with name (.*)$/ do |role_name|
1777
- role(:role_name => [%Q{"#{role_name}"}], :file_name => 'webserver.rb')
1776
+ role(:role_name => [%Q{"#{role_name}"}], :file_name => "webserver.rb")
1778
1777
  end
1779
1778
 
1780
1779
  Given /^a ruby role that triggers FC049 with comment (.*)$/ do |comment|
1781
- write_file 'roles/webserver.rb', %Q{
1780
+ write_file "roles/webserver.rb", %Q{
1782
1781
  name "apache" #{comment}
1783
1782
  run_list "recipe[apache2]"
1784
1783
  }.strip
1785
1784
  end
1786
1785
 
1787
1786
  Given /^a template directory that contains a binary file (.*) that is not valid UTF-8$/ do |filename|
1788
- template_dir = 'cookbooks/example/templates/default'
1789
- write_recipe ''
1790
- write_file "#{template_dir}/innocent_template.erb", '<%= hello %>'
1791
- File.open("#{expand_path('.')}/#{template_dir}/#{filename}", 'wb'){|f| f.putc(0x93)}
1787
+ template_dir = "cookbooks/example/templates/default"
1788
+ write_recipe ""
1789
+ write_file "#{template_dir}/innocent_template.erb", "<%= hello %>"
1790
+ File.open("#{expand_path('.')}/#{template_dir}/#{filename}", "wb") { |f| f.putc(0x93) }
1792
1791
  end
1793
1792
 
1794
- Given 'each role directory has a role with a name that does not match the containing file name' do
1795
- role(:dir => 'roles1', :role_name => '"apache"', :file_name => 'webserver.rb')
1796
- role(:dir => 'roles2', :role_name => '"postgresql"', :file_name => 'database.rb')
1793
+ Given "each role directory has a role with a name that does not match the containing file name" do
1794
+ role(:dir => "roles1", :role_name => '"apache"', :file_name => "webserver.rb")
1795
+ role(:dir => "roles2", :role_name => '"postgresql"', :file_name => "database.rb")
1797
1796
  end
1798
1797
 
1799
1798
  Given /^it contains an environment file (.*\.rb) that defines the environment name (.*)$/ do |file_name, env_name|
@@ -1805,45 +1804,45 @@ Given /^it contains a role file ([a-z]+\.rb) that defines the role name (.*)$/ d
1805
1804
  end
1806
1805
 
1807
1806
  Given /^the cookbook metadata declares support for (.*)$/ do |supported_platforms|
1808
- write_metadata(supported_platforms.split(',').map do |platform|
1807
+ write_metadata(supported_platforms.split(",").map do |platform|
1809
1808
  "supports '#{platform}'"
1810
1809
  end.join("\n"))
1811
1810
  end
1812
1811
 
1813
- Given 'the cookbook metadata declares support with versions specified' do
1812
+ Given "the cookbook metadata declares support with versions specified" do
1814
1813
  write_metadata %q{
1815
1814
  supports 'redhat', '>= 6'
1816
1815
  supports 'scientific', '>= 6'
1817
1816
  }.strip
1818
1817
  end
1819
1818
 
1820
- Given 'three of the recipes read node attributes via strings' do
1821
- (1..3).map{|i| "string_#{i}"}.each do |recipe|
1819
+ Given "three of the recipes read node attributes via strings" do
1820
+ (1..3).map { |i| "string_#{i}" }.each do |recipe|
1822
1821
  write_file "cookbooks/example/recipes/#{recipe}.rb", "Chef::Log.warn node['foo']"
1823
1822
  end
1824
1823
  end
1825
1824
 
1826
- Given 'two of the recipes read node attributes via symbols' do
1827
- (1..2).map{|i| "symbol_#{i}"}.each do |recipe|
1825
+ Given "two of the recipes read node attributes via symbols" do
1826
+ (1..2).map { |i| "symbol_#{i}" }.each do |recipe|
1828
1827
  write_file "cookbooks/example/recipes/#{recipe}.rb", "Chef::Log.warn node[:foo]"
1829
1828
  end
1830
1829
  end
1831
1830
 
1832
- Given 'two roles directories' do
1831
+ Given "two roles directories" do
1833
1832
 
1834
1833
  end
1835
1834
 
1836
1835
  When /^I check the cookbook specifying ([^ ]+) as the Chef version$/ do |version|
1837
- options = ['-c', version, 'cookbooks/example']
1838
- cd '.' do
1839
- options = ['-I', 'rules/test.rb'] + options if Dir.exist?('rules')
1836
+ options = ["-c", version, "cookbooks/example"]
1837
+ cd "." do
1838
+ options = ["-I", "rules/test.rb"] + options if Dir.exist?("rules")
1840
1839
  end
1841
1840
  run_lint(options)
1842
1841
  end
1843
1842
 
1844
1843
  When /^I check the cookbook( tree)?(?: specifying tags(.*))?(, specifying that context should be shown)?$/ do |whole_tree, tags, context|
1845
- options = tags.nil? ? [] : tags.split(' ')
1846
- options += ['-C'] unless context.nil?
1844
+ options = tags.nil? ? [] : tags.split(" ")
1845
+ options += ["-C"] unless context.nil?
1847
1846
  run_lint(options + ["cookbooks/#{whole_tree.nil? ? 'example' : ''}"])
1848
1847
  end
1849
1848
 
@@ -1852,13 +1851,13 @@ Given /^the cookbook directory has a \.foodcritic file specifying tags (.*)$/ do
1852
1851
  run_lint(["cookbooks/example"])
1853
1852
  end
1854
1853
 
1855
- When 'I check both cookbooks specified as arguments' do
1854
+ When "I check both cookbooks specified as arguments" do
1856
1855
  run_lint(["cookbooks/another_example", "cookbooks/example"])
1857
1856
  end
1858
1857
 
1859
1858
  When /^I check both cookbooks with the command-line (.*)$/ do |command_line|
1860
- cmds = command_line.split(' ').map do |c|
1861
- if c.end_with?('example')
1859
+ cmds = command_line.split(" ").map do |c|
1860
+ if c.end_with?("example")
1862
1861
  "cookbooks/#{c}"
1863
1862
  else
1864
1863
  c
@@ -1867,66 +1866,66 @@ When /^I check both cookbooks with the command-line (.*)$/ do |command_line|
1867
1866
  run_lint(cmds)
1868
1867
  end
1869
1868
 
1870
- When 'I check both roles directories' do
1871
- run_lint ['-R', 'roles1', '-R', 'roles2']
1869
+ When "I check both roles directories" do
1870
+ run_lint ["-R", "roles1", "-R", "roles2"]
1872
1871
  end
1873
1872
 
1874
- When 'I check the cookbooks, role and environment together' do
1873
+ When "I check the cookbooks, role and environment together" do
1875
1874
  run_lint([
1876
- '-B', 'cookbooks/another_example', '-B', 'cookbooks/example',
1877
- '-E', 'environments',
1878
- '-R', 'roles'
1875
+ "-B", "cookbooks/another_example", "-B", "cookbooks/example",
1876
+ "-E", "environments",
1877
+ "-R", "roles"
1879
1878
  ])
1880
1879
  end
1881
1880
 
1882
- When 'I check the cookbook without specifying a Chef version' do
1883
- run_lint(['-I', 'rules/test.rb', 'cookbooks/example'])
1881
+ When "I check the cookbook without specifying a Chef version" do
1882
+ run_lint(["-I", "rules/test.rb", "cookbooks/example"])
1884
1883
  end
1885
1884
 
1886
- When 'I check the environment directory' do
1887
- run_lint ['-E', 'environments']
1885
+ When "I check the environment directory" do
1886
+ run_lint ["-E", "environments"]
1888
1887
  end
1889
1888
 
1890
- When 'I check the eu environment file only' do
1891
- run_lint ['-E', 'environments/production_eu.rb']
1889
+ When "I check the eu environment file only" do
1890
+ run_lint ["-E", "environments/production_eu.rb"]
1892
1891
  end
1893
1892
 
1894
1893
  When /^I check the cookbook( without)? excluding the ([^ ]+) directory$/ do |no_exclude, dir|
1895
- options = no_exclude.nil? ? ['-X', dir] : []
1896
- run_lint(options + ['cookbooks/example'])
1894
+ options = no_exclude.nil? ? ["-X", dir] : []
1895
+ run_lint(options + ["cookbooks/example"])
1897
1896
  end
1898
1897
 
1899
- When 'I check the recipe' do
1898
+ When "I check the recipe" do
1900
1899
  run_lint(["cookbooks/example/recipes/default.rb"])
1901
1900
  end
1902
1901
 
1903
- When 'I compare the man page options against the usage options' do
1902
+ When "I compare the man page options against the usage options" do
1904
1903
 
1905
1904
  end
1906
1905
 
1907
- When 'I check the role directory' do
1908
- run_lint ['-R', 'roles']
1906
+ When "I check the role directory" do
1907
+ run_lint ["-R", "roles"]
1909
1908
  end
1910
1909
 
1911
1910
  When /^I check the role directory as a (default|cookbook|role) path$/ do |path_type|
1912
1911
  options = case path_type
1913
- when 'default' then ['roles']
1914
- when 'cookbook' then ['-B', 'roles']
1915
- when 'role' then ['-R', 'roles']
1912
+ when "default" then ["roles"]
1913
+ when "cookbook" then ["-B", "roles"]
1914
+ when "role" then ["-R", "roles"]
1916
1915
  end
1917
1916
  run_lint(options)
1918
1917
  end
1919
1918
 
1920
- When 'I check the webserver role only' do
1921
- run_lint ['-R', 'roles/webserver.rb']
1919
+ When "I check the webserver role only" do
1920
+ run_lint ["-R", "roles/webserver.rb"]
1922
1921
  end
1923
1922
 
1924
- When 'I list the available build tasks' do
1923
+ When "I list the available build tasks" do
1925
1924
  list_available_build_tasks
1926
1925
  end
1927
1926
 
1928
1927
  When /^I run it on the command line including a custom rule (file|directory) containing a rule that matches$/ do |path_type|
1929
- write_file 'rules/custom_rules.rb', %q{
1928
+ write_file "rules/custom_rules.rb", %q{
1930
1929
  rule "BAR001", "Use symbols in preference to strings to access node attributes" do
1931
1930
  tags %w{style attributes}
1932
1931
  recipe do |ast|
@@ -1934,37 +1933,37 @@ When /^I run it on the command line including a custom rule (file|directory) con
1934
1933
  end
1935
1934
  end
1936
1935
  }
1937
- run_lint(['-I',
1938
- path_type == 'file' ? 'rules/custom_rules.rb' : 'rules',
1939
- 'cookbooks/example'])
1936
+ run_lint(["-I",
1937
+ path_type == "file" ? "rules/custom_rules.rb" : "rules",
1938
+ "cookbooks/example"])
1940
1939
  end
1941
1940
 
1942
1941
  When /^I run it on the command line including a file which does not contain Ruby code$/ do
1943
- write_file 'rules/invalid_rules.rb', 'echo "not ruby"'
1942
+ write_file "rules/invalid_rules.rb", 'echo "not ruby"'
1944
1943
  capture_error do
1945
- run_lint(['-I', 'rules/invalid_rules.rb', 'cookbooks/example'])
1944
+ run_lint(["-I", "rules/invalid_rules.rb", "cookbooks/example"])
1946
1945
  end
1947
1946
  end
1948
1947
 
1949
1948
  When /^I run it on the command line including a missing custom rule file$/ do
1950
1949
  capture_error do
1951
- run_lint(['-I', 'rules/missing_rules.rb', 'cookbooks/example'])
1950
+ run_lint(["-I", "rules/missing_rules.rb", "cookbooks/example"])
1952
1951
  end
1953
1952
  end
1954
1953
 
1955
- When 'I run it on the command line specifying a cookbook that does not exist' do
1956
- run_lint(['no-such-cookbook'])
1954
+ When "I run it on the command line specifying a cookbook that does not exist" do
1955
+ run_lint(["no-such-cookbook"])
1957
1956
  end
1958
1957
 
1959
1958
  When /^I run it on the command line specifying a( role|n environment) directory that does not exist$/ do |type|
1960
- if type.include?('role')
1961
- run_lint(['-R', 'no-such-role-dir'])
1959
+ if type.include?("role")
1960
+ run_lint(["-R", "no-such-role-dir"])
1962
1961
  else
1963
- run_lint(['-E', 'no-such-environment-dir'])
1962
+ run_lint(["-E", "no-such-environment-dir"])
1964
1963
  end
1965
1964
  end
1966
1965
 
1967
- When 'I run it on the command line with no arguments' do
1966
+ When "I run it on the command line with no arguments" do
1968
1967
  run_lint([])
1969
1968
  end
1970
1969
 
@@ -1979,15 +1978,15 @@ When /^I run it on the command line with the (?:unimplemented |)([^ ]+) option(
1979
1978
  run_lint(options)
1980
1979
  end
1981
1980
 
1982
- When 'I run the build' do
1981
+ When "I run the build" do
1983
1982
  run_build
1984
1983
  end
1985
1984
 
1986
- Then 'a warning for the custom rule should be displayed' do
1987
- expect_output('BAR001: Use symbols in preference to strings to access node attributes: cookbooks/example/recipes/default.rb:1')
1985
+ Then "a warning for the custom rule should be displayed" do
1986
+ expect_output("BAR001: Use symbols in preference to strings to access node attributes: cookbooks/example/recipes/default.rb:1")
1988
1987
  end
1989
1988
 
1990
- Then 'all options should be documented in the man page' do
1989
+ Then "all options should be documented in the man page" do
1991
1990
  man_page_options.must_equal usage_options_for_diff
1992
1991
  end
1993
1992
 
@@ -1995,81 +1994,81 @@ Then /^an? '([^']+)' error should be displayed$/ do |expected_error|
1995
1994
  last_error.must_include expected_error
1996
1995
  end
1997
1996
 
1998
- Then 'the attribute consistency warning 019 should be shown for both of the recipes that use symbols' do
1999
- expect_warning 'FC019', :file => 'recipes/symbol_1.rb'
2000
- expect_warning 'FC019', :file => 'recipes/symbol_2.rb'
1997
+ Then "the attribute consistency warning 019 should be shown for both of the recipes that use symbols" do
1998
+ expect_warning "FC019", :file => "recipes/symbol_1.rb"
1999
+ expect_warning "FC019", :file => "recipes/symbol_2.rb"
2001
2000
  end
2002
2001
 
2003
2002
  Then /^the bare attribute keys warning 044 should not be displayed against the (brace|do) block$/ do |block_type|
2004
- line = block_type == 'brace' ? 2 : 3
2005
- expect_warning 'FC044', {:expect_warning => false, :line => line, :file_type => :attributes}
2003
+ line = block_type == "brace" ? 2 : 3
2004
+ expect_warning "FC044", { :expect_warning => false, :line => line, :file_type => :attributes }
2006
2005
  end
2007
2006
 
2008
2007
  Then /^the bare attribute keys warning 044 should not be displayed against the (?:local variable|library call)$/ do
2009
- expect_warning 'FC044', {:expect_warning => false, :line => 2, :file_type => :attributes}
2008
+ expect_warning "FC044", { :expect_warning => false, :line => 2, :file_type => :attributes }
2010
2009
  end
2011
2010
 
2012
2011
  Then /^the bare attribute keys warning 044 should not be displayed against the new line$/ do
2013
- expect_warning 'FC044', {:expect_warning => false, :line => 3, :file_type => :attributes}
2012
+ expect_warning "FC044", { :expect_warning => false, :line => 3, :file_type => :attributes }
2014
2013
  end
2015
2014
 
2016
- Then 'the execute resource used to run git commands warning 040 should be displayed against the last resource' do
2017
- expect_warning 'FC040', {:line => 7}
2015
+ Then "the execute resource used to run git commands warning 040 should be displayed against the last resource" do
2016
+ expect_warning "FC040", { :line => 7 }
2018
2017
  end
2019
2018
 
2020
2019
  Then /^the LWRP does not notify when updated warning 017 should( not)? be shown against the :([^ ]+) action$/ do |not_shown, action|
2021
- line = action == 'create' ? 1 : 8
2022
- expect_warning('FC017', :file_type => :provider, :expect_warning => ! not_shown, :line => line)
2020
+ line = action == "create" ? 1 : 8
2021
+ expect_warning("FC017", :file_type => :provider, :expect_warning => ! not_shown, :line => line)
2023
2022
  end
2024
2023
 
2025
2024
  Then /^the invalid (role|environment) name warning 050 should( not)? be shown$/ do |type, not_shown|
2026
- file = type == 'role' ? 'roles/webserver.rb' : 'environments/production.rb'
2027
- expect_warning 'FC050', {:expect_warning => ! not_shown, :file => file}
2025
+ file = type == "role" ? "roles/webserver.rb" : "environments/production.rb"
2026
+ expect_warning "FC050", { :expect_warning => ! not_shown, :file => file }
2028
2027
  end
2029
2028
 
2030
2029
  Then /^the invalid environment name warning 050 should( not)? be shown against the (eu|us) environment$/ do |not_shown, env|
2031
- expect_warning 'FC050', {:expect_warning => ! not_shown,
2032
- :file => "environments/production_#{env}.rb", :line => 1}
2030
+ expect_warning "FC050", { :expect_warning => ! not_shown,
2031
+ :file => "environments/production_#{env}.rb", :line => 1 }
2033
2032
  end
2034
2033
 
2035
- Then 'the prefer mixlib shellout warning 048 should not be displayed against the group resource' do
2036
- expect_warning 'FC048', {:expect_warning => false, :line => 2}
2034
+ Then "the prefer mixlib shellout warning 048 should not be displayed against the group resource" do
2035
+ expect_warning "FC048", { :expect_warning => false, :line => 2 }
2037
2036
  end
2038
2037
 
2039
- Then 'the prefer mixlib shellout warning 048 should not be displayed against the user resource' do
2040
- expect_warning 'FC048', {:expect_warning => false, :line => 2}
2038
+ Then "the prefer mixlib shellout warning 048 should not be displayed against the user resource" do
2039
+ expect_warning "FC048", { :expect_warning => false, :line => 2 }
2041
2040
  end
2042
2041
 
2043
- Then 'the prefer mixlib shellout warning 048 should be displayed against the ruby_block resource' do
2044
- expect_warning('FC048', :file_type => :provider, :line => 4)
2042
+ Then "the prefer mixlib shellout warning 048 should be displayed against the ruby_block resource" do
2043
+ expect_warning("FC048", :file_type => :provider, :line => 4)
2045
2044
  end
2046
2045
 
2047
2046
  Then /^the role name does not match file name warning 049 should( not)? be shown( against the second name)?$/ do |not_shown, second|
2048
- expect_warning 'FC049', {:expect_warning => ! not_shown,
2049
- :file => 'roles/webserver.rb', :line => second ? 2 : 1}
2047
+ expect_warning "FC049", { :expect_warning => ! not_shown,
2048
+ :file => "roles/webserver.rb", :line => second ? 2 : 1 }
2050
2049
  end
2051
2050
 
2052
- Then 'the role name does not match file name warning 049 should be shown against the files in both directories' do
2053
- expect_warning 'FC049', {:file => "roles1/webserver.rb", :line => 1}
2054
- expect_warning 'FC049', {:file => "roles2/database.rb", :line => 1}
2051
+ Then "the role name does not match file name warning 049 should be shown against the files in both directories" do
2052
+ expect_warning "FC049", { :file => "roles1/webserver.rb", :line => 1 }
2053
+ expect_warning "FC049", { :file => "roles2/database.rb", :line => 1 }
2055
2054
  end
2056
2055
 
2057
2056
  Then /^the role name does not match file name warning 049 should( not)? be shown against the (webserver|database) role$/ do |not_shown, role|
2058
- expect_warning 'FC049', {:expect_warning => ! not_shown,
2059
- :file => "roles/#{role}.rb", :line => 1}
2057
+ expect_warning "FC049", { :expect_warning => ! not_shown,
2058
+ :file => "roles/#{role}.rb", :line => 1 }
2060
2059
  end
2061
2060
 
2062
- Then 'the long ruby block warning 014 should be displayed against the long block only' do
2063
- expect_warning 'FC014', {:expect_warning => false, :line => 1}
2064
- expect_warning 'FC014', {:expect_warning => true, :line => 11}
2061
+ Then "the long ruby block warning 014 should be displayed against the long block only" do
2062
+ expect_warning "FC014", { :expect_warning => false, :line => 1 }
2063
+ expect_warning "FC014", { :expect_warning => true, :line => 11 }
2065
2064
  end
2066
2065
 
2067
2066
  Then /^the lint task will be listed( under the different name)?$/ do |diff_name|
2068
- expected_name = diff_name ? 'lint' : 'foodcritic'
2069
- build_tasks.must_include([expected_name, 'Lint Chef cookbooks'])
2067
+ expected_name = diff_name ? "lint" : "foodcritic"
2068
+ build_tasks.must_include([expected_name, "Lint Chef cookbooks"])
2070
2069
  end
2071
2070
 
2072
- Then 'no error should have occurred' do
2071
+ Then "no error should have occurred" do
2073
2072
  assert_no_error_occurred
2074
2073
  end
2075
2074
 
@@ -2081,38 +2080,38 @@ Then /^(no )?warnings will be displayed against the tests$/ do |no_display|
2081
2080
  end
2082
2081
  end
2083
2082
 
2084
- Then 'the attribute consistency warning 019 should warn on lines 2 and 10 in that order' do
2083
+ Then "the attribute consistency warning 019 should warn on lines 2 and 10 in that order" do
2085
2084
  expected_warnings = [2, 10].map do |line|
2086
2085
  "FC019: Access node attributes in a consistent manner: cookbooks/example/recipes/default.rb:#{line}"
2087
2086
  end
2088
2087
  expect_output(expected_warnings.join("\n"))
2089
2088
  end
2090
2089
 
2091
- Then 'the attribute consistency warning 019 should be displayed for the recipe' do
2092
- expect_warning('FC019', :line => 2)
2090
+ Then "the attribute consistency warning 019 should be displayed for the recipe" do
2091
+ expect_warning("FC019", :line => 2)
2093
2092
  end
2094
2093
 
2095
- Then 'the attribute consistency warning 019 should not be displayed for the attributes' do
2096
- expect_warning('FC019', :file_type => :attributes, :line => 1, :expect_warning => false)
2094
+ Then "the attribute consistency warning 019 should not be displayed for the attributes" do
2095
+ expect_warning("FC019", :file_type => :attributes, :line => 1, :expect_warning => false)
2097
2096
  end
2098
2097
 
2099
- Then /^the warning ([0-9]+ )?should (not )?be (?:displayed|shown)$/ do |warning,should_not|
2100
- code = warning.nil? ? 'FCTEST001' : "FC#{warning.strip}"
2101
- expect_warning code, {:expect_warning => should_not.nil?}
2098
+ Then /^the warning ([0-9]+ )?should (not )?be (?:displayed|shown)$/ do |warning, should_not|
2099
+ code = warning.nil? ? "FCTEST001" : "FC#{warning.strip}"
2100
+ expect_warning code, { :expect_warning => should_not.nil? }
2102
2101
  end
2103
2102
 
2104
2103
  Then /^the (?:[a-zA-Z \-_]+) warning ([0-9]+) should (not )?be displayed(?: against the (attributes|libraries|definition|metadata|provider|resource|README.md|README.rdoc) file)?( below)?(?: on (?:(any line)|(?:line ([0-9]+))))?$/ do |code, no_display, file, warning_only, any_line, line|
2105
2104
  options = {}
2106
- options[:expect_warning] = no_display != 'not '
2105
+ options[:expect_warning] = no_display != "not "
2107
2106
  unless file.nil?
2108
- if file.include?('.')
2107
+ if file.include?(".")
2109
2108
  options[:file] = file
2110
2109
  else
2111
2110
  options[:file_type] = file.to_sym
2112
2111
  end
2113
2112
  end
2114
- options[:line] = 3 if code == '018' and options[:expect_warning]
2115
- options[:line] = 2 if ['021', '022'].include?(code)
2113
+ options[:line] = 3 if code == "018" && options[:expect_warning]
2114
+ options[:line] = 2 if %w{021 022}.include?(code)
2116
2115
 
2117
2116
  if any_line
2118
2117
  options[:line] = nil
@@ -2125,44 +2124,44 @@ Then /^the (?:[a-zA-Z \-_]+) warning ([0-9]+) should (not )?be displayed(?: agai
2125
2124
  end
2126
2125
 
2127
2126
  Then /^the attribute consistency warning 019 should be (shown|not shown)$/ do |show_warning|
2128
- expect_warning('FC019', :line => nil, :expect_warning => show_warning == 'shown')
2127
+ expect_warning("FC019", :line => nil, :expect_warning => show_warning == "shown")
2129
2128
  end
2130
2129
 
2131
2130
  Then /^the boilerplate metadata warning 008 should warn on lines (.*)$/ do |lines_to_warn|
2132
- if lines_to_warn.strip == ''
2133
- expect_no_warning('FC008')
2131
+ if lines_to_warn.strip == ""
2132
+ expect_no_warning("FC008")
2134
2133
  else
2135
- lines_to_warn.split(',').each{|line| expect_warning('FC008', :line => line, :file => 'metadata.rb')}
2134
+ lines_to_warn.split(",").each { |line| expect_warning("FC008", :line => line, :file => "metadata.rb") }
2136
2135
  end
2137
2136
  end
2138
2137
 
2139
2138
  Then /the build status should be (successful|failed)$/ do |build_outcome|
2140
- build_outcome == 'successful' ? assert_no_error_occurred : assert_error_occurred
2139
+ build_outcome == "successful" ? assert_no_error_occurred : assert_error_occurred
2141
2140
  end
2142
2141
 
2143
2142
  Then /^the build will (succeed|fail) with (?:no )?warnings(.*)$/ do |build_outcome, warnings|
2144
- assert_build_result(build_outcome == 'succeed', warnings.delete(' ').split(','))
2143
+ assert_build_result(build_outcome == "succeed", warnings.delete(" ").split(","))
2145
2144
  end
2146
2145
 
2147
- Then 'the check for server warning 003 should not be displayed against the condition' do
2146
+ Then "the check for server warning 003 should not be displayed against the condition" do
2148
2147
  expect_warning("FC003", :line => nil, :expect_warning => false)
2149
2148
  end
2150
2149
 
2151
2150
  Then /^the check for server warning 003 should not be displayed against the search after the (.*) conditional$/ do |format|
2152
- line = format == 'oneline' ? 2 : 4
2151
+ line = format == "oneline" ? 2 : 4
2153
2152
  expect_warning("FC003", :line => line, :expect_warning => false)
2154
2153
  end
2155
2154
 
2156
- Then 'the check for server warning 003 should not be displayed given we have checked' do
2155
+ Then "the check for server warning 003 should not be displayed given we have checked" do
2157
2156
  expect_warning("FC003", :line => 4, :expect_warning => false)
2158
2157
  end
2159
2158
 
2160
2159
  Then /^the consider adding platform warning 024 should( not)? be shown$/ do |should_not|
2161
- expect_warning('FC024', :line => should_not.nil? ? @expected_line : nil, :expect_warning => should_not.nil?)
2160
+ expect_warning("FC024", :line => should_not.nil? ? @expected_line : nil, :expect_warning => should_not.nil?)
2162
2161
  end
2163
2162
 
2164
2163
  Then /^the conditional block contains only string warning 026 should be (shown|not shown)$/ do |show_warning|
2165
- expect_warning('FC026', :line => nil, :expect_warning => show_warning == 'shown')
2164
+ expect_warning("FC026", :line => nil, :expect_warning => show_warning == "shown")
2166
2165
  end
2167
2166
 
2168
2167
  Then /^the current version should( not)? be displayed$/ do |no_display|
@@ -2176,27 +2175,27 @@ end
2176
2175
 
2177
2176
  Then /^the debugger breakpoint warning 030 should be (not )?shown against the (.*)$/ do |should_not, component|
2178
2177
  filename = case component
2179
- when 'library' then 'libraries/foo.rb'
2180
- when 'metadata' then 'metadata.rb'
2181
- when 'provider' then 'providers/foo.rb'
2182
- when 'recipe' then 'recipes/default.rb'
2183
- when 'resource' then 'resources/foo.rb'
2184
- when 'template' then 'templates/default/foo.erb'
2178
+ when "library" then "libraries/foo.rb"
2179
+ when "metadata" then "metadata.rb"
2180
+ when "provider" then "providers/foo.rb"
2181
+ when "recipe" then "recipes/default.rb"
2182
+ when "resource" then "resources/foo.rb"
2183
+ when "template" then "templates/default/foo.erb"
2185
2184
  end
2186
- expect_warning('FC030', :line => nil, :expect_warning => should_not.nil?, :file => filename)
2185
+ expect_warning("FC030", :line => nil, :expect_warning => should_not.nil?, :file => filename)
2187
2186
  end
2188
2187
 
2189
- Then 'the dodgy resource condition warning 022 should not be shown' do
2190
- expect_warning('FC022', {:line => nil, :expect_warning => false})
2188
+ Then "the dodgy resource condition warning 022 should not be shown" do
2189
+ expect_warning("FC022", { :line => nil, :expect_warning => false })
2191
2190
  end
2192
2191
 
2193
2192
  Then /^the warning (\d+) should be (valid|invalid)$/ do |code, valid|
2194
2193
  code = "FC#{code}"
2195
- valid == 'valid' ? expect_no_warning(code) : expect_warning(code)
2194
+ valid == "valid" ? expect_no_warning(code) : expect_warning(code)
2196
2195
  end
2197
2196
 
2198
2197
  Then /^the incorrect platform usage warning 028 should be (not )?shown$/ do |should_not|
2199
- expect_warning('FC028', :line => nil, :expect_warning => should_not.nil?)
2198
+ expect_warning("FC028", :line => nil, :expect_warning => should_not.nil?)
2200
2199
  end
2201
2200
 
2202
2201
  Then /^the line number and line of code that triggered the warning(s)? should be displayed$/ do |multiple|
@@ -2208,66 +2207,66 @@ Then /^the line number and line of code that triggered the warning(s)? should be
2208
2207
  end
2209
2208
  end
2210
2209
 
2211
- Then 'the missing template warning 033 should not be displayed against the template' do
2212
- expect_warning('FC033', :line => 3, :expect_warning => false)
2210
+ Then "the missing template warning 033 should not be displayed against the template" do
2211
+ expect_warning("FC033", :line => 3, :expect_warning => false)
2213
2212
  end
2214
2213
 
2215
2214
  Then /^the no leading cookbook name warning 029 should be (not )?shown$/ do |should_not|
2216
- expect_warning('FC029', :line => 1, :expect_warning => should_not.nil?, :file => 'metadata.rb')
2215
+ expect_warning("FC029", :line => 1, :expect_warning => should_not.nil?, :file => "metadata.rb")
2217
2216
  end
2218
2217
 
2219
- Then 'the node access warning 001 should be displayed for each match' do
2220
- expect_warning('FC001', :line => 1)
2221
- expect_warning('FC001', :line => 2)
2218
+ Then "the node access warning 001 should be displayed for each match" do
2219
+ expect_warning("FC001", :line => 1)
2220
+ expect_warning("FC001", :line => 2)
2222
2221
  end
2223
2222
 
2224
- Then 'the node access warning 001 should be displayed against the variables' do
2225
- expect_warning('FC001', :line => 4)
2226
- expect_warning('FC001', :line => 5)
2223
+ Then "the node access warning 001 should be displayed against the variables" do
2224
+ expect_warning("FC001", :line => 4)
2225
+ expect_warning("FC001", :line => 5)
2227
2226
  end
2228
2227
 
2229
- Then 'the node access warning 001 should be displayed twice for the same line' do
2230
- expect_warning('FC001', :line => 1, :num_occurrences => 2)
2228
+ Then "the node access warning 001 should be displayed twice for the same line" do
2229
+ expect_warning("FC001", :line => 1, :num_occurrences => 2)
2231
2230
  end
2232
2231
 
2233
- Then 'the node access warning 001 should warn on lines 2 and 10 in that order' do
2232
+ Then "the node access warning 001 should warn on lines 2 and 10 in that order" do
2234
2233
  expected_warnings = [2, 10].map do |line|
2235
2234
  "FC001: Use strings in preference to symbols to access node attributes: cookbooks/example/recipes/default.rb:#{line}"
2236
2235
  end
2237
2236
  expect_output(expected_warnings.join("\n"))
2238
2237
  end
2239
2238
 
2240
- Then 'the node access warning 001 should be displayed for the recipe' do
2241
- expect_warning('FC001')
2239
+ Then "the node access warning 001 should be displayed for the recipe" do
2240
+ expect_warning("FC001")
2242
2241
  end
2243
2242
 
2244
- Then 'the node access warning 001 should not be displayed for the attributes' do
2243
+ Then "the node access warning 001 should not be displayed for the attributes" do
2245
2244
  expect_warning("FC001", :file_type => :attributes, :line => 1, :expect_warning => false)
2246
2245
  end
2247
2246
 
2248
- Then 'the prefer chef_gem to manual install warning 025 should be shown' do
2249
- expect_warning('FC025', :line => nil)
2247
+ Then "the prefer chef_gem to manual install warning 025 should be shown" do
2248
+ expect_warning("FC025", :line => nil)
2250
2249
  end
2251
2250
 
2252
- Then 'the recipe filename should be displayed' do
2251
+ Then "the recipe filename should be displayed" do
2253
2252
  expect_output "cookbooks/example/recipes/default.rb"
2254
2253
  end
2255
2254
 
2256
2255
  Then /^the resource sets internal attribute warning 027 should be (not )?shown$/ do |should_not|
2257
- expect_warning('FC027', :line => nil, :expect_warning => should_not.nil?)
2256
+ expect_warning("FC027", :line => nil, :expect_warning => should_not.nil?)
2258
2257
  end
2259
2258
 
2260
2259
  Then /^the service resource warning 005 should( not)? be visible$/ do |dont_show|
2261
- expect_warning('FC005', :line => dont_show ? 2 : 7, :expect_warning => ! dont_show)
2260
+ expect_warning("FC005", :line => dont_show ? 2 : 7, :expect_warning => ! dont_show)
2262
2261
  end
2263
2262
 
2264
2263
  Then /^the service resource warning 005 should( not)? be displayed against the first resource in the block$/ do |dont_show|
2265
- expect_warning('FC005', :line => 2, :expect_warning => ! dont_show)
2264
+ expect_warning("FC005", :line => 2, :expect_warning => ! dont_show)
2266
2265
  end
2267
2266
 
2268
2267
  Then /^the service resource warning 005 should( not)? be shown$/ do |dont_show|
2269
- expect_warning('FC005', :line => 2, :file_type => :provider,
2270
- :expect_warning => ! dont_show)
2268
+ expect_warning("FC005", :line => 2, :file_type => :provider,
2269
+ :expect_warning => ! dont_show)
2271
2270
  end
2272
2271
 
2273
2272
  Then /^the simple usage text should be displayed along with a (non-)?zero exit code$/ do |non_zero|
@@ -2275,57 +2274,57 @@ Then /^the simple usage text should be displayed along with a (non-)?zero exit c
2275
2274
  end
2276
2275
 
2277
2276
  Then /^the template partials loop indefinitely warning 051 should (not )?be displayed against the templates$/ do |not_shown|
2278
- expect_warning('FC051', :file => 'templates/default/a.erb', :line => 1,
2279
- :expect_warning => ! not_shown)
2280
- expect_warning('FC051', :file => 'templates/default/b.erb', :line => 1,
2281
- :expect_warning => ! not_shown)
2277
+ expect_warning("FC051", :file => "templates/default/a.erb", :line => 1,
2278
+ :expect_warning => ! not_shown)
2279
+ expect_warning("FC051", :file => "templates/default/b.erb", :line => 1,
2280
+ :expect_warning => ! not_shown)
2282
2281
  end
2283
2282
 
2284
- Then 'the undeclared dependency warning 007 should be displayed only for the undeclared dependencies' do
2285
- expect_warning("FC007", :file => 'recipes/default.rb', :line => 1, :expect_warning => false)
2286
- expect_warning("FC007", :file => 'recipes/default.rb', :line => 2, :expect_warning => false)
2287
- expect_warning("FC007", :file => 'recipes/default.rb', :line => 6, :expect_warning => true)
2283
+ Then "the undeclared dependency warning 007 should be displayed only for the undeclared dependencies" do
2284
+ expect_warning("FC007", :file => "recipes/default.rb", :line => 1, :expect_warning => false)
2285
+ expect_warning("FC007", :file => "recipes/default.rb", :line => 2, :expect_warning => false)
2286
+ expect_warning("FC007", :file => "recipes/default.rb", :line => 6, :expect_warning => true)
2288
2287
  end
2289
2288
 
2290
2289
  Then /^the unused template variables warning 034 should (not )?be displayed against the (?:inferred )?template(.*)?$/ do |not_shown, ext|
2291
2290
  file = if ext.empty?
2292
- 'templates/default/config.conf.erb'
2293
- else
2294
- "templates/default/config#{ext.strip}"
2291
+ "templates/default/config.conf.erb"
2292
+ else
2293
+ "templates/default/config#{ext.strip}"
2295
2294
  end
2296
- expect_warning('FC034', :file => file, :line => 1,
2297
- :expect_warning => ! not_shown)
2295
+ expect_warning("FC034", :file => file, :line => 1,
2296
+ :expect_warning => ! not_shown)
2298
2297
  end
2299
2298
 
2300
2299
  Then /^the unrecognised attribute warning 009 should be (true|false)$/ do |shown|
2301
- shown == 'true' ? expect_warning('FC009') : expect_no_warning('FC009')
2300
+ shown == "true" ? expect_warning("FC009") : expect_no_warning("FC009")
2302
2301
  end
2303
2302
 
2304
2303
  Then /^the invalid resource action warning 038 should be (true|false)$/ do |shown|
2305
- shown == 'true' ? expect_warning('FC038') : expect_no_warning('FC038')
2304
+ shown == "true" ? expect_warning("FC038") : expect_no_warning("FC038")
2306
2305
  end
2307
2306
 
2308
- Then 'the unrecognised attribute warning 009 should be displayed against the correct resource' do
2309
- expect_warning('FC009', :line => 7)
2307
+ Then "the unrecognised attribute warning 009 should be displayed against the correct resource" do
2308
+ expect_warning("FC009", :line => 7)
2310
2309
  end
2311
2310
 
2312
- Then 'the usage text should include an option for specifying tags that will fail the build' do
2313
- expect_usage_option('f', 'epic-fail TAGS',
2311
+ Then "the usage text should include an option for specifying tags that will fail the build" do
2312
+ expect_usage_option("f", "epic-fail TAGS",
2314
2313
  "Fail the build based on tags. Use 'any' to fail on all warnings.")
2315
2314
  end
2316
2315
 
2317
2316
  Then /^the warnings shown should be (.*)$/ do |warnings|
2318
- warnings.split(',').each {|warning| expect_warning(warning, :line => nil)}
2317
+ warnings.split(",").each { |warning| expect_warning(warning, :line => nil) }
2319
2318
  end
2320
2319
 
2321
2320
  When /^I check the cookbook specifying a search grammar that (does not exist|is not in treetop format|is a valid treetop grammar)$/ do |search_grammar|
2322
2321
  case search_grammar
2323
- when 'is not in treetop format'
2324
- write_file('search.treetop', 'I am not a valid treetop grammar')
2325
- when 'is a valid treetop grammar'
2326
- write_file('search.treetop', IO.read(FoodCritic::Chef::Search.new.chef_search_grammars.first))
2322
+ when "is not in treetop format"
2323
+ write_file("search.treetop", "I am not a valid treetop grammar")
2324
+ when "is a valid treetop grammar"
2325
+ write_file("search.treetop", IO.read(FoodCritic::Chef::Search.new.chef_search_grammars.first))
2327
2326
  end
2328
- run_lint(['--search-grammar', 'search.treetop', 'cookbooks/example'])
2327
+ run_lint(["--search-grammar", "search.treetop", "cookbooks/example"])
2329
2328
  end
2330
2329
 
2331
2330
  Then /^the check should abort with an error$/ do
@@ -2346,19 +2345,19 @@ Given(/^a cookbook with an? (.*) file with an interpolated name$/) do |file_type
2346
2345
  end
2347
2346
 
2348
2347
  Then /^the metadata missing maintainer warning 055 should be (shown|not shown) against the metadata file$/ do |show_warning|
2349
- expect_warning('FC055', :file => 'metadata.rb', :expect_warning => show_warning == 'shown')
2348
+ expect_warning("FC055", :file => "metadata.rb", :expect_warning => show_warning == "shown")
2350
2349
  end
2351
2350
 
2352
2351
  Then /^the metadata missing maintainer email warning 056 should be (shown|not shown) against the metadata file$/ do |show_warning|
2353
- expect_warning('FC056', :file => 'metadata.rb', :expect_warning => show_warning == 'shown')
2352
+ expect_warning("FC056", :file => "metadata.rb", :expect_warning => show_warning == "shown")
2354
2353
  end
2355
2354
 
2356
2355
  Then /^the metadata using suggests warning 052 should be (shown|not shown) against the metadata file$/ do |show_warning|
2357
- expect_warning('FC052', :file => "metadata.rb", :line => 2, :expect_warning => show_warning == 'shown')
2356
+ expect_warning("FC052", :file => "metadata.rb", :line => 2, :expect_warning => show_warning == "shown")
2358
2357
  end
2359
2358
 
2360
2359
  Then /^the metadata using recommends warning 053 should be (shown|not shown) against the metadata file$/ do |show_warning|
2361
- expect_warning('FC053', :file => "metadata.rb", :line => 2, :expect_warning => show_warning == 'shown')
2360
+ expect_warning("FC053", :file => "metadata.rb", :line => 2, :expect_warning => show_warning == "shown")
2362
2361
  end
2363
2362
 
2364
2363
  Given /^a cookbook that contains a LWRP provider (with|without) use_inline_resources( and uses def action_create)?$/ do |with_use_inline_resources, uses_def|
@@ -2367,7 +2366,7 @@ Given /^a cookbook that contains a LWRP provider (with|without) use_inline_resou
2367
2366
  attribute :name, :kind_of => String, :name_attribute => true
2368
2367
  })
2369
2368
  provider_file = ""
2370
- if with_use_inline_resources == 'with'
2369
+ if with_use_inline_resources == "with"
2371
2370
  provider_file += %q{
2372
2371
  use_inline_resources
2373
2372
  }
@@ -2403,7 +2402,7 @@ Given /^a cookbook that contains a library provider (with|without) use_inline_re
2403
2402
  class Site < Chef::Provider::LWRPBase
2404
2403
  provides :site
2405
2404
  }
2406
- if with_use_inline_resources == 'with'
2405
+ if with_use_inline_resources == "with"
2407
2406
  library_file += %q{
2408
2407
  use_inline_resources
2409
2408
  }
@@ -2423,7 +2422,7 @@ Given /^a cookbook that contains a library provider (with|without) use_inline_re
2423
2422
  end
2424
2423
  end
2425
2424
  }
2426
- write_library('lib', library_file)
2425
+ write_library("lib", library_file)
2427
2426
  end
2428
2427
 
2429
2428
  Given /^a cookbook that contains a library resource$/ do
@@ -2437,54 +2436,54 @@ Given /^a cookbook that contains a library resource$/ do
2437
2436
  end
2438
2437
  end
2439
2438
  }
2440
- write_library('lib', library_file)
2439
+ write_library("lib", library_file)
2441
2440
  end
2442
2441
 
2443
- Given 'a cookbook with metadata that includes the version keyword and a valid version string' do
2444
- write_metadata %Q{version '1.2.3'}
2442
+ Given "a cookbook with metadata that includes the version keyword and a valid version string" do
2443
+ write_metadata %q{version '1.2.3'}
2445
2444
  end
2446
2445
 
2447
- Given 'a cookbook with metadata that includes the version keyword and a valid version string with double quotes' do
2448
- write_metadata %Q{version '1.2.3'}
2446
+ Given "a cookbook with metadata that includes the version keyword and a valid version string with double quotes" do
2447
+ write_metadata %q{version '1.2.3'}
2449
2448
  end
2450
2449
 
2451
- Given 'a cookbook with metadata that includes the version keyword and a valid x.y version string' do
2452
- write_metadata %Q{version '1.2'}
2450
+ Given "a cookbook with metadata that includes the version keyword and a valid x.y version string" do
2451
+ write_metadata %q{version '1.2'}
2453
2452
  end
2454
2453
 
2455
- Given 'a cookbook with metadata that does not include a version keyword' do
2454
+ Given "a cookbook with metadata that does not include a version keyword" do
2456
2455
  write_metadata %Q{
2457
2456
  name 'test'
2458
2457
  }
2459
2458
  end
2460
2459
 
2461
- Given 'a cookbook with metadata that includes the version keyword and an invalid version string' do
2462
- write_metadata %Q{version '1.a.3'}
2460
+ Given "a cookbook with metadata that includes the version keyword and an invalid version string" do
2461
+ write_metadata %q{version '1.a.3'}
2463
2462
  end
2464
2463
 
2465
- Given 'a cookbook with metadata that includes the version keyword and an invalid single digit version string' do
2466
- write_metadata %Q{version '1'}
2464
+ Given "a cookbook with metadata that includes the version keyword and an invalid single digit version string" do
2465
+ write_metadata %q{version '1'}
2467
2466
  end
2468
2467
 
2469
- Given 'a cookbook with metadata that includes the version keyword and an invalid 4 digit version string' do
2470
- write_metadata %Q{version '1.2.3.4'}
2468
+ Given "a cookbook with metadata that includes the version keyword and an invalid 4 digit version string" do
2469
+ write_metadata %q{version '1.2.3.4'}
2471
2470
  end
2472
2471
 
2473
- Given 'a cookbook with a metadata version that uses string interpolation' do
2472
+ Given "a cookbook with a metadata version that uses string interpolation" do
2474
2473
  write_metadata %q{
2475
2474
  patch = 3
2476
2475
  version "1.2.#{patch}"
2477
2476
  }
2478
2477
  end
2479
2478
 
2480
- Given 'a cookbook with a metadata version that is not a string literal' do
2479
+ Given "a cookbook with a metadata version that is not a string literal" do
2481
2480
  write_metadata %q{
2482
2481
  v = "1.2.3"
2483
2482
  version v
2484
2483
  }
2485
2484
  end
2486
2485
 
2487
- Given 'a cookbook with a metadata version that is a method call' do
2486
+ Given "a cookbook with a metadata version that is a method call" do
2488
2487
  write_metadata %q{
2489
2488
  version magic_version_generator('and its args')
2490
2489
  }
@@ -2499,10 +2498,10 @@ Given(/^a cookbook with metadata that (includes|does not include) a self depende
2499
2498
  end
2500
2499
 
2501
2500
  Then(/^the metadata with self dependency warning 063 should be (shown|not shown) against the metadata file$/) do |show_warning|
2502
- if show_warning == 'shown'
2503
- expect_warning('FC063', :file => "metadata.rb", :line => 3, :expect_warning => true)
2501
+ if show_warning == "shown"
2502
+ expect_warning("FC063", :file => "metadata.rb", :line => 3, :expect_warning => true)
2504
2503
  else
2505
- expect_warning('FC063', :file => "metadata.rb", :expect_warning => false)
2504
+ expect_warning("FC063", :file => "metadata.rb", :expect_warning => false)
2506
2505
  end
2507
2506
  end
2508
2507
 
@@ -2517,7 +2516,7 @@ Given(/^a cookbook with metadata that includes a issues_url expression$/) do
2517
2516
  end
2518
2517
 
2519
2518
  Then(/^the metadata missing issues_url warning 064 should be (shown|not shown) against the metadata file$/) do |show_warning|
2520
- expect_warning('FC064', :file => 'metadata.rb', :expect_warning => show_warning == 'shown')
2519
+ expect_warning("FC064", :file => "metadata.rb", :expect_warning => show_warning == "shown")
2521
2520
  end
2522
2521
 
2523
2522
  Given(/^a cookbook with metadata that (includes|does not include) a source_url keyword$/) do |includes|
@@ -2527,7 +2526,7 @@ Given(/^a cookbook with metadata that (includes|does not include) a source_url k
2527
2526
  end
2528
2527
 
2529
2528
  Then(/^the metadata missing source_url warning 065 should be (shown|not shown) against the metadata file$/) do |show_warning|
2530
- expect_warning('FC065', :file => 'metadata.rb', :expect_warning => show_warning == 'shown')
2529
+ expect_warning("FC065", :file => "metadata.rb", :expect_warning => show_warning == "shown")
2531
2530
  end
2532
2531
 
2533
2532
  Given(/^a cookbook with metadata that includes a source_url expression$/) do