[rspec-users] Style issue

Matt Wynne matt at mattwynne.net
Fri Apr 24 03:34:27 EDT 2009

On 23 Apr 2009, at 20:05, James Byrne wrote:

> In one of my features I have to check to see if a file is created by  
> an
> external script and then determine if that file contains specific
> information.  So, I ended up with these step definitions:
> When /currency exchange rate transfer file should contain rates/ do
>  found = false
>  fx_code = 'USD'
>  File.open(FOREX_XFR_FN).each do |line|
>    found = true if
> /.*fx_target#{fx_code}.*fx_rate(\d+\.\d{4}).*/.match(line)
>    break if found
>  end
>  fail(ArgumentError, "Exchange Rate not found for #{fx_code}") if not
> found
> end
> When /currency exchange rate transfer file should exist/ do
>  File.open(FOREX_XFR_FN)
> end
> These work well enough.  What I want to know if this is considered a
> normal style for testing this sort of specification and if not then  
> what
> is?

Slightly off-topic, but it seems a bit weird to have the word 'should'  
in a When step to me. Are these really Then steps?

Matt Wynne

More information about the rspec-users mailing list