Restaurantly Testing Configuration
John Davison photo
Get notifications about new tutorials, code and events.

click: follow along with the source code

modify Gemfile

  gem 'selenium-webdriver'
  gem 'database_cleaner', '~> 1.2.0'

bundle install

mkdir spec/support/ touch spec/support/database_cleaner.rb
  # props to @avdi
  # http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/

  RSpec.configure do |config|

    config.before(:suite) do
      DatabaseCleaner.clean_with(:truncation)
    end

    config.before(:each) do
      DatabaseCleaner.strategy = :transaction
    end

    config.before(:each, :js => true) do
      DatabaseCleaner.strategy = :truncation
    end

    config.before(:each) do
      DatabaseCleaner.start
    end

    config.after(:each) do
      DatabaseCleaner.clean
    end

  end

modify app/assets/javascripts/application.js

  # remove //= turbolinks

touch app/assets/stylesheets/restaurants.css.scss

modify app/assets/stylesheets/restaurants.css.scss

  .center {
    text-align:center;
  }

modify config/routes.rb

  root to: "restaurants#index"
Get notifications about new tutorials, code and events.