[rspec-users] [cucumber] Setting a constant in step definition
dchelimsky at gmail.com
Mon Apr 27 09:34:20 EDT 2009
On Mon, Apr 27, 2009 at 7:00 AM, Andrew Premdas <apremdas at gmail.com> wrote:
> Currently I have a very simple constants implementation being loaded as a
> Rails initialiser
> module MVOR
> module Postage
> THRESHOLD = BigDecimal.new('6.99')
> RATE = BigDecimal.new('30.00')
> My scenarios of my postage feature want to deal with two situations when the
> THRESHOLD has been set to zero and to '6.99'. The question is how can I set
> the threshold in my step_definition. So I want to implement
> Given the postage threshold is 0.00
> Given the postage threshold is 6.99
> I've considered a number of ideas, but seem to keep on getting into complex
> solutions for what I assume is something very simple.
If THRESHOLD can change, then it is not, by definition, a constant.
It's just a global variable.
I'd change it to a method and then stub that method for a given
scenario (even though stubbing is a Cucumber no-no ;) ).
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users