Created
February 11, 2011 02:52
-
-
Save jamesmartin/821844 to your computer and use it in GitHub Desktop.
Testing instance methods defined on a Sinatra application using the helpers module using RSpec
This file contains 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 'rubygems' | |
require 'sinatra' | |
Sinatra::Base.show_exceptions = false | |
class App < Sinatra::Base | |
helpers do | |
def my_helper_method | |
"ZOMG HELLO!" | |
end | |
end | |
end |
This file contains 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
describe 'App' do | |
before(:each) do | |
@app = App.new | |
end | |
def app | |
@app ||= App.new | |
end | |
it "exposes its helper methods" do | |
@app.should respond_to :my_helper_method | |
@app.my_helper_method.should == "ZOMG HELLO!" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment