Sha256: a694e20a0f449630ad7ab04c4fecc5bc02c773d964709ddc181b909ef22b8a8b

Contents?: true

Size: 660 Bytes

Versions: 4

Compression:

Stored size: 660 Bytes

Contents

module RSpec
  shared_examples 'a chef sugar' do
    it 'acts as a singleton' do
      described_class.module_eval("def foo; 'result'; end")
      klass = Class.new.tap { |k| k.send(:include, described_class) }
      expect(described_class.foo).to eq(klass.new.foo)
    end

    described_class.instance_methods.each do |name|
      it "defines a `#{name}` DSL method" do
        expect(Chef::Sugar::DSL.instance_methods).to include(name)
      end

      it 'has n-1 arity from the parent method' do
        method = Chef::Sugar::DSL.instance_method(name)
        expect(method.arity).to eq(described_class.method(name).arity - 1)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chef-sugar-1.1.0 spec/support/shared_examples.rb
chef-sugar-1.0.1 spec/support/shared_examples.rb
chef-sugar-1.0.0 spec/support/shared_examples.rb
chef-sugar-1.0.0.beta.1 spec/support/shared_examples.rb