+1

On Jun 6, 2009, at 7:18 AM, Brice Figureau wrote:

>
> 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 <[email protected]>
> ---
> 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 487bdc0..c2d5a99 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
> -- 
> 1.6.0.2
>
>
> >


-- 
I used to get high on life but lately I've built up a resistance.
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to