Browse files

Move the RackTest driver override to capybara/rails

This change enables the `:respect_data_method` option from the RackTest
driver for Rails projects that don't use RSpec.
  • Loading branch information...
1 parent 6446eac commit 9c1dd623f1f91aa1531c3db14037ab12cae79ca6 @carlosantoniodasilva carlosantoniodasilva committed Nov 15, 2012
Showing with 13 additions and 6 deletions.
  1. +8 −0 History.md
  2. +5 −1 lib/capybara/rails.rb
  3. +0 −5 lib/capybara/rspec.rb
View
8 History.md
@@ -1,3 +1,11 @@
+# master
+
+### Changed
+
+* Move the RackTest driver override with the `:respect_data_method` option
+ enabled from capybara/rspec to capybara/rails, so that it is enabled in
+ Rails projects that don't use RSpec. [Carlos Antonio da Silva]
+
# Version 2.0.0
Release date: 2012-11-05
View
6 lib/capybara/rails.rb
@@ -4,7 +4,7 @@
Capybara.app = Rack::Builder.new do
map "/" do
if Rails.version.to_f >= 3.0
- run Rails.application
+ run Rails.application
else # Rails 2
use Rails::Rack::Static
run ActionController::Dispatcher.new
@@ -15,3 +15,7 @@
Capybara.asset_root = Rails.root.join('public')
Capybara.save_and_open_page_path = Rails.root.join('tmp/capybara')
+# Override default rack_test driver to respect data-method attributes.
+Capybara.register_driver :rack_test do |app|
+ Capybara::RackTest::Driver.new(app, :respect_data_method => true)
+end
View
5 lib/capybara/rspec.rb
@@ -22,8 +22,3 @@
end
end
end
-
-# Override default rack_test driver to respect data-method attributes.
-Capybara.register_driver :rack_test do |app|
- Capybara::RackTest::Driver.new(app, :respect_data_method => true)
-end

5 comments on commit 9c1dd62

@tomstuart

What about #478?

@carlosantoniodasilva

It is false by default, but true in capybara/rails where it makes more sense. Not sure I follow @tomstuart, can you please clarify?

@tomstuart

There’s a discussion in #184 about making this behaviour opt-in so that nobody gets unexpectedly bitten by the data-method magic, and my expectation was that :respect_data_method => false would be the default everywhere in Capybara 2.0. If there’s been another discussion about enabling it by default for Rails apps then I haven’t seen it.

@carlosantoniodasilva

Well, as far as I know, it's about #793 and telling everyone using Rails to add respect_data_method, since I believe it's more expected that it works this way within Rails helpers like link_to. I myself would make that change in my apps to use data-method with rack-test, so that I wouldn't need a javascript driver to test such features. Anyway, I can't say more than that because I don't think I have enough background on capybara and related issues regarding this option :).

@tomstuart

Thanks for the pointer, I hadn’t seen that pull request. I disagree with the change — a major version bump is the perfect opportunity to make this sort of simplification at the expense of backwards compatibility — but @jnicklas merged it, so I guess it’s happening!

Please sign in to comment.