Cucumber + Capybara + Sinatra

This post is not to provide a tutorial of how to combine those three awesome applications together, but it might stop you from scratching your head when the test cannot be run correctly.

  1. You need to have Sinatra in subclass style rather than classic style. Sinatra subclass-style
  2. This is quite importance, you might find some website that is using Spec. but you need to change it to be “RSpec” in order for it to work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require File.join(File.dirname(__FILE__), '..', '..', '/server.rb')

require 'rspec'
require 'rspec/expectations'
require 'rack/test'
require 'capybara'
require 'capybara/cucumber'
require 'capybara/envjs'

App.set(:environment, :test)

World do
  Capybara.app = App
  Capybara.javascript_driver = :envjs
  include Capybara
  include RSpec::Expectations
  include RSpec::Matchers
end
Jan 15th, 2012

Comments