1
我有一個Sinatra應用程序。rspec-sinatra,如何調用輔助方法?
它包括以下內容:
helpers do
def helper1
...code...
end
def helper2
...code...
end
...
end
如何測試這些輔助方法?
目前我rspec的有:
ENV['RACK_ENV'] = 'test'
require_relative '../app' # <-- your sinatra app
describe 'Basic test' do
before :each do
@xml_info = File.read('examples/request_litle_auth.xml')
end
it "basic test" do
'a'.should eq 'a'
end
it "can call a helper method" do
to_dollars(30)
end
end
但給:
undefined method `to_dollars' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000002460e18>