1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

fix feature definition in case user has RSpec set not to expose dsl globally - test in rspec 3 beta tests

This commit is contained in:
Thomas Walpole 2014-04-03 10:25:03 -07:00
parent 12b975da27
commit 85e9fcd7f2
14 changed files with 20 additions and 19 deletions

View file

@ -5,6 +5,7 @@ require 'capybara/rspec/matchers'
require 'capybara/rspec/features' require 'capybara/rspec/features'
RSpec.configure do |config| RSpec.configure do |config|
config.expose_dsl_globally = false if config.respond_to? :expose_dsl_globally
config.include Capybara::DSL, :type => :feature config.include Capybara::DSL, :type => :feature
config.include Capybara::RSpecMatchers, :type => :feature config.include Capybara::RSpecMatchers, :type => :feature

View file

@ -21,7 +21,8 @@ def self.feature(*args, &block)
options[:caller] ||= caller options[:caller] ||= caller
args.push(options) args.push(options)
describe(*args, &block) #call describe on RSpec in case user has expose_dsl_globally set to false
RSpec.describe(*args, &block)
end end
RSpec.configuration.include Capybara::Features, :capybara_feature => true RSpec.configuration.include Capybara::Features, :capybara_feature => true

View file

@ -52,7 +52,7 @@ module Capybara
def run_specs(session, name, options={}) def run_specs(session, name, options={})
specs = @specs specs = @specs
describe Capybara::Session, name, options do RSpec.describe Capybara::Session, name, options do
include Capybara::SpecHelper include Capybara::SpecHelper
before do before do
@session = session @session = session

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Capybara do RSpec.describe Capybara do
describe '.string' do describe '.string' do
let :string do let :string do
Capybara.string <<-STRING Capybara.string <<-STRING

View file

@ -1,7 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Capybara do RSpec.describe Capybara do
describe 'default_wait_time' do describe 'default_wait_time' do
after do after do
Capybara.default_wait_time = @previous_default_time Capybara.default_wait_time = @previous_default_time
@ -44,7 +43,7 @@ describe Capybara do
end end
end end
describe Capybara::Session do RSpec.describe Capybara::Session do
context 'with non-existant driver' do context 'with non-existant driver' do
it "should raise an error" do it "should raise an error" do
expect { expect {

View file

@ -14,7 +14,7 @@ Capybara::SpecHelper.run_specs TestClass.new, "DSL", :capybara_skip => [
:hover :hover
] ]
describe Capybara::DSL do RSpec.describe Capybara::DSL do
after do after do
Capybara.session_name = nil Capybara.session_name = nil
Capybara.default_driver = nil Capybara.default_driver = nil

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Capybara::Selenium::Driver do RSpec.describe Capybara::Selenium::Driver do
it "should exit with a non-zero exit status" do it "should exit with a non-zero exit status" do
browser = Capybara::Selenium::Driver.new(TestApp).browser browser = Capybara::Selenium::Driver.new(TestApp).browser
expect(true).to eq(false) expect(true).to eq(false)

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Capybara::Selenium::Driver do RSpec.describe Capybara::Selenium::Driver do
it "should exit with a zero exit status" do it "should exit with a zero exit status" do
browser = Capybara::Selenium::Driver.new(TestApp).browser browser = Capybara::Selenium::Driver.new(TestApp).browser
expect(true).to eq(true) expect(true).to eq(true)

View file

@ -13,7 +13,7 @@ Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", :capybara_ski
:hover :hover
] ]
describe Capybara::Session do RSpec.describe Capybara::Session do
context 'with rack test driver' do context 'with rack test driver' do
before do before do
@session = TestSessions::RackTest @session = TestSessions::RackTest
@ -70,7 +70,7 @@ describe Capybara::Session do
end end
end end
describe Capybara::RackTest::Driver do RSpec.describe Capybara::RackTest::Driver do
before do before do
@driver = TestSessions::RackTest.driver @driver = TestSessions::RackTest.driver
end end
@ -165,7 +165,7 @@ module CSSHandlerIncludeTester
end end
include CSSHandlerIncludeTester include CSSHandlerIncludeTester
describe Capybara::RackTest::CSSHandlers do RSpec.describe Capybara::RackTest::CSSHandlers do
it "should not be extended by global includes" do it "should not be extended by global includes" do
expect(Capybara::RackTest::CSSHandlers.new).not_to respond_to(:dont_extend_css_handler) expect(Capybara::RackTest::CSSHandlers.new).not_to respond_to(:dont_extend_css_handler)
end end

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Capybara::Result do RSpec.describe Capybara::Result do
let :string do let :string do
Capybara.string <<-STRING Capybara.string <<-STRING
<ul> <ul>

View file

@ -2,7 +2,7 @@ require 'spec_helper'
require 'capybara/dsl' require 'capybara/dsl'
require 'capybara/rspec/matchers' require 'capybara/rspec/matchers'
describe Capybara::RSpecMatchers do RSpec.describe Capybara::RSpecMatchers do
include Capybara::DSL include Capybara::DSL
include Capybara::RSpecMatchers include Capybara::RSpecMatchers

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe 'capybara/rspec', :type => :feature do RSpec.describe 'capybara/rspec', :type => :feature do
it "should include Capybara in rspec" do it "should include Capybara in rspec" do
visit('/foo') visit('/foo')
expect(page.body).to include('Another World') expect(page.body).to include('Another World')
@ -37,7 +37,7 @@ describe 'capybara/rspec', :type => :feature do
end end
end end
describe 'capybara/rspec', :type => :other do RSpec.describe 'capybara/rspec', :type => :other do
it "should not include Capybara" do it "should not include Capybara" do
expect { visit('/') }.to raise_error(NoMethodError) expect { visit('/') }.to raise_error(NoMethodError)
end end

View file

@ -17,7 +17,7 @@ Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", :capybara_ski
:trigger :trigger
] ]
describe Capybara::Session do RSpec.describe Capybara::Session do
context 'with selenium driver' do context 'with selenium driver' do
before do before do
@session = TestSessions::Selenium @session = TestSessions::Selenium
@ -66,7 +66,7 @@ describe Capybara::Session do
end end
end end
describe Capybara::Selenium::Driver do RSpec.describe Capybara::Selenium::Driver do
before do before do
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox) @driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
end end

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Capybara::Server do RSpec.describe Capybara::Server do
it "should spool up a rack server" do it "should spool up a rack server" do
@app = proc { |env| [200, {}, ["Hello Server!"]]} @app = proc { |env| [200, {}, ["Hello Server!"]]}