chefspec 9.1.0 → 9.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -9
  3. data/Rakefile +60 -52
  4. data/chefspec.gemspec +20 -20
  5. data/lib/chefspec/api/core.rb +3 -3
  6. data/lib/chefspec/api/described.rb +3 -5
  7. data/lib/chefspec/api/stubs.rb +2 -2
  8. data/lib/chefspec/api/stubs_for.rb +22 -19
  9. data/lib/chefspec/api.rb +14 -14
  10. data/lib/chefspec/berkshelf.rb +4 -4
  11. data/lib/chefspec/cacher.rb +2 -2
  12. data/lib/chefspec/coverage/filters.rb +18 -15
  13. data/lib/chefspec/coverage.rb +35 -40
  14. data/lib/chefspec/deprecations.rb +3 -3
  15. data/lib/chefspec/errors.rb +7 -7
  16. data/lib/chefspec/expect_exception.rb +2 -1
  17. data/lib/chefspec/extensions/chef/client.rb +3 -3
  18. data/lib/chefspec/extensions/chef/conditional.rb +2 -1
  19. data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +5 -4
  20. data/lib/chefspec/extensions/chef/cookbook_loader.rb +1 -0
  21. data/lib/chefspec/extensions/chef/cookbook_uploader.rb +1 -1
  22. data/lib/chefspec/extensions/chef/data_query.rb +3 -3
  23. data/lib/chefspec/extensions/chef/lwrp_base.rb +1 -0
  24. data/lib/chefspec/extensions/chef/provider.rb +8 -5
  25. data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +2 -1
  26. data/lib/chefspec/extensions/chef/resource.rb +18 -12
  27. data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +21 -1
  28. data/lib/chefspec/extensions/chef/securable.rb +1 -1
  29. data/lib/chefspec/extensions/ohai/system.rb +11 -0
  30. data/lib/chefspec/extensions.rb +14 -13
  31. data/lib/chefspec/file_cache_path_proxy.rb +3 -3
  32. data/lib/chefspec/formatter.rb +15 -3
  33. data/lib/chefspec/librarian.rb +7 -6
  34. data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
  35. data/lib/chefspec/matchers/include_any_recipe_matcher.rb +4 -4
  36. data/lib/chefspec/matchers/include_recipe_matcher.rb +1 -1
  37. data/lib/chefspec/matchers/link_to_matcher.rb +2 -2
  38. data/lib/chefspec/matchers/notifications_matcher.rb +5 -4
  39. data/lib/chefspec/matchers/render_file_matcher.rb +3 -3
  40. data/lib/chefspec/matchers/resource_matcher.rb +18 -16
  41. data/lib/chefspec/matchers.rb +9 -9
  42. data/lib/chefspec/mixins/normalize.rb +1 -1
  43. data/lib/chefspec/policyfile.rb +6 -6
  44. data/lib/chefspec/renderer.rb +4 -4
  45. data/lib/chefspec/rspec.rb +1 -1
  46. data/lib/chefspec/server.rb +1 -1
  47. data/lib/chefspec/server_methods.rb +8 -8
  48. data/lib/chefspec/server_runner.rb +10 -10
  49. data/lib/chefspec/solo_runner.rb +27 -25
  50. data/lib/chefspec/stubs/command_registry.rb +1 -1
  51. data/lib/chefspec/stubs/command_stub.rb +1 -1
  52. data/lib/chefspec/stubs/data_bag_item_registry.rb +1 -1
  53. data/lib/chefspec/stubs/data_bag_item_stub.rb +1 -1
  54. data/lib/chefspec/stubs/data_bag_registry.rb +1 -1
  55. data/lib/chefspec/stubs/data_bag_stub.rb +1 -1
  56. data/lib/chefspec/stubs/registry.rb +1 -1
  57. data/lib/chefspec/stubs/search_registry.rb +2 -2
  58. data/lib/chefspec/stubs/search_stub.rb +2 -2
  59. data/lib/chefspec/util.rb +7 -7
  60. data/lib/chefspec/version.rb +1 -1
  61. data/lib/chefspec/zero_server.rb +4 -4
  62. data/lib/chefspec.rb +29 -29
  63. data/spec/spec_helper.rb +3 -4
  64. data/spec/support/hash.rb +3 -3
  65. data/spec/unit/cacher_spec.rb +17 -17
  66. data/spec/unit/coverage/filters_spec.rb +16 -16
  67. data/spec/unit/deprecations_spec.rb +8 -9
  68. data/spec/unit/errors_spec.rb +15 -15
  69. data/spec/unit/expect_exception_spec.rb +9 -9
  70. data/spec/unit/macros_spec.rb +50 -50
  71. data/spec/unit/matchers/do_nothing_matcher.rb +1 -1
  72. data/spec/unit/matchers/include_any_recipe_matcher_spec.rb +23 -23
  73. data/spec/unit/matchers/include_recipe_matcher_spec.rb +15 -15
  74. data/spec/unit/matchers/link_to_matcher_spec.rb +18 -18
  75. data/spec/unit/matchers/notifications_matcher_spec.rb +15 -16
  76. data/spec/unit/matchers/render_file_matcher_spec.rb +26 -26
  77. data/spec/unit/matchers/resource_matcher_spec.rb +1 -1
  78. data/spec/unit/matchers/state_attrs_matcher_spec.rb +24 -24
  79. data/spec/unit/matchers/subscribes_matcher_spec.rb +27 -29
  80. data/spec/unit/renderer_spec.rb +36 -36
  81. data/spec/unit/server_runner_spec.rb +6 -6
  82. data/spec/unit/solo_runner_spec.rb +69 -69
  83. data/spec/unit/stubs/command_registry_spec.rb +11 -11
  84. data/spec/unit/stubs/command_stub_spec.rb +26 -26
  85. data/spec/unit/stubs/data_bag_item_registry_spec.rb +17 -17
  86. data/spec/unit/stubs/data_bag_item_stub_spec.rb +14 -14
  87. data/spec/unit/stubs/data_bag_registry_spec.rb +16 -16
  88. data/spec/unit/stubs/data_bag_stub_spec.rb +13 -13
  89. data/spec/unit/stubs/registry_spec.rb +9 -9
  90. data/spec/unit/stubs/search_registry_spec.rb +17 -17
  91. data/spec/unit/stubs/search_stub_spec.rb +14 -14
  92. data/spec/unit/stubs/stub_spec.rb +22 -22
  93. metadata +10 -11
  94. data/lib/chefspec/extensions/.DS_Store +0 -0
  95. data/lib/chefspec/extensions/chef/.DS_Store +0 -0
@@ -1,4 +1,4 @@
1
- require 'chef_zero/server'
1
+ require "chef_zero/server"
2
2
 
3
3
  module ChefSpec
4
4
  # Rather than create a ChefZero instance per test case, simply create one
@@ -56,7 +56,7 @@ module ChefSpec
56
56
  port: RSpec.configuration.server_runner_port,
57
57
 
58
58
  # Set the data store
59
- data_store: data_store(RSpec.configuration.server_runner_data_store),
59
+ data_store: data_store(RSpec.configuration.server_runner_data_store)
60
60
  )
61
61
  @cookbooks_uploaded = false
62
62
  @data_loaded = {}
@@ -74,6 +74,7 @@ module ChefSpec
74
74
  #
75
75
  def upload_cookbooks!
76
76
  return if @cookbooks_uploaded
77
+
77
78
  loader = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
78
79
  loader.load_cookbooks
79
80
  cookbook_uploader_for(loader).upload_cookbooks
@@ -122,9 +123,8 @@ module ChefSpec
122
123
  require "chef_zero/data_store/memory_store_v2"
123
124
  ChefZero::DataStore::MemoryStoreV2.new
124
125
  when :on_disk
125
- require "tmpdir"
126
+ require "tmpdir" unless defined?(Dir.mktmpdir)
126
127
  require "chef_zero/data_store/raw_file_store"
127
- tmpdir = Dir.mktmpdir
128
128
  ChefZero::DataStore::RawFileStore.new(Dir.mktmpdir)
129
129
  else
130
130
  raise ArgumentError, ":#{option} is not a valid server_runner_data_store option. Please use either :in_memory or :on_disk."
data/lib/chefspec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rspec'
1
+ require "rspec"
2
2
 
3
3
  module ChefSpec
4
4
  #
@@ -25,7 +25,7 @@ module ChefSpec
25
25
  # @return [Pathname]
26
26
  #
27
27
  def root
28
- @root ||= Pathname.new(File.expand_path('../../', __FILE__))
28
+ @root ||= Pathname.new(File.expand_path("..", __dir__))
29
29
  end
30
30
  module_function :root
31
31
 
@@ -42,34 +42,34 @@ module ChefSpec
42
42
  module_function :matchers
43
43
  end
44
44
 
45
- require_relative 'chefspec/extensions'
45
+ require_relative "chefspec/extensions"
46
46
 
47
- require_relative 'chefspec/mixins/normalize'
47
+ require_relative "chefspec/mixins/normalize"
48
48
 
49
- require_relative 'chefspec/stubs/command_registry'
50
- require_relative 'chefspec/stubs/command_stub'
51
- require_relative 'chefspec/stubs/data_bag_item_registry'
52
- require_relative 'chefspec/stubs/data_bag_item_stub'
53
- require_relative 'chefspec/stubs/data_bag_registry'
54
- require_relative 'chefspec/stubs/data_bag_stub'
55
- require_relative 'chefspec/stubs/registry'
56
- require_relative 'chefspec/stubs/stub'
57
- require_relative 'chefspec/stubs/search_registry'
58
- require_relative 'chefspec/stubs/search_stub'
49
+ require_relative "chefspec/stubs/command_registry"
50
+ require_relative "chefspec/stubs/command_stub"
51
+ require_relative "chefspec/stubs/data_bag_item_registry"
52
+ require_relative "chefspec/stubs/data_bag_item_stub"
53
+ require_relative "chefspec/stubs/data_bag_registry"
54
+ require_relative "chefspec/stubs/data_bag_stub"
55
+ require_relative "chefspec/stubs/registry"
56
+ require_relative "chefspec/stubs/stub"
57
+ require_relative "chefspec/stubs/search_registry"
58
+ require_relative "chefspec/stubs/search_stub"
59
59
 
60
- require_relative 'chefspec/api'
61
- require_relative 'chefspec/cacher'
62
- require_relative 'chefspec/coverage'
63
- require_relative 'chefspec/errors'
64
- require_relative 'chefspec/expect_exception'
65
- require_relative 'chefspec/formatter'
66
- require_relative 'chefspec/matchers'
67
- require_relative 'chefspec/renderer'
68
- require_relative 'chefspec/rspec'
69
- require_relative 'chefspec/server_runner'
70
- require_relative 'chefspec/solo_runner'
71
- require_relative 'chefspec/runner'
72
- require_relative 'chefspec/util'
73
- require_relative 'chefspec/version'
60
+ require_relative "chefspec/api"
61
+ require_relative "chefspec/cacher"
62
+ require_relative "chefspec/coverage"
63
+ require_relative "chefspec/errors"
64
+ require_relative "chefspec/expect_exception"
65
+ require_relative "chefspec/formatter"
66
+ require_relative "chefspec/matchers"
67
+ require_relative "chefspec/renderer"
68
+ require_relative "chefspec/rspec"
69
+ require_relative "chefspec/server_runner"
70
+ require_relative "chefspec/solo_runner"
71
+ require_relative "chefspec/runner"
72
+ require_relative "chefspec/util"
73
+ require_relative "chefspec/version"
74
74
 
75
- require_relative 'chefspec/deprecations'
75
+ require_relative "chefspec/deprecations"
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,8 @@
1
- require 'chefspec'
2
- require 'support/hash'
3
-
1
+ require "chefspec"
2
+ require "support/hash"
4
3
 
5
4
  ChefSpec::Coverage.start! do
6
- set_template 'table.erb'
5
+ set_template "table.erb"
7
6
  end
8
7
 
9
8
  RSpec.configure do |config|
data/spec/support/hash.rb CHANGED
@@ -11,9 +11,9 @@ class Hash
11
11
  # Monkey-patch to allow mash-style look ups for tests
12
12
  #
13
13
  def method_missing(m, *args, &block)
14
- if has_key?(m.to_sym)
14
+ if key?(m.to_sym)
15
15
  self[m.to_sym]
16
- elsif has_key?(m.to_s)
16
+ elsif key?(m.to_s)
17
17
  self[m.to_s]
18
18
  else
19
19
  super
@@ -26,7 +26,7 @@ class Hash
26
26
  # @see Hash#respond_to?
27
27
  #
28
28
  def respond_to?(m, include_private = false)
29
- if has_key?(m.to_sym) || has_key?(m.to_s)
29
+ if key?(m.to_sym) || key?(m.to_s)
30
30
  true
31
31
  else
32
32
  super
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- require 'chefspec/cacher'
1
+ require "spec_helper"
2
+ require "chefspec/cacher"
3
3
 
4
4
  describe ChefSpec::Cacher do
5
5
  let(:klass) do
@@ -7,7 +7,7 @@ describe ChefSpec::Cacher do
7
7
  extend ChefSpec::Cacher
8
8
 
9
9
  def self.metadata
10
- { parent_example_group: { location: 'spec' } }
10
+ { parent_example_group: { location: "spec" } }
11
11
  end
12
12
  end
13
13
  end
@@ -17,23 +17,23 @@ describe ChefSpec::Cacher do
17
17
 
18
18
  before(:each) { described_class.class_variable_set(:@@cache, {}) unless preserve_cache }
19
19
 
20
- describe 'cached' do
21
- it 'lazily defines the results for the cache' do
20
+ describe "cached" do
21
+ it "lazily defines the results for the cache" do
22
22
  klass.cached(:chef_run)
23
23
  expect(klass).to be_method_defined(:chef_run)
24
24
  end
25
25
 
26
- it 'adds the item to the cache when called' do
26
+ it "adds the item to the cache when called" do
27
27
  runner = double(:runner)
28
28
  klass.cached(:chef_run) { runner }
29
29
  klass.new.chef_run
30
30
 
31
- expect(cache[Thread.current.object_id]).to have_key('spec.chef_run')
32
- expect(cache[Thread.current.object_id]['spec.chef_run']).to eq(runner)
31
+ expect(cache[Thread.current.object_id]).to have_key("spec.chef_run")
32
+ expect(cache[Thread.current.object_id]["spec.chef_run"]).to eq(runner)
33
33
  end
34
34
 
35
- context 'when multithreaded environment' do
36
- it 'is thread safe' do
35
+ context "when multithreaded environment" do
36
+ it "is thread safe" do
37
37
  (1..2).each do |n|
38
38
  Thread.new do
39
39
  klass.cached(:chef_run) { n }
@@ -43,14 +43,14 @@ describe ChefSpec::Cacher do
43
43
  end
44
44
  end
45
45
 
46
- context 'when example groups are defined by looping' do
46
+ context "when example groups are defined by looping" do
47
47
  let(:preserve_cache) { true }
48
48
 
49
- ['first', 'second', 'third'].each do |iteration|
49
+ %w{first second third}.each do |iteration|
50
50
  context "on the #{iteration} iteration" do
51
- context 'in caching context' do
51
+ context "in caching context" do
52
52
  cached(:cached_iteration) { iteration }
53
- it 'caches the iteration for this context' do
53
+ it "caches the iteration for this context" do
54
54
  expect(cached_iteration).to eq iteration
55
55
  end
56
56
  end
@@ -59,12 +59,12 @@ describe ChefSpec::Cacher do
59
59
  end
60
60
  end
61
61
 
62
- describe 'cached!' do
63
- it 'loads the value at runtime' do
62
+ describe "cached!" do
63
+ it "loads the value at runtime" do
64
64
  expect(klass).to receive(:cached).with(:chef_run).once
65
65
  expect(klass).to receive(:before).once
66
66
 
67
- klass.cached!(:chef_run) { }
67
+ klass.cached!(:chef_run) {}
68
68
  end
69
69
  end
70
70
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  # Note: These specs don't use Berkshelf code directly as this project doesn't
4
4
  # have a direct dependency on Berkshelf and loading it would impact the
@@ -6,51 +6,51 @@ require 'spec_helper'
6
6
  # a standin for Berkshelf to exercise the `#matches?` behavior.
7
7
  describe ChefSpec::Coverage::BerkshelfFilter do
8
8
  let(:dependencies) do
9
- [double('Berkshelf::Dependency', metadata?: true, name: "cookbookery")]
9
+ [double("Berkshelf::Dependency", metadata?: true, name: "cookbookery")]
10
10
  end
11
- let(:berksfile) { double('Berkshelf::Berksfile', dependencies: dependencies) }
12
- let(:resource) { Chef::Resource.new('theone') }
11
+ let(:berksfile) { double("Berkshelf::Berksfile", dependencies: dependencies) }
12
+ let(:resource) { Chef::Resource.new("theone") }
13
13
  subject { described_class.new(berksfile) }
14
14
 
15
- describe '#matches?' do
16
- it 'returns truthy if resource source_line is nil' do
15
+ describe "#matches?" do
16
+ it "returns truthy if resource source_line is nil" do
17
17
  expect(subject.matches?(resource)).to be_truthy
18
18
  end
19
19
 
20
- context 'when resource#source_line is under target cookbook' do
21
- it 'normal unix path returns truthy' do
20
+ context "when resource#source_line is under target cookbook" do
21
+ it "normal unix path returns truthy" do
22
22
  resource.source_line =
23
- '/path/to/cookbooks/nope/recipes/default.rb:22'
23
+ "/path/to/cookbooks/nope/recipes/default.rb:22"
24
24
  expect(subject.matches?(resource)).to be_truthy
25
25
  end
26
26
 
27
- it 'normal windows path returns truthy' do
27
+ it "normal windows path returns truthy" do
28
28
  resource.source_line =
29
29
  'C:\\path\\to\\cookbooks\\nope\\recipes\\default.rb:22'
30
30
  expect(subject.matches?(resource)).to be_truthy
31
31
  end
32
32
 
33
- it 'mixed windows path returns truthy' do
33
+ it "mixed windows path returns truthy" do
34
34
  resource.source_line =
35
35
  'C:\\path\\to\\cookbooks/nope/recipes/default.rb:22'
36
36
  expect(subject.matches?(resource)).to be_truthy
37
37
  end
38
38
  end
39
39
 
40
- context 'when resource#source_line is not under target cookbook' do
41
- it 'normal unix path returns falsey' do
40
+ context "when resource#source_line is not under target cookbook" do
41
+ it "normal unix path returns falsey" do
42
42
  resource.source_line =
43
- '/path/to/cookbooks/cookbookery/recipes/default.rb:22'
43
+ "/path/to/cookbooks/cookbookery/recipes/default.rb:22"
44
44
  expect(subject.matches?(resource)).to be_falsey
45
45
  end
46
46
 
47
- it 'normal windows path returns falsey' do
47
+ it "normal windows path returns falsey" do
48
48
  resource.source_line =
49
49
  'C:\\path\\to\\cookbooks\\cookbookery\\recipes\\default.rb:22'
50
50
  expect(subject.matches?(resource)).to be_falsey
51
51
  end
52
52
 
53
- it 'mixed windows path returns falsey' do
53
+ it "mixed windows path returns falsey" do
54
54
  resource.source_line =
55
55
  'C:\\path\\to\\cookbooks/cookbookery/recipes/default.rb:22'
56
56
  expect(subject.matches?(resource)).to be_falsey
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe ChefSpec::Runner do
4
4
  before do
@@ -8,12 +8,12 @@ describe ChefSpec::Runner do
8
8
  allow(ChefSpec::Runner).to receive(:deprecated)
9
9
  end
10
10
 
11
- describe '#define_runner_method' do
11
+ describe "#define_runner_method" do
12
12
  before do
13
13
  allow(ChefSpec).to receive(:define_matcher)
14
14
  end
15
15
 
16
- it 'prints a deprecation' do
16
+ it "prints a deprecation" do
17
17
  expect(ChefSpec::Runner).to receive(:deprecated)
18
18
  .with("`ChefSpec::Runner.define_runner_method' is deprecated."\
19
19
  " It is being used in the my_custom_resource resource matcher." \
@@ -21,7 +21,7 @@ describe ChefSpec::Runner do
21
21
  ChefSpec::Runner.define_runner_method(:my_custom_resource)
22
22
  end
23
23
 
24
- it 'calls ChefSpec#define_matcher' do
24
+ it "calls ChefSpec#define_matcher" do
25
25
  expect(ChefSpec).to receive(:define_matcher).with(:my_custom_resource).once
26
26
  ChefSpec::Runner.define_runner_method(:my_custom_resource)
27
27
  end
@@ -34,19 +34,18 @@ describe ChefSpec::Server do
34
34
  allow(ChefSpec::Server).to receive(:deprecated)
35
35
  end
36
36
 
37
- it 'prints a deprecation for any method called' do
37
+ it "prints a deprecation for any method called" do
38
38
  expect(ChefSpec::Server).to receive(:deprecated)
39
39
  .with("`ChefSpec::Server.any_method' is deprecated. There is no longer" \
40
40
  " a global Chef Server instance. Please use a ChefSpec::SoloRunner" \
41
- " instead. More documentation can be found in the ChefSpec README."
42
- )
41
+ " instead. More documentation can be found in the ChefSpec README.")
43
42
  expect {
44
43
  ChefSpec::Server.any_method
45
44
  }.to raise_error(ChefSpec::Error::NoConversionError)
46
45
  end
47
46
 
48
- it 'raises non-conversion error for any method called' do
49
- expect{ChefSpec::Server.any_method}
47
+ it "raises non-conversion error for any method called" do
48
+ expect { ChefSpec::Server.any_method }
50
49
  .to raise_error(ChefSpec::Error::NoConversionError)
51
50
  end
52
51
 
@@ -1,14 +1,14 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module ChefSpec::Error
4
4
  describe CommandNotStubbed do
5
- let(:instance) { described_class.new(args: ['cat']) }
5
+ let(:instance) { described_class.new(args: ["cat"]) }
6
6
 
7
- it 'raises an exception with the correct message' do
7
+ it "raises an exception with the correct message" do
8
8
  instance
9
- expect { raise instance }.to raise_error { |error|
9
+ expect { raise instance }.to( raise_error { |error|
10
10
  expect(error).to be_a(described_class)
11
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
11
+ expect(error.message).to eq <<-EOH.gsub(/^ {10}/, "")
12
12
  Executing a real command is disabled. Unregistered command:
13
13
 
14
14
  command("cat")
@@ -17,32 +17,32 @@ module ChefSpec::Error
17
17
 
18
18
  stub_command("cat").and_return(...)
19
19
  EOH
20
- }
20
+ })
21
21
  end
22
22
  end
23
23
 
24
24
  describe CookbookPathNotFound do
25
25
  let(:instance) { described_class.new }
26
26
 
27
- it 'raises an exception with the correct message' do
28
- expect { raise instance }.to raise_error { |error|
27
+ it "raises an exception with the correct message" do
28
+ expect { raise instance }.to(raise_error { |error|
29
29
  expect(error).to be_a(described_class)
30
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
30
+ expect(error.message).to eq <<-EOH.gsub(/^ {10}/, "")
31
31
  I could not find or infer a cookbook_path from your current working directory.
32
32
  Please make sure you put your specs (tests) under a directory named 'spec' or
33
33
  manually set the cookbook path in the RSpec configuration.
34
34
  EOH
35
- }
35
+ })
36
36
  end
37
37
  end
38
38
 
39
39
  describe GemLoadError do
40
- let(:instance) { described_class.new(gem: 'bacon', name: 'bacon') }
40
+ let(:instance) { described_class.new(gem: "bacon", name: "bacon") }
41
41
 
42
- it 'raises an exception with the correct message' do
43
- expect { raise instance }.to raise_error { |error|
42
+ it "raises an exception with the correct message" do
43
+ expect { raise instance }.to( raise_error { |error|
44
44
  expect(error).to be_a(described_class)
45
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
45
+ expect(error.message).to eq <<-EOH.gsub(/^ {10}/, "")
46
46
  I could not load the 'bacon' gem! You must have the gem installed
47
47
  on your local system before you can use the bacon plugin.
48
48
  You can install bacon by running:
@@ -51,7 +51,7 @@ module ChefSpec::Error
51
51
 
52
52
  or add bacon to your Gemfile and run the `bundle` command to install.
53
53
  EOH
54
- }
54
+ })
55
55
  end
56
56
  end
57
57
  end
@@ -1,30 +1,30 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe ChefSpec::ExpectException do
4
- context 'when there have been no `raise_error` matchers' do
4
+ context "when there have been no `raise_error` matchers" do
5
5
  subject { described_class.new(Exception) }
6
6
 
7
- it 'does not match' do
7
+ it "does not match" do
8
8
  allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(nil)
9
9
  expect(subject.expected?).to be_falsy
10
10
  end
11
11
  end
12
12
 
13
- context 'when the last error does not match the expected type' do
13
+ context "when the last error does not match the expected type" do
14
14
  subject { described_class.new(RuntimeError) }
15
15
 
16
- it 'does not match' do
17
- last_error = double('last error', last_error_for_chefspec: ArgumentError)
16
+ it "does not match" do
17
+ last_error = double("last error", last_error_for_chefspec: ArgumentError)
18
18
  allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(last_error)
19
19
  expect(subject.expected?).to be_falsy
20
20
  end
21
21
  end
22
22
 
23
- context 'when the last error matches the expected type' do
23
+ context "when the last error matches the expected type" do
24
24
  subject { described_class.new(RuntimeError) }
25
25
 
26
- it 'does not match' do
27
- last_error = double('last error', last_error_for_chefspec: RuntimeError)
26
+ it "does not match" do
27
+ last_error = double("last error", last_error_for_chefspec: RuntimeError)
28
28
  allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(last_error)
29
29
  expect(subject.expected?).to be_truthy
30
30
  end