- spec repo.rb
- ........FFFF
- 1)
- Mocha::ExpectationError in 'Puppet::Type::Repo Puppet::Type::Repo when it should be absent should do nothing if it is absent'
- not all expectations were satisfied
- unsatisfied expectations:
- - expected exactly once, not yet invoked: #<Mock:provider>.properties(any_parameters)
- satisfied expectations:
- - allowed any number of times, not yet invoked: #<Mock:provider>.satisfies?(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.name(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.clear(any_parameters)
- - allowed any number of times, already invoked 7 times: #<Mock:provider>.class(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.instances(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.new(any_parameters)
- ./repo.rb:81:
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:22:in `run'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `each'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `run'
- 2)
- Mocha::ExpectationError in 'Puppet::Type::Repo Puppet::Type::Repo when it should be absent should uninstall if it is present'
- not all expectations were satisfied
- unsatisfied expectations:
- - expected exactly once, not yet invoked: #<Mock:provider>.uninstall(any_parameters)
- satisfied expectations:
- - allowed any number of times, not yet invoked: #<Mock:provider>.properties(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.satisfies?(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.name(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.clear(any_parameters)
- - allowed any number of times, already invoked 7 times: #<Mock:provider>.class(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.instances(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.new(any_parameters)
- ./repo.rb:89:
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:22:in `run'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `each'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `run'
- 3)
- Mocha::ExpectationError in 'Puppet::Type::Repo Puppet::Type::Repo when it should be present should do nothing if it is present'
- not all expectations were satisfied
- unsatisfied expectations:
- - expected exactly once, not yet invoked: #<Mock:provider>.properties(any_parameters)
- satisfied expectations:
- - allowed any number of times, not yet invoked: #<Mock:provider>.satisfies?(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.name(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.clear(any_parameters)
- - allowed any number of times, already invoked 7 times: #<Mock:provider>.class(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.instances(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.new(any_parameters)
- ./repo.rb:102:
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:22:in `run'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `each'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `run'
- 4)
- Mocha::ExpectationError in 'Puppet::Type::Repo Puppet::Type::Repo when it should be present should install if it is absent'
- not all expectations were satisfied
- unsatisfied expectations:
- - expected exactly once, not yet invoked: #<Mock:provider>.install(any_parameters)
- satisfied expectations:
- - allowed any number of times, not yet invoked: #<Mock:provider>.properties(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.satisfies?(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.name(any_parameters)
- - allowed any number of times, not yet invoked: #<Mock:provider>.clear(any_parameters)
- - allowed any number of times, already invoked 7 times: #<Mock:provider>.class(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.instances(any_parameters)
- - allowed any number of times, already invoked once: Puppet::Type::Repo::ProviderZypper.new(any_parameters)
- ./repo.rb:110:
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:22:in `run'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `each'
- /puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `run'
- Finished in 0.037089 seconds
- 12 examples, 4 failures
- ---------------------------------
- cat repo.rb
- #!/usr/bin/env ruby
- Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
- repo = Puppet::Type.type(:repo)
- describe repo do
- before do
- @provider = stub 'provider'
- @resource = stub 'resource', :resource => nil, :provider => @provider, :line => nil, :file => nil
- end
- it "should default to being installed" do
- pkg = Puppet::Type.type(:repo).new(:name => "yay")
- pkg.should(:ensure).should == :present
- end
- end
- describe repo, "when validating attributes" do
- # [:name, :source, :instance, :status, :adminfile, :responsefile, :configfiles, :category, :platform, :root, :vendor, :description, :allowcdrom].each do |param|
- [:name ,:source].each do |param|
- it "should have a #{param} parameter" do
- Puppet::Type.type(:package).attrtype(param).should == :param
- end
- end
- it "should have an ensure property" do
- Puppet::Type.type(:package).attrtype(:ensure).should == :property
- end
- end
- describe repo, "when validating attribute values" do
- before do
- @provider = stub 'provider', :class => Puppet::Type.type(:repo).defaultprovider, :clear => nil
- Puppet::Type.type(:repo).defaultprovider.expects(:new).returns(@provider)
- end
- it "should support :present as a value to :ensure" do
- repo.new(:name => "yay", :ensure => :present)
- end
- it "should alias :installed to :present as a value to :ensure" do
- repo = Puppet::Type.type(:repo).new(:name => "yay", :ensure => :installed)
- repo.should(:ensure).should == :present
- end
- it "should support :absent as a value to :ensure" do
- Puppet::Type.type(:repo).new(:name => "yay", :ensure => :absent)
- end
- it "should accept any string as an argument to :source" do
- proc { Puppet::Type.type(:repo).new(:name => "yay", :source => "stuff") }.should_not raise_error(Puppet::Error)
- end
- end
- module RepositoryEvaluationTesting
- def setprops(properties)
- @provider.stubs(:properties).returns(properties)
- end
- end
- describe Puppet::Type.type(:repo) do
- before :each do
- @provider = stub 'provider', :class => Puppet::Type.type(:repo).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
- Puppet::Type.type(:repo).defaultprovider.stubs(:new).returns(@provider)
- Puppet::Type.type(:repo).defaultprovider.stubs(:instances).returns([])
- @repo = Puppet::Type.type(:repo).new(:name => "yay")
- @catalog = Puppet::Resource::Catalog.new
- @catalog.add_resource(@repo)
- end
- describe Puppet::Type.type(:repo), "when it should be absent" do
- include RepositoryEvaluationTesting
- before { @repo[:ensure] = :absent }
- [:absent].each do |state|
- it "should do nothing if it is #{state.to_s}" do
- @provider.expects(:properties).returns(:ensure => state)
- @catalog.apply
- end
- end
- [:present].each do |state|
- it "should uninstall if it is #{state.to_s}" do
- @provider.stubs(:properties).returns(:ensure => state)
- @provider.expects(:uninstall)
- @catalog.apply
- end
- end
- end
- describe Puppet::Type.type(:repo), "when it should be present" do
- include RepositoryEvaluationTesting
- before { @repo[:ensure] = :present }
- [:present, ].each do |state|
- it "should do nothing if it is #{state.to_s}" do
- @provider.expects(:properties).returns(:ensure => state)
- @catalog.apply
- end
- end
- [:absent].each do |state|
- it "should install if it is #{state.to_s}" do
- @provider.stubs(:properties).returns(:ensure => state)
- @provider.expects(:install)
- @catalog.apply
- end
- end
- end
- end
