pluginの事を考えるとbeforeが複数回定義されてもちゃんとそれぞれが実行されないと意味が無い。なので試してみた。

komagata's double_before at master - GitHub

require 'rubygems'
require 'sinatra'

before do
@name = 'Masaki'
end

before do
@name += ' Komagata'
end

get '/' do
"Hello, #{@name}"
end
require 'rubygems'
require 'test/unit'
require 'rack/test'
require 'shoulda'
require './double_before'

class DoubleBeforeTest < Test::Unit::TestCase
include Rack::Test::Methods

def app
Sinatra::Application
end

context "Access pages" do
should "show index" do
get '/'
assert_equal 'Hello, Masaki Komagata', last_response.body
end
end
end
% ruby double_before_test.rb 
Loaded suite double_before_test
Started
.
Finished in 0.030489 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

おお、問題無い!これは期待してなかったので嬉しいですゾ!(@ムック)

Comments


Option