The following scenario pretty much sums up my problem:
Scenario: problems with subprocesses
Given the date is 01/01/2012 10:31
When I run `ruby -e "puts Time.now"`
Then the output should contain "10:31"
It boils down to When I run ruby -e "puts Time.now"
launching a child process and thus making all of my Timecop.freeze
stubs ineffective, since they only work on the main process. I need to somehow 'inject' the current context into the command that is run, but I seem to be unable to come up with anything. Am I trying something impossible here?
The step:
require 'timecop'
Given /^the date is (\d+)\/(\d+)\/(\d+) (\d+):(\d+)$/ do |month, day, year, hour, minute|
Timecop.freeze(Time.local(year.to_i, month.to_i, day.to_i, hour.to_i , minute.to_i, 0))
end