diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-06-06 12:55:48 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-06-11 08:05:36 +1000 |
| commit | 06b919ddb7d635abfe7855336e0e5af67675b44e (patch) | |
| tree | d652d76190726ae38d06869f3824281236a7a6f7 /spec/unit/parser | |
| parent | 2945f8d315d265cfb527443cca27d191b7f3d8be (diff) | |
| download | puppet-06b919ddb7d635abfe7855336e0e5af67675b44e.tar.gz puppet-06b919ddb7d635abfe7855336e0e5af67675b44e.tar.xz puppet-06b919ddb7d635abfe7855336e0e5af67675b44e.zip | |
Fix collector specs which were not working
The various collector specs covering the rails query code were not
in fact covering anything.
This patch fixes the specs to integration tests that actually verify
the rails query building code works fine.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser')
| -rwxr-xr-x | spec/unit/parser/collector.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb index 487bdc094..c2d5a991b 100755 --- a/spec/unit/parser/collector.rb +++ b/spec/unit/parser/collector.rb @@ -476,7 +476,10 @@ describe Puppet::Parser::Collector, "when building its ActiveRecord query for co @equery = nil @vquery = proc { |r| true } + @resource = stub_everything 'collected' + @collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported) + @collector.stubs(:exported_resource).with(@resource).returns(@resource) @compiler.stubs(:resources).returns([]) ActiveRecord::Base.stubs(:connected?).returns(false) @@ -497,36 +500,36 @@ describe Puppet::Parser::Collector, "when building its ActiveRecord query for co Puppet::Rails::Resource.stubs(:find).with { |*arguments| options = arguments[3] options[:conditions][0] =~ /^host_id != \?/ and options[:conditions][1] == 5 - }.returns([]) + }.returns([@resource]) - @collector.evaluate + @collector.evaluate.should == [@resource] end it "should return parameter names, parameter values and tags when querying ActiveRecord" do Puppet::Rails::Resource.stubs(:find).with { |*arguments| options = arguments[3] options[:include] == {:param_values => :param_name, :puppet_tags => :resource_tags} - }.returns([]) + }.returns([@resource]) - @collector.evaluate + @collector.evaluate.should == [@resource] end it "should only search for exported resources with the matching type" do Puppet::Rails::Resource.stubs(:find).with { |*arguments| options = arguments[3] options[:conditions][0].include?("(exported=? AND restype=?)") and options[:conditions][1] == true and options[:conditions][2] == "Mytype" - }.returns([]) + }.returns([@resource]) - @collector.evaluate + @collector.evaluate.should == [@resource] end it "should include the export query if one is provided" do - @collector = Puppet::Parser::Collector.new(@scope, @resource_type, "test = true", @vquery, :exported) + @collector.equery = "test = true" Puppet::Rails::Resource.stubs(:find).with { |*arguments| options = arguments[3] options[:conditions][0].include?("test = true") - }.returns([]) + }.returns([@resource]) - @collector.evaluate + @collector.evaluate.should == [@resource] end end |
