mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Cleanup some RSpec tests/settings
This commit is contained in:
parent
a6e289f6cc
commit
9ebc503328
4 changed files with 19 additions and 26 deletions
|
@ -20,9 +20,8 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before do
|
config.before do |example|
|
||||||
if self.class.include?(Capybara::DSL)
|
if self.class.include?(Capybara::DSL)
|
||||||
example = RSpec.current_example
|
|
||||||
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js]
|
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js]
|
||||||
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver]
|
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver]
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Capybara
|
||||||
include ::RSpec::Matchers::Composable
|
include ::RSpec::Matchers::Composable
|
||||||
|
|
||||||
def and(matcher)
|
def and(matcher)
|
||||||
Capybara::RSpecMatchers::Compound::And.new(self, matcher)
|
And.new(self, matcher)
|
||||||
end
|
end
|
||||||
|
|
||||||
def and_then(matcher)
|
def and_then(matcher)
|
||||||
|
@ -14,7 +14,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def or(matcher)
|
def or(matcher)
|
||||||
Capybara::RSpecMatchers::Compound::Or.new(self, matcher)
|
Or.new(self, matcher)
|
||||||
end
|
end
|
||||||
|
|
||||||
class CapybaraEvaluator
|
class CapybaraEvaluator
|
||||||
|
|
|
@ -7,19 +7,17 @@ Capybara::SpecHelper.spec '#body' do
|
||||||
expect(@session.body).to include('Hello world!')
|
expect(@session.body).to include('Hello world!')
|
||||||
end
|
end
|
||||||
|
|
||||||
if "".respond_to?(:encoding)
|
context "encoding of response between ascii and utf8" do
|
||||||
context "encoding of response between ascii and utf8" do
|
it "should be valid with html entities" do
|
||||||
it "should be valid with html entities" do
|
@session.visit('/with_html_entities')
|
||||||
@session.visit('/with_html_entities')
|
expect(@session).to have_content('Encoding') # wait for content to appear if visit is async
|
||||||
expect(@session).to have_content('Encoding') # wait for content to appear if visit is async
|
expect { @session.body.encode!("UTF-8") }.not_to raise_error
|
||||||
expect { @session.body.encode!("UTF-8") }.not_to raise_error
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "should be valid without html entities" do
|
it "should be valid without html entities" do
|
||||||
@session.visit('/with_html')
|
@session.visit('/with_html')
|
||||||
expect(@session).to have_content('This is a test') # wait for content to appear if visit is async
|
expect(@session).to have_content('This is a test') # wait for content to appear if visit is async
|
||||||
expect { @session.body.encode!("UTF-8") }.not_to raise_error
|
expect { @session.body.encode!("UTF-8") }.not_to raise_error
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,17 +12,13 @@ feature "Capybara's feature DSL" do
|
||||||
@in_background = true
|
@in_background = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_example(context)
|
|
||||||
RSpec.respond_to?(:current_example) ? RSpec.current_example : context.example
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "includes Capybara" do
|
scenario "includes Capybara" do
|
||||||
visit('/')
|
visit('/')
|
||||||
expect(page).to have_content('Hello world!')
|
expect(page).to have_content('Hello world!')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "preserves description" do
|
scenario "preserves description" do |ex|
|
||||||
expect(current_example(self).metadata[:full_description])
|
expect(ex.metadata[:full_description])
|
||||||
.to eq("Capybara's feature DSL preserves description")
|
.to eq("Capybara's feature DSL preserves description")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,12 +44,12 @@ feature "Capybara's feature DSL" do
|
||||||
expect(page).to have_content 'Hello world!'
|
expect(page).to have_content 'Hello world!'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'are marked in the metadata as capybara_feature' do
|
scenario 'are marked in the metadata as capybara_feature' do |ex|
|
||||||
expect(current_example(self).metadata[:capybara_feature]).to be_truthy
|
expect(ex.metadata[:capybara_feature]).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'have a type of :feature' do
|
scenario 'have a type of :feature' do |ex|
|
||||||
expect(current_example(self).metadata[:type]).to eq :feature
|
expect(ex.metadata[:type]).to eq :feature
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue