diff options
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/fixture_helpers.rb | 7 | ||||
-rw-r--r-- | spec/support/provider_subject.rb | 7 | ||||
-rw-r--r-- | spec/support/resource_helpers.rb | 27 | ||||
-rw-r--r-- | spec/support/vcsrepo_helpers.rb | 12 |
4 files changed, 53 insertions, 0 deletions
diff --git a/spec/support/fixture_helpers.rb b/spec/support/fixture_helpers.rb new file mode 100644 index 0000000..7b7b20a --- /dev/null +++ b/spec/support/fixture_helpers.rb @@ -0,0 +1,7 @@ +module FixtureHelpers + + def fixture(name, ext = '.txt') + File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', name.to_s + ext)) + end + +end diff --git a/spec/support/provider_subject.rb b/spec/support/provider_subject.rb new file mode 100644 index 0000000..de7ce7c --- /dev/null +++ b/spec/support/provider_subject.rb @@ -0,0 +1,7 @@ +module ProviderSubject + + def provider + subject + end + +end diff --git a/spec/support/resource_helpers.rb b/spec/support/resource_helpers.rb new file mode 100644 index 0000000..8327ec0 --- /dev/null +++ b/spec/support/resource_helpers.rb @@ -0,0 +1,27 @@ +class ProviderExampleGroup < Spec::Example::ExampleGroup + + attr_reader :resource + + before :each do + resource_hash = example_group_hierarchy.inject({}) do |memo, klass| + memo.merge(klass.options[:resource] || {}) + end + full_hash = resource_hash.merge(:provider => described_class.name) + @resource = described_class.resource_type.new(full_hash) + end + + subject { described_class.new(@resource) } + alias :provider :subject + + def _(name) + resource.value(name) + end + +end + +Spec::Example::ExampleGroupFactory.register(:provider, ProviderExampleGroup) + +def describe_provider(type_name, provider_name, options = {}, &block) + provider_class = Puppet::Type.type(type_name).provider(provider_name) + describe(provider_class, options.merge(:type => :provider), &block) +end diff --git a/spec/support/vcsrepo_helpers.rb b/spec/support/vcsrepo_helpers.rb new file mode 100644 index 0000000..e0b9beb --- /dev/null +++ b/spec/support/vcsrepo_helpers.rb @@ -0,0 +1,12 @@ +module VcsrepoHelpers + + def expects_chdir + Dir.expects(:chdir).with(resource.value(:path)).at_least_once.yields + end + + def expects_mkdir + Dir.expects(:mkdir).with(resource.value(:path)).at_least_once + end + + +end |