Skip to content

Commit

Permalink
fix feature definition in case user has RSpec set not to expose dsl g…
Browse files Browse the repository at this point in the history
…lobally - test in rspec 3 beta tests
  • Loading branch information
twalpole committed Apr 3, 2014
1 parent 12b975d commit 85e9fcd
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions lib/capybara/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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

Expand Down
3 changes: 2 additions & 1 deletion lib/capybara/rspec/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/capybara/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def spec(name, options={}, &block)

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
Expand Down
2 changes: 1 addition & 1 deletion spec/basic_node_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Capybara do
RSpec.describe Capybara do
describe '.string' do
let :string do
Capybara.string <<-STRING
Expand Down
5 changes: 2 additions & 3 deletions spec/capybara_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -44,7 +43,7 @@
end
end

describe Capybara::Session do
RSpec.describe Capybara::Session do
context 'with non-existant driver' do
it "should raise an error" do
expect {
Expand Down
2 changes: 1 addition & 1 deletion spec/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestClass
:hover
]

describe Capybara::DSL do
RSpec.describe Capybara::DSL do
after do
Capybara.session_name = nil
Capybara.default_driver = nil
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/selenium_driver_rspec_failure.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/selenium_driver_rspec_success.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spec/rack_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module TestSessions
:hover
]

describe Capybara::Session do
RSpec.describe Capybara::Session do
context 'with rack test driver' do
before do
@session = TestSessions::RackTest
Expand Down Expand Up @@ -70,7 +70,7 @@ module TestSessions
end
end

describe Capybara::RackTest::Driver do
RSpec.describe Capybara::RackTest::Driver do
before do
@driver = TestSessions::RackTest.driver
end
Expand Down Expand Up @@ -165,7 +165,7 @@ def dont_extend_css_handler
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
Expand Down
2 changes: 1 addition & 1 deletion spec/result_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Capybara::Result do
RSpec.describe Capybara::Result do
let :string do
Capybara.string <<-STRING
<ul>
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'capybara/dsl'
require 'capybara/rspec/matchers'

describe Capybara::RSpecMatchers do
RSpec.describe Capybara::RSpecMatchers do
include Capybara::DSL
include Capybara::RSpecMatchers

Expand Down
4 changes: 2 additions & 2 deletions spec/rspec_spec.rb
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -37,7 +37,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions spec/selenium_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module TestSessions
:trigger
]

describe Capybara::Session do
RSpec.describe Capybara::Session do
context 'with selenium driver' do
before do
@session = TestSessions::Selenium
Expand Down Expand Up @@ -66,7 +66,7 @@ module TestSessions
end
end

describe Capybara::Selenium::Driver do
RSpec.describe Capybara::Selenium::Driver do
before do
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/server_spec.rb
Original file line number Diff line number Diff line change
@@ -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!"]]}
Expand Down

0 comments on commit 85e9fcd

Please sign in to comment.