Stubbing Sinatra helper in Cucumber
cucumber, ruby, ruby-mocha, sinatra
Solution
You can get the right context by using `Sinatra::Application.class_eval`
Edit: See original poster's answer for full explanation.
Problem
I am currently struggling with stubbing out a helper method of my Sinatra app from within Cucumber. I have a Sinatra app with simple session authentication (by cookies) and I want to turn of authentication by stubbing out the `logged_in?` helper method for my Cucumber scenarios. There seems to be a problem with Sinatra and Cucumber concerning sessions so I thought about just using Mocha to work around the problem. However I don't know how I can access the `Sinatra::Application` instance from within a `Given`-Block to stub out the method.