开发者

how to run capybara sinatra

I was given a sample sinatra project with a hello world for capybara testing in akephalos. I understand the concept by looking at the code, but how do i run it? If I run rackup config.ru, and then go to :9292 I just see a hello world. Great, what is that telling me? How do I run the test? The project is bare bones, but below is a file called example_spec.rb. How can I see it fail, for example by looking for "Hi world" and watching it fail? Hope this is enough info. Thought I would check here before I ask the dude that supplied me with the test, thanks!

# describe and context blocks are optional but help organize things
describe 'the index page' do
  include x

  # :js => true is开发者_JAVA百科 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


You need to set Capybara.app = <your Sinatra class>. Perhaps something like this:

setup do
  Capybara.app = Main
end


bundle exec rspec spec, This means run "bundle exec rspec" on the "spec" directory

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜