[rspec-users] Style issue

James Byrne lists at ruby-forum.com
Thu Apr 23 15:05:40 EDT 2009


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?
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list