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
|
||||
|
||||
config.before do
|
||||
config.before do |example|
|
||||
if self.class.include?(Capybara::DSL)
|
||||
example = RSpec.current_example
|
||||
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js]
|
||||
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver]
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module Capybara
|
|||
include ::RSpec::Matchers::Composable
|
||||
|
||||
def and(matcher)
|
||||
Capybara::RSpecMatchers::Compound::And.new(self, matcher)
|
||||
And.new(self, matcher)
|
||||
end
|
||||
|
||||
def and_then(matcher)
|
||||
|
@ -14,7 +14,7 @@ module Capybara
|
|||
end
|
||||
|
||||
def or(matcher)
|
||||
Capybara::RSpecMatchers::Compound::Or.new(self, matcher)
|
||||
Or.new(self, matcher)
|
||||
end
|
||||
|
||||
class CapybaraEvaluator
|
||||
|
|
|
@ -7,19 +7,17 @@ Capybara::SpecHelper.spec '#body' do
|
|||
expect(@session.body).to include('Hello world!')
|
||||
end
|
||||
|
||||
if "".respond_to?(:encoding)
|
||||
context "encoding of response between ascii and utf8" do
|
||||
it "should be valid with html entities" do
|
||||
@session.visit('/with_html_entities')
|
||||
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
|
||||
end
|
||||
context "encoding of response between ascii and utf8" do
|
||||
it "should be valid with html entities" do
|
||||
@session.visit('/with_html_entities')
|
||||
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
|
||||
end
|
||||
|
||||
it "should be valid without html entities" do
|
||||
@session.visit('/with_html')
|
||||
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
|
||||
end
|
||||
it "should be valid without html entities" do
|
||||
@session.visit('/with_html')
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,17 +12,13 @@ feature "Capybara's feature DSL" do
|
|||
@in_background = true
|
||||
end
|
||||
|
||||
def current_example(context)
|
||||
RSpec.respond_to?(:current_example) ? RSpec.current_example : context.example
|
||||
end
|
||||
|
||||
scenario "includes Capybara" do
|
||||
visit('/')
|
||||
expect(page).to have_content('Hello world!')
|
||||
end
|
||||
|
||||
scenario "preserves description" do
|
||||
expect(current_example(self).metadata[:full_description])
|
||||
scenario "preserves description" do |ex|
|
||||
expect(ex.metadata[:full_description])
|
||||
.to eq("Capybara's feature DSL preserves description")
|
||||
end
|
||||
|
||||
|
@ -48,12 +44,12 @@ feature "Capybara's feature DSL" do
|
|||
expect(page).to have_content 'Hello world!'
|
||||
end
|
||||
|
||||
scenario 'are marked in the metadata as capybara_feature' do
|
||||
expect(current_example(self).metadata[:capybara_feature]).to be_truthy
|
||||
scenario 'are marked in the metadata as capybara_feature' do |ex|
|
||||
expect(ex.metadata[:capybara_feature]).to be_truthy
|
||||
end
|
||||
|
||||
scenario 'have a type of :feature' do
|
||||
expect(current_example(self).metadata[:type]).to eq :feature
|
||||
scenario 'have a type of :feature' do |ex|
|
||||
expect(ex.metadata[:type]).to eq :feature
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue