Попытка настроить capybara / rspec для тестирования простого приложения sinatra, но постоянно выдает ошибку стойки.
hello.rb
require 'sinatra'
class App < Sinatra::Base
get "/" do
"hello hello!"
end
run! if app_file == $0
end
спецификация / hello_spec.rb
require File.join(File.dirname(__FILE__), '..', 'hello.rb')
require 'rspec'
require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec'
set :environment, :test
describe 'The Hello App' do
include Capybara::DSL
def setup
Capybara.app = App
end
it "says hello when browsing /" do
visit '/'
page.should have_content('hello')
end
end
Обратите внимание, я тоже пробовал
def setup
Capybara.app = App.new
end
Который выдал ту же ошибку.
Ошибка:
C:\Sites\misc\qrgen>bundle exec rspec
F
Failures:
1) The Hello App says hello when browsing /
Failure/Error: visit '/'
ArgumentError:
rack-test requires a rack application, but none was given
# ./spec/hello_spec.rb:18:in `block (2 levels) in <top (required)>'
Finished in 0.374 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/hello_spec.rb:17 # The Hello App says hello when browsing /
Та же ошибка при запуске и без комплекта exec. Есть идеи?
Gemfile:
gem "sinatra"
gem "sinatra-contrib"
gem "sinatra-flash"
gem "slim"
gem "rspec"
gem "capybara"
gem "rack-test"