teamcapybara--capybara/spec/rspec/features_spec.rb

97 lines
2.4 KiB
Ruby
Raw Normal View History

2016-03-08 00:52:19 +00:00
# frozen_string_literal: true
2018-03-01 00:11:41 +00:00
require 'spec_helper'
require 'capybara/rspec'
2018-07-10 21:18:39 +00:00
RSpec.configuration.before(:each, file_path: './spec/rspec/features_spec.rb') do
2011-03-13 13:31:04 +00:00
@in_filtered_hook = true
end
feature "Capybara's feature DSL" do
background do
@in_background = true
end
2018-07-10 21:18:39 +00:00
scenario 'includes Capybara' do
visit('/')
expect(page).to have_content('Hello world!')
end
2018-07-10 21:18:39 +00:00
scenario 'preserves description' do |ex|
2018-05-15 19:39:40 +00:00
expect(ex.metadata[:full_description])
.to eq("Capybara's feature DSL preserves description")
end
2018-07-10 21:18:39 +00:00
scenario 'allows driver switching', driver: :selenium do
expect(Capybara.current_driver).to eq(:selenium)
end
2018-07-10 21:18:39 +00:00
scenario 'runs background' do
expect(@in_background).to be_truthy
end
2018-07-10 21:18:39 +00:00
scenario 'runs hooks filtered by file path' do
expect(@in_filtered_hook).to be_truthy
2011-03-13 13:31:04 +00:00
end
scenario "doesn't pollute the Object namespace" do
expect(Object.new).not_to respond_to(:feature)
end
2013-07-09 22:58:18 +00:00
feature 'nested features' do
scenario 'work as expected' do
visit '/'
expect(page).to have_content 'Hello world!'
2013-07-09 22:58:18 +00:00
end
2018-05-15 19:39:40 +00:00
scenario 'are marked in the metadata as capybara_feature' do |ex|
expect(ex.metadata[:capybara_feature]).to be_truthy
2013-07-09 22:58:18 +00:00
end
2018-05-15 19:39:40 +00:00
scenario 'have a type of :feature' do |ex|
expect(ex.metadata[:type]).to eq :feature
2013-07-09 22:58:18 +00:00
end
end
end
2018-07-10 21:18:39 +00:00
feature 'given and given! aliases to let and let!' do
2012-10-03 22:49:44 +00:00
given(:value) { :available }
given!(:value_in_background) { :available }
background do
expect(value_in_background).to be(:available)
2012-10-03 22:49:44 +00:00
end
2018-07-10 21:18:39 +00:00
scenario 'given and given! work as intended' do
expect(value).to be(:available)
expect(value_in_background).to be(:available)
2012-10-03 22:49:44 +00:00
end
end
2018-03-01 00:11:41 +00:00
feature "Capybara's feature DSL with driver", driver: :culerity do
2018-07-10 21:18:39 +00:00
scenario 'switches driver' do
expect(Capybara.current_driver).to eq(:culerity)
end
end
# rubocop:disable RSpec/RepeatedExample
2018-07-10 21:18:39 +00:00
xfeature 'if xfeature aliases to pending then' do
2018-03-01 00:11:41 +00:00
scenario "this should be 'temporarily disabled with xfeature'" do
# dummy
end
scenario "this also should be 'temporarily disabled with xfeature'" do
# dummy
end
end
2018-07-10 21:18:39 +00:00
ffeature 'if ffeature aliases focused tag then' do # rubocop:disable RSpec/Focus
scenario 'scenario inside this feature has metatag focus tag' do |example|
expect(example.metadata[:focus]).to eq true
end
2018-07-10 21:18:39 +00:00
scenario 'other scenarios also has metatag focus tag ' do |example|
expect(example.metadata[:focus]).to eq true
end
end
# rubocop:enable RSpec/RepeatedExample