2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2010-12-10 08:54:46 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-04-03 13:25:03 -04:00
|
|
|
RSpec.describe 'capybara/rspec', :type => :feature do
|
2011-02-03 17:18:07 -05:00
|
|
|
it "should include Capybara in rspec" do
|
2010-12-10 08:54:46 -05:00
|
|
|
visit('/foo')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(page.body).to include('Another World')
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context "resetting session" do
|
|
|
|
it "sets a cookie in one example..." do
|
|
|
|
visit('/set_cookie')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(page.body).to include('Cookie set to test_cookie')
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
|
2014-03-31 18:10:27 -04:00
|
|
|
it "...then it is not available in the next" do
|
2010-12-10 08:54:46 -05:00
|
|
|
visit('/get_cookie')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(page.body).not_to include('test_cookie')
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "setting the current driver" do
|
|
|
|
it "sets the current driver in one example..." do
|
|
|
|
Capybara.current_driver = :selenium
|
|
|
|
end
|
|
|
|
|
|
|
|
it "...then it has returned to the default in the next example" do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(Capybara.current_driver).to eq(:rack_test)
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-04 14:10:29 -04:00
|
|
|
it "switches to the javascript driver when giving it as metadata", js: true do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(Capybara.current_driver).to eq(Capybara.javascript_driver)
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "switches to the given driver when giving it as metadata", :driver => :culerity do
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(Capybara.current_driver).to eq(:culerity)
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
end
|
2011-01-09 07:57:41 -05:00
|
|
|
|
2014-04-03 13:25:03 -04:00
|
|
|
RSpec.describe 'capybara/rspec', :type => :other do
|
2011-01-09 07:57:41 -05:00
|
|
|
it "should not include Capybara" do
|
|
|
|
expect { visit('/') }.to raise_error(NoMethodError)
|
|
|
|
end
|
|
|
|
end
|
2011-02-11 08:44:58 -05:00
|
|
|
|
|
|
|
feature "Feature DSL" do
|
|
|
|
scenario "is pulled in" do
|
|
|
|
visit('/foo')
|
2013-11-14 12:43:36 -05:00
|
|
|
expect(page.body).to include('Another World')
|
2011-02-11 08:44:58 -05:00
|
|
|
end
|
|
|
|
end
|