我获得了一个样本sinatra项目,其中有一个用于在akephalos进行水豚测试的hello world。我通过查看代码来理解这个概念,但我该如何运行呢?如果我运行rackup config.ru,然后转到:9292我只看到一个问候世界。太好了,那是什么告诉我的?我该如何进行测试?该项目很简单,但下面是一个名为example_spec.rb的文件。我怎么能看到它失败,例如通过寻找“嗨世界”并观看它失败?希望这是足够的信息。以为我会先问这个,然后我问那个为我提供测试的老兄,谢谢!
# describe and context blocks are optional but help organize things
describe 'the index page' do
include x
# :js => true is used to run the test in Firefox. Otherwise it runs headless
# and without JS support
it 'can view the index page', :js => true do
visit '/'
# check to see if the page has the following text (ignoring tags)
page.should have_content('Hello, world!')
# visit https://github.com/jnicklas/capybara to see a complete list of
# assertions
end
答案 0 :(得分:2)
您需要设置Capybara.app = <your Sinatra class>
。也许是这样的:
setup do
Capybara.app = Main
end
答案 1 :(得分:0)
bundle exec rspec spec,这意味着在“spec”目录上运行“bundle exec rspec”