On Sep 27, 2008, at 4:21 AM, Brice Figureau wrote:
> +
> +    it "should evaluate left operand inconditionally" do
> +        lval = stub "lval"
> +        lval.expects(:safeevaluate).with(@scope).returns("true")
> +        rval = stub "rval", :safeevaluate => false
> +
> +        operator = Puppet::Parser::AST::BooleanOperator.new :rval  
> => rval, :operator => "or", :lval => lval
> +        operator.evaluate(@scope)
> +    end

Here I might do something like 'rval.expects(:evaluate).never', to  
make the assertion clear.

I can't actually quite tell if you are asserting here that the rval  
shouldn't be evaluated.

>
> +    it "should evaluate right 'and' operand only if left operand is  
> true" do
> +        lval = stub "lval", :safeevaluate => true
> +        rval = stub "rval", :safeevaluate => false
> +        rval.expects(:safeevaluate).with(@scope).returns(false)
> +        operator = Puppet::Parser::AST::BooleanOperator.new :rval  
> => rval, :operator => "and", :lval => lval
> +        operator.evaluate(@scope)
> +    end
> +
> +    it "should evaluate right 'or' operand only if left operand is  
> false" do
> +        lval = stub "lval", :safeevaluate => false
> +        rval = stub "rval", :safeevaluate => false
> +        rval.expects(:safeevaluate).with(@scope).returns(false)
> +        operator = Puppet::Parser::AST::BooleanOperator.new :rval  
> => rval, :operator => "or", :lval => lval
> +        operator.evaluate(@scope)
> +    end
> +
> +    it "should return true for false OR true" do
> +        operator = Puppet::Parser::AST::BooleanOperator.new :rval  
> => @true_ast, :operator => "or", :lval => @false_ast
> +        operator.evaluate(@scope).should == true
> +    end

It's nitpicky, but these can be done as oneliners:

Puppet::Parser::AST::BooleanOperator.new(:rval => @true_ast, :operator  
=> "or", :lval => @false_ast).evaluate(@scope).should be_true

(Note RSpec has builtin be_true, be_false, and be_nil matchers.)

This is stylistic, so it doesn't matter much to me.  I use a wide  
editor window, as you probably know by now, so that works well for me.

-- 
I do not feel obliged to believe that the same God who has endowed us
with sense, reason, and intellect has intended us to forgo their use.
     -- Galileo Galilei
---------------------------------------------------------------------
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