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'
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::RSpecMatchers, :type => :feature

View File

@ -21,7 +21,8 @@ def self.feature(*args, &block)
options[:caller] ||= caller
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
RSpec.configuration.include Capybara::Features, :capybara_feature => true

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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