summaryrefslogtreecommitdiff
path: root/spec/integration/recipes/provider_choice.rb
blob: 5aa5dcb9b38157768f339bfc5affad3217119a33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'support/shared/integration/integration_helper'

describe "Recipe DSL methods" do
  include IntegrationSupport

  context "With resource class providing 'provider_thingy'" do
    before :context do
      class Chef::Resource::ProviderThingy < Chef::Resource
        def initialize(*args, &block)
          super
          @action = :create
          @allowed_actions = [ :create ]
        end
        resource_name :provider_thingy
        def to_s
          "provider_thingy resource class"
        end
      end
    end
    context "And class Chef::Provider::ProviderThingy with no provides" do
      before :context do
        class Chef::Provider::ProviderThingy < Chef::Provider
          def load_current_resource
          end
          def action_create
            Chef::Log.warn("hello from #{self.class.name}")
          end
        end
      end

      it "provider_thingy 'blah' runs the provider and warns" do
        recipe = converge {
          provider_thingy 'blah' do; end
        }
        expect(recipe.logged_warnings).to match /hello from Chef::Provider::ProviderThingy/
        expect(recipe.logged_warnings).to match /you must use 'provides' to provide DSL/i
      end
    end
  end
end