Created
August 12, 2011 03:48
-
-
Save timuruski/1141404 to your computer and use it in GitHub Desktop.
Sinatra sings the helper stubbing blues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra/base' | |
| require 'rack/test' | |
| class MyApp < Sinatra::Base | |
| disable :show_exceptions | |
| helpers do | |
| def msg | |
| "hello world" | |
| end | |
| end | |
| get '/' do | |
| msg | |
| end | |
| end | |
| describe "sinatra helpers" do | |
| include Rack::Test::Methods | |
| def app; MyApp.new end | |
| it "fails to stub" do | |
| app.stub(:msg) { 'goodbye world' } | |
| get "/" | |
| last_response.body.should == 'goodbye world' | |
| end | |
| it "fails to stub miserably" do | |
| MyApp.any_instance.stub(:msg).and_return { 'goodbye world' } | |
| get "/" | |
| last_response.body.should == 'goodbye world' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment