chefspec 3.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -19
  3. data/CHANGELOG.md +32 -1
  4. data/CONTRIBUTING.md +1 -1
  5. data/README.md +37 -9
  6. data/chefspec.gemspec +2 -3
  7. data/examples/render_file/spec/default_spec.rb +32 -17
  8. data/examples/server/recipes/render_with_cached.rb +3 -0
  9. data/examples/server/spec/client_spec.rb +1 -1
  10. data/examples/server/spec/data_bag_spec.rb +1 -1
  11. data/examples/server/spec/environment_spec.rb +1 -1
  12. data/examples/server/spec/node_spec.rb +1 -1
  13. data/examples/server/spec/render_with_cached_spec.rb +16 -0
  14. data/examples/server/spec/role_spec.rb +1 -1
  15. data/features/server.feature +10 -12
  16. data/features/support/executor.rb +2 -0
  17. data/gemfiles/{chef-11.0.0.gemfile → chef-11.12.0.gemfile} +1 -1
  18. data/gemfiles/chef-master.gemfile +1 -1
  19. data/lib/chefspec.rb +1 -0
  20. data/lib/chefspec/api/erl_call.rb +5 -5
  21. data/lib/chefspec/api/execute.rb +5 -5
  22. data/lib/chefspec/api/powershell_script.rb +5 -5
  23. data/lib/chefspec/api/ruby_block.rb +2 -2
  24. data/lib/chefspec/api/script.rb +13 -2
  25. data/lib/chefspec/cacher.rb +2 -1
  26. data/lib/chefspec/coverage.rb +10 -2
  27. data/lib/chefspec/expect_exception.rb +0 -2
  28. data/lib/chefspec/extensions/chef/lwrp_base.rb +5 -1
  29. data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +19 -0
  30. data/lib/chefspec/librarian.rb +5 -2
  31. data/lib/chefspec/macros.rb +3 -3
  32. data/lib/chefspec/matchers/do_nothing_matcher.rb +4 -2
  33. data/lib/chefspec/matchers/include_recipe_matcher.rb +2 -2
  34. data/lib/chefspec/matchers/link_to_matcher.rb +11 -5
  35. data/lib/chefspec/matchers/notifications_matcher.rb +2 -2
  36. data/lib/chefspec/matchers/render_file_matcher.rb +9 -3
  37. data/lib/chefspec/matchers/resource_matcher.rb +2 -2
  38. data/lib/chefspec/matchers/state_attrs_matcher.rb +2 -2
  39. data/lib/chefspec/matchers/subscribes_matcher.rb +4 -4
  40. data/lib/chefspec/renderer.rb +1 -1
  41. data/lib/chefspec/rspec.rb +1 -0
  42. data/lib/chefspec/runner.rb +2 -1
  43. data/lib/chefspec/server.rb +90 -19
  44. data/lib/chefspec/version.rb +1 -1
  45. data/spec/unit/cacher_spec.rb +1 -1
  46. data/spec/unit/expect_exception_spec.rb +6 -6
  47. data/spec/unit/extensions/lwrp_base_spec.rb +9 -1
  48. data/spec/unit/macros_spec.rb +6 -6
  49. data/spec/unit/matchers/include_recipe_matcher_spec.rb +6 -6
  50. data/spec/unit/matchers/link_to_matcher_spec.rb +31 -15
  51. data/spec/unit/matchers/notifications_matcher_spec.rb +4 -4
  52. data/spec/unit/matchers/render_file_matcher_spec.rb +19 -10
  53. data/spec/unit/matchers/state_attrs_matcher_spec.rb +28 -24
  54. data/spec/unit/matchers/subscribes_matcher_spec.rb +7 -7
  55. data/spec/unit/renderer_spec.rb +7 -7
  56. data/spec/unit/runner_spec.rb +39 -9
  57. metadata +10 -25
  58. data/gemfiles/chef-11.2.0.gemfile +0 -5
  59. data/gemfiles/chef-11.4.4.gemfile +0 -5
  60. data/gemfiles/chef-11.6.0.gemfile +0 -5
  61. data/gemfiles/chef-11.8.0.gemfile +0 -5
@@ -1,3 +1,3 @@
1
1
  module ChefSpec
2
- VERSION = '3.4.0'
2
+ VERSION = '4.0.0'
3
3
  end
@@ -7,7 +7,7 @@ describe ChefSpec::Cacher do
7
7
  extend ChefSpec::Cacher
8
8
 
9
9
  def self.metadata
10
- { example_group: { location: 'spec' } }
10
+ { parent_example_group: { location: 'spec' } }
11
11
  end
12
12
  end
13
13
  end
@@ -5,8 +5,8 @@ describe ChefSpec::ExpectException do
5
5
  subject { described_class.new(Exception) }
6
6
 
7
7
  it 'does not match' do
8
- RSpec::Matchers::BuiltIn::RaiseError.stub(:last_run).and_return(nil)
9
- expect(subject.expected?).to be_false
8
+ allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(nil)
9
+ expect(subject.expected?).to be_falsy
10
10
  end
11
11
  end
12
12
 
@@ -15,8 +15,8 @@ describe ChefSpec::ExpectException do
15
15
 
16
16
  it 'does not match' do
17
17
  last_error = double('last error', last_error_for_chefspec: ArgumentError)
18
- RSpec::Matchers::BuiltIn::RaiseError.stub(:last_run).and_return(last_error)
19
- expect(subject.expected?).to be_false
18
+ allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(last_error)
19
+ expect(subject.expected?).to be_falsy
20
20
  end
21
21
  end
22
22
 
@@ -25,8 +25,8 @@ describe ChefSpec::ExpectException do
25
25
 
26
26
  it 'does not match' do
27
27
  last_error = double('last error', last_error_for_chefspec: RuntimeError)
28
- RSpec::Matchers::BuiltIn::RaiseError.stub(:last_run).and_return(last_error)
29
- expect(subject.expected?).to be_true
28
+ allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(last_error)
29
+ expect(subject.expected?).to be_truthy
30
30
  end
31
31
  end
32
32
  end
@@ -9,7 +9,7 @@ if Chef::VERSION >= '11.0.0'
9
9
  describe '#remove_existing_lwrp' do
10
10
  before do
11
11
  Chef::Provider::MysqlDatabase = nil
12
- Chef::Resource::MysqlDatabase = nil
12
+ Chef::Resource::MysqlDatabase = Class.new(Chef::Resource)
13
13
  end
14
14
 
15
15
  after do
@@ -40,6 +40,8 @@ if Chef::VERSION >= '11.0.0'
40
40
  end
41
41
 
42
42
  context Chef::Resource do
43
+ let!(:resource_class) { Chef::Resource::MysqlDatabase }
44
+
43
45
  before do
44
46
  Chef::Resource::LWRPBase.remove_existing_lwrp('MysqlDatabase')
45
47
  end
@@ -48,6 +50,12 @@ if Chef::VERSION >= '11.0.0'
48
50
  expect(Chef::Resource.constants).to_not include(:MysqlDatabase)
49
51
  end
50
52
 
53
+ if Chef::Resource.respond_to?(:resource_classes)
54
+ it 'removes the resource from Chef::Resource.resource_classes' do
55
+ expect(Chef::Resource.resource_classes).to_not include(resource_class)
56
+ end
57
+ end
58
+
51
59
  it 'does not remove the provider' do
52
60
  Chef::Resource::LWRPBase.remove_existing_lwrp('MysqlDatabase')
53
61
  expect(Chef::Provider.constants).to include(:MysqlDatabase)
@@ -5,7 +5,7 @@ describe ChefSpec::Macros do
5
5
  let(:command_stub) { double('command') }
6
6
 
7
7
  it 'adds the command to the command registry' do
8
- ChefSpec::Stubs::CommandStub.stub(:new).and_return(command_stub)
8
+ allow(ChefSpec::Stubs::CommandStub).to receive(:new).and_return(command_stub)
9
9
  described_class.stub_command('echo "hello"')
10
10
 
11
11
  expect(ChefSpec::Stubs::CommandRegistry.stubs).to include(command_stub)
@@ -16,7 +16,7 @@ describe ChefSpec::Macros do
16
16
  let(:search_stub) { double('search') }
17
17
 
18
18
  it 'adds the query to the search registry' do
19
- ChefSpec::Stubs::SearchStub.stub(:new).and_return(search_stub)
19
+ allow(ChefSpec::Stubs::SearchStub).to receive(:new).and_return(search_stub)
20
20
  described_class.stub_search(:node, '*:*')
21
21
 
22
22
  expect(ChefSpec::Stubs::SearchRegistry.stubs).to include(search_stub)
@@ -27,7 +27,7 @@ describe ChefSpec::Macros do
27
27
  let(:data_bag_stub) { double('data_bag') }
28
28
 
29
29
  it 'adds the query to the data_bag registry' do
30
- ChefSpec::Stubs::DataBagStub.stub(:new).and_return(data_bag_stub)
30
+ allow(ChefSpec::Stubs::DataBagStub).to receive(:new).and_return(data_bag_stub)
31
31
  described_class.stub_data_bag(:users)
32
32
 
33
33
  expect(ChefSpec::Stubs::DataBagRegistry.stubs).to include(data_bag_stub)
@@ -38,7 +38,7 @@ describe ChefSpec::Macros do
38
38
  let(:data_bag_item_stub) { double('data_bag_item') }
39
39
 
40
40
  it 'adds the query to the data_bag_item registry' do
41
- ChefSpec::Stubs::DataBagItemStub.stub(:new).and_return(data_bag_item_stub)
41
+ allow(ChefSpec::Stubs::DataBagItemStub).to receive(:new).and_return(data_bag_item_stub)
42
42
  described_class.stub_data_bag_item(:users, 'id')
43
43
 
44
44
  expect(ChefSpec::Stubs::DataBagItemRegistry.stubs).to include(data_bag_item_stub)
@@ -76,8 +76,8 @@ describe ChefSpec::Macros do
76
76
  end
77
77
 
78
78
  it 'sets the automatic attributes from a JSON data path' do
79
- File.stub(:exists?).with('/path/to/json').and_return(true)
80
- File.stub(:read).with('/path/to/json').and_return('{ "ipaddress": "1.2.3.4" }')
79
+ allow(File).to receive(:exists?).with('/path/to/json').and_return(true)
80
+ allow(File).to receive(:read).with('/path/to/json').and_return('{ "ipaddress": "1.2.3.4" }')
81
81
  node = described_class.stub_node('node.example', path: '/path/to/json')
82
82
  expect(node['ipaddress']).to eq('1.2.3.4')
83
83
  end
@@ -4,18 +4,18 @@ describe ChefSpec::Matchers::IncludeRecipeMatcher do
4
4
  let(:chef_run) { double('chef run', run_context: { loaded_recipes: %w(one two three) }) }
5
5
  subject { described_class.new('one::default') }
6
6
 
7
- describe '#failure_message_for_should' do
7
+ describe '#failure_message' do
8
8
  it 'has the right value' do
9
9
  subject.matches?(chef_run)
10
- expect(subject.failure_message_for_should)
10
+ expect(subject.failure_message)
11
11
  .to eq(%q(expected ["one::default", "two::default", "three::default"] to include "one::default"))
12
12
  end
13
13
  end
14
14
 
15
- describe '#failure_message_for_should_not' do
15
+ describe '#failure_message_when_negated' do
16
16
  it 'has the right value' do
17
17
  subject.matches?(chef_run)
18
- expect(subject.failure_message_for_should_not)
18
+ expect(subject.failure_message_when_negated)
19
19
  .to eq(%q(expected "one::default" to not be included))
20
20
  end
21
21
  end
@@ -28,11 +28,11 @@ describe ChefSpec::Matchers::IncludeRecipeMatcher do
28
28
  end
29
29
 
30
30
  it 'matches when the recipe is included' do
31
- expect(subject.matches?(chef_run)).to be_true
31
+ expect(subject.matches?(chef_run)).to be_truthy
32
32
  end
33
33
 
34
34
  it 'does not match when the recipe is not included' do
35
35
  failure = described_class.new('nope')
36
- expect(failure.matches?(chef_run)).to be_false
36
+ expect(failure.matches?(chef_run)).to be_falsy
37
37
  end
38
38
  end
@@ -1,39 +1,55 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ChefSpec::Matchers::LinkToMatcher do
4
- let(:path) { '/var/www' }
5
- let(:link) { double('link', to: path, to_s: "link[#{path}]", is_a?: true, performed_action?: true) }
6
- subject { described_class.new(path) }
4
+ let(:from) { '/var/www' }
5
+ let(:to) { '/var/html' }
6
+ let(:link) do
7
+ Chef::Resource::Link.new(from).tap do |link|
8
+ link.to(to)
9
+ link.perform_action(:create)
10
+ end
11
+ end
12
+ subject { described_class.new(to) }
7
13
 
8
- describe '#failure_message_for_should' do
14
+ describe '#failure_message' do
9
15
  it 'has the right value' do
10
16
  subject.matches?(link)
11
- expect(subject.failure_message_for_should)
12
- .to eq(%Q(expected "link[#{path}]" to link to "#{path}" but was "#{path}"))
17
+ expect(subject.failure_message)
18
+ .to eq(%Q(expected "link[#{from}]" to link to "#{to}" but was "#{to}"))
13
19
  end
14
20
  end
15
21
 
16
- describe '#failure_message_for_should_not' do
22
+ describe '#failure_message_when_negated' do
17
23
  it 'has the right value' do
18
24
  subject.matches?(link)
19
- expect(subject.failure_message_for_should_not)
20
- .to eq(%Q(expected "link[#{path}]" to not link to "#{path}"))
25
+ expect(subject.failure_message_when_negated)
26
+ .to eq(%Q(expected "link[#{from}]" to not link to "#{to}"))
21
27
  end
22
28
  end
23
29
 
24
30
  describe '#description' do
25
31
  it 'has the right value' do
26
32
  subject.matches?(link)
27
- expect(subject.description).to eq(%Q(link to "#{path}"))
33
+ expect(subject.description).to eq(%Q(link to "#{to}"))
28
34
  end
29
35
  end
30
36
 
31
- it 'matches when the link is correct' do
32
- expect(subject.matches?(link)).to be_true
37
+ context 'when the link is correct' do
38
+ it 'matches' do
39
+ expect(subject.matches?(link)).to be_truthy
40
+ end
41
+
42
+ it 'adds the link to the coverage report' do
43
+ expect(ChefSpec::Coverage).to receive(:cover!).with(link)
44
+ subject.matches?(link)
45
+ end
33
46
  end
34
47
 
35
- it 'does not match when the link is incorrect' do
36
- failure = described_class.new('nope')
37
- expect(failure.matches?(link)).to be_false
48
+ context 'when the link is not correct' do
49
+ subject { described_class.new('/nope/bad/path/bro') }
50
+
51
+ it 'does not match' do
52
+ expect(subject.matches?(link)).to be_falsy
53
+ end
38
54
  end
39
55
  end
@@ -13,18 +13,18 @@ describe ChefSpec::Matchers::NotificationsMatcher do
13
13
  )
14
14
  end
15
15
 
16
- describe '#failure_message_for_should' do
16
+ describe '#failure_message' do
17
17
  it 'has the right value' do
18
18
  subject.matches?(package)
19
- expect(subject.failure_message_for_should)
19
+ expect(subject.failure_message)
20
20
  .to include %|expected "package[foo]" to notify "execute[install]", but did not.|
21
21
  end
22
22
  end
23
23
 
24
- describe '#failure_message_for_should_not' do
24
+ describe '#failure_message_when_negated' do
25
25
  it 'has the right value' do
26
26
  subject.matches?(package)
27
- expect(subject.failure_message_for_should_not)
27
+ expect(subject.failure_message_when_negated)
28
28
  .to eq %|expected "package[foo]" to not notify "execute[install]", but it did.|
29
29
  end
30
30
  end
@@ -6,18 +6,18 @@ describe ChefSpec::Matchers::RenderFileMatcher do
6
6
  let(:chef_run) { double('chef run', find_resource: file) }
7
7
  subject { described_class.new(path) }
8
8
 
9
- describe '#failure_message_for_should' do
9
+ describe '#failure_message' do
10
10
  it 'has the right value' do
11
11
  subject.matches?(chef_run)
12
- expect(subject.failure_message_for_should)
12
+ expect(subject.failure_message)
13
13
  .to eq(%Q(expected Chef run to render "#{path}"))
14
14
  end
15
15
  end
16
16
 
17
- describe '#failure_message_for_should_not' do
17
+ describe '#failure_message_when_negated' do
18
18
  it 'has the right value' do
19
19
  subject.matches?(chef_run)
20
- expect(subject.failure_message_for_should_not)
20
+ expect(subject.failure_message_when_negated)
21
21
  .to eq(%Q(expected file "#{path}" to not be in Chef run))
22
22
  end
23
23
  end
@@ -29,13 +29,22 @@ describe ChefSpec::Matchers::RenderFileMatcher do
29
29
  end
30
30
  end
31
31
 
32
- it 'matches when the file is correct' do
33
- expect(subject.matches?(chef_run)).to be_true
32
+ context 'when the file is correct' do
33
+ it 'matches' do
34
+ expect(subject.matches?(chef_run)).to be_truthy
35
+ end
36
+
37
+ it 'adds the resource to the coverage report' do
38
+ expect(ChefSpec::Coverage).to receive(:cover!).with(file)
39
+ subject.matches?(chef_run)
40
+ end
34
41
  end
35
42
 
36
- it 'does not match when the file is incorrect' do
37
- chef_run.stub(:find_resource).and_return(nil)
38
- failure = described_class.new('nope')
39
- expect(failure.matches?(chef_run)).to be_false
43
+ context 'when the file is not correct' do
44
+ it 'does not match' do
45
+ allow(chef_run).to receive(:find_resource).and_return(nil)
46
+ failure = described_class.new('nope')
47
+ expect(failure.matches?(chef_run)).to be_falsy
48
+ end
40
49
  end
41
50
  end
@@ -11,26 +11,26 @@ describe ChefSpec::Matchers::StateAttrsMatcher do
11
11
  expect(subject).to_not be_matches(resource)
12
12
  end
13
13
 
14
- its(:description) { should eq('have state attributes [:a, :b]') }
14
+ it 'has the correct description' do
15
+ expect(subject.description).to eq('have state attributes [:a, :b]')
16
+ end
17
+
18
+ it 'has the correct failure message for should' do
19
+ expect(subject.failure_message).to include <<-EOH.gsub(/^ {8}/, '')
20
+ expected _something_ to have state attributes, but the _something_ you gave me was nil!
21
+ Ensure the resource exists before making assertions:
15
22
 
16
- its(:failure_message_for_should) do
17
- should eq "expected _something_ to have state attributes, but " \
18
- "the _something_ you gave me was nil!" \
19
- "\n" \
20
- "Ensure the resource exists before making assertions:" \
21
- "\n\n" \
22
- " expect(resource).to be" \
23
- "\n "
23
+ expect(resource).to be
24
+ EOH
24
25
  end
25
26
 
26
- its(:failure_message_for_should_not) do
27
- should eq "expected _something_ to not have state attributes, but " \
28
- "the _something_ you gave me was nil!" \
29
- "\n" \
30
- "Ensure the resource exists before making assertions:" \
31
- "\n\n" \
32
- " expect(resource).to be" \
33
- "\n "
27
+ it 'has the correct failure message for should not' do
28
+ expect(subject.failure_message_when_negated).to include <<-EOH.gsub(/^ {8}/, '')
29
+ expected _something_ to not have state attributes, but the _something_ you gave me was nil!
30
+ Ensure the resource exists before making assertions:
31
+
32
+ expect(resource).to be
33
+ EOH
34
34
  end
35
35
  end
36
36
 
@@ -39,12 +39,16 @@ describe ChefSpec::Matchers::StateAttrsMatcher do
39
39
  let(:resource) { double('resource', class: klass) }
40
40
  before { subject.matches?(resource) }
41
41
 
42
- its(:description) { should eq('have state attributes [:a, :b]') }
43
- its(:failure_message_for_should) do
44
- should eq('expected [:a, :b] to equal [:a, :b]')
42
+ it 'has the correct description' do
43
+ expect(subject.description).to eq('have state attributes [:a, :b]')
45
44
  end
46
- its(:failure_message_for_should_not) do
47
- should eq('expected [:a, :b] to not equal [:a, :b]')
45
+
46
+ it 'has the correct failure message for should' do
47
+ expect(subject.failure_message).to eq('expected [:a, :b] to equal [:a, :b]')
48
+ end
49
+
50
+ it 'has the correct failure message for should not' do
51
+ expect(subject.failure_message_when_negated).to eq('expected [:a, :b] to not equal [:a, :b]')
48
52
  end
49
53
 
50
54
  it 'matches when the state attributes are correct' do
@@ -52,12 +56,12 @@ describe ChefSpec::Matchers::StateAttrsMatcher do
52
56
  end
53
57
 
54
58
  it 'does not match when the state attributes are incorrect' do
55
- klass.stub(:state_attrs).and_return([:c, :d])
59
+ allow(klass).to receive(:state_attrs).and_return([:c, :d])
56
60
  expect(subject).to_not be_matches(resource)
57
61
  end
58
62
 
59
63
  it 'does not match when partial state attribute are incorrect' do
60
- klass.stub(:state_attrs).and_return([:b, :c])
64
+ allow(klass).to receive(:state_attrs).and_return([:b, :c])
61
65
  expect(subject).to_not be_matches(resource)
62
66
  end
63
67
  end
@@ -14,10 +14,10 @@ describe ChefSpec::Matchers::SubscribesMatcher do
14
14
  end
15
15
 
16
16
  context 'when no resource is found' do
17
- describe '#failure_message_for_should' do
17
+ describe '#failure_message' do
18
18
  it 'has the right value' do
19
19
  subject.matches?(package)
20
- expect(subject.failure_message_for_should)
20
+ expect(subject.failure_message)
21
21
  .to include %|expected _something_ to notify "package[foo]", but the _something_ you gave me was nil! If you are running a test like:|
22
22
  end
23
23
  end
@@ -34,21 +34,21 @@ describe ChefSpec::Matchers::SubscribesMatcher do
34
34
  end
35
35
 
36
36
  before do
37
- runner.stub(:find_resource).and_return(execute)
37
+ allow(runner).to receive(:find_resource).and_return(execute)
38
38
  end
39
39
 
40
- describe '#failure_message_for_should' do
40
+ describe '#failure_message' do
41
41
  it 'has the right value' do
42
42
  subject.matches?(package)
43
- expect(subject.failure_message_for_should)
43
+ expect(subject.failure_message)
44
44
  .to include %|expected "execute[install]" to notify "package[foo]", but did not.|
45
45
  end
46
46
  end
47
47
 
48
- describe '#failure_message_for_should_not' do
48
+ describe '#failure_message_when_negated' do
49
49
  it 'has the right value' do
50
50
  subject.matches?(package)
51
- expect(subject.failure_message_for_should_not)
51
+ expect(subject.failure_message_when_negated)
52
52
  .to eq %|expected "execute[install]" to not notify "package[foo]", but it did.|
53
53
  end
54
54
  end
@@ -15,35 +15,35 @@ describe ChefSpec::Renderer do
15
15
 
16
16
  describe '#content' do
17
17
  before do
18
- subject.stub(:content_from_cookbook_file).and_return('cookbook_file content')
19
- subject.stub(:content_from_file).and_return('file content')
20
- subject.stub(:content_from_template).and_return('template content')
18
+ allow(subject).to receive(:content_from_cookbook_file).and_return('cookbook_file content')
19
+ allow(subject).to receive(:content_from_file).and_return('file content')
20
+ allow(subject).to receive(:content_from_template).and_return('template content')
21
21
  end
22
22
 
23
23
  context 'when the resource is a cookbook_file' do
24
24
  it 'renders the cookbook_file content' do
25
- resource.stub(:resource_name).and_return('cookbook_file')
25
+ allow(resource).to receive(:resource_name).and_return('cookbook_file')
26
26
  expect(subject.content).to eq('cookbook_file content')
27
27
  end
28
28
  end
29
29
 
30
30
  context 'when the resource is a file' do
31
31
  it 'renders the file content' do
32
- resource.stub(:resource_name).and_return('file')
32
+ allow(resource).to receive(:resource_name).and_return('file')
33
33
  expect(subject.content).to eq('file content')
34
34
  end
35
35
  end
36
36
 
37
37
  context 'when the resource is a template' do
38
38
  it 'renders the template content' do
39
- resource.stub(:resource_name).and_return('template')
39
+ allow(resource).to receive(:resource_name).and_return('template')
40
40
  expect(subject.content).to eq('template content')
41
41
  end
42
42
  end
43
43
 
44
44
  context 'when the resource is not a file type' do
45
45
  it 'returns nil' do
46
- resource.stub(:resource_name).and_return('service')
46
+ allow(resource).to receive(:resource_name).and_return('service')
47
47
  expect(subject.content).to be_nil
48
48
  end
49
49
  end