I'm still not with you on the timing thing. By the time that step is reached, either the state has changed, or it hasn't. We address the need for it to be able to see "back in time" by storing a history of the state of the object in a way that is accessible to the steps. I.E. For steps like this:
Given a credential for a supported vendor
When I change the nickname
Then the edit version should not be changed
The step definitions might look like: Given /a credential for a supported vendor/ do
@thing = FactoryGirl.create(:'credential/amazon', :valid)
@thing_history = [@thing.attributes.dup]
end
When /I change the nickname/ do
@thing.nickname += " meh"
@thing.save!
@thing_history << @thing.attributes.dup
end
Then /the edit version should not be changed/ do
@thing_history[-1][:edit_version].should == @thing_history[0][:edit_version]
end
(The use of "@thing" is a way to encourage myself to only be talking about one object at a time...)Perhaps that's a somewhat obtuse way of handling things -- and there's likely ways of DRYing up that pattern, if it's worth preserving, but it's proven to be fairly effective for me in the past.
And yeah, Cucumber might make a good vehicle for that sort of testing. Quickcheck sounds like a brilliant idea -- although a bit terrifying in the context of a slow language like Ruby. Would love to get my hands on / build a tool like that...