@tressie.damore
To run Capybara with Sinatra, you first need to have a basic Sinatra application set up. Here's a simple example:
1 2 3 4 5 |
require 'sinatra' get '/' do 'Hello, World!' end |
1 2 3 4 5 |
source 'https://rubygems.org' gem 'sinatra' gem 'capybara' gem 'selenium-webdriver' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
require 'capybara' require 'capybara/dsl' require 'test/unit' Capybara.default_driver = :selenium Capybara.app = Sinatra::Application class AppTest < Test::Unit::TestCase include Capybara::DSL def test_home_page visit '/' assert page.has_content?('Hello, World!') end end |
This setup will run your Sinatra application and then use Capybara to automate browser interactions and verify the content of your application.