I'm implementing a two step login. In the first step the user has to enter his email+password. If correct then a random string is generated, stored in the session and sent to the account开发者_开发技巧 holder's mobile phone.
I wonder how to access the session variable from within my step definitions or how to otherwise capture the random string so that I can use fill it in the form and so test the whole login as the user would use it. The string is not stored in the model because it's only temporary.
Thanks, Corin
Stub the token generator to return a fixed string.
I solved it by stubbing the SMSGateway. My code in features/env.rb:
require 'cucumber/rspec/doubles'
...
Before do |scenario|
@smsgateway_sent_text_messages = []
SMSGateway.stub(:send_text_message) do |message, phone_number|
@smsgateway_sent_text_messages << {
:phone_number => phone_number,
:message => message,
}
end
end
精彩评论