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