Created
December 6, 2013 03:35
-
-
Save yuanying/7818151 to your computer and use it in GitHub Desktop.
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 'sinatra' | |
get '/' do | |
hello | |
end | |
helpers do | |
def hello | |
'Hello World!' | |
end | |
end | |
if defined?(RSpec) | |
require 'rack/test' | |
RSpec.configure { |c| c.include Rack::Test::Methods } | |
describe Sinatra::Application do | |
def app(); @app ||= Sinatra::Application.new end | |
context 'hello をスタブしてないとき、' do | |
it 'Hello World! を返す。' do | |
get '/' | |
expect(last_response.body).to eq('Hello World!') | |
end | |
end | |
context 'hello をスタブしてるとき、' do | |
before { allow(app).to receive(:hello).and_return('Hello Stub!') } | |
it 'Hello Stub! を返す。' do | |
get '/' | |
expect(last_response.body).to eq('Hello Stub!') | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment