Skip to content

Commit

Permalink
Move the RackTest driver override to capybara/rails
Browse files Browse the repository at this point in the history
This change enables the `:respect_data_method` option from the RackTest
driver for Rails projects that don't use RSpec.
  • Loading branch information
carlosantoniodasilva committed Nov 15, 2012
1 parent 6446eac commit 9c1dd62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 8 additions & 0 deletions 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
Expand Down
6 changes: 5 additions & 1 deletion lib/capybara/rails.rb
Expand Up @@ -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
Expand All @@ -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
5 changes: 0 additions & 5 deletions lib/capybara/rspec.rb
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about #478?

@carlosantoniodasilva
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.