Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capybara rack_test driver should *not* respect data-method #184

Closed
chrisroos opened this issue Nov 5, 2010 · 6 comments
Closed

Capybara rack_test driver should *not* respect data-method #184

chrisroos opened this issue Nov 5, 2010 · 6 comments
Labels
Milestone

Comments

@chrisroos
Copy link

Kalv raised this[1] recently and I know you responded in the comments there. I'd just like to add my voice and say that I really disagree with Capybara knowing anything about Rails 3 behaviour. I can understand that it might not be desirable to just remove it (although that'd be my preference) but I'd at least like to be able to discuss it. Where's the best place for that?

Cheers, Chris

[1] http://kalv.co.uk/2010/10/27/stop-being-clever-capybara/

@jnicklas
Copy link
Collaborator

jnicklas commented Nov 5, 2010

I agree, but last time this discussion came up I was the only one objecting and a lot of people wanted this. I think that since this is now the expected behaviour we shouldn't just randomly break it. I think the sensible way would be to make this a driver configuration option for the rack-test driver, so to switch it off you'd have to do (wordy, I know):

Capybara.register_driver :rack_test do |app|
  Capybara::Driver::RackTest.new(app, :respect_data_method => false)
end

If we find that there is support for this, we'll change the default.

Thoughts?

@chrisroos
Copy link
Author

Would you be able to point me to the relevant discussions you've had in the past please?

As for your suggestion, I think that'd definitely be a start, and it would give people that were aware of the issue a chance to have their tests fail rather than magically pass. I wonder if we could take that slightly further and emit a warning if respect_data_method is set to true. Or be slightly clever and only warn if it's set to true yet rails.js is missing (not foolproof by any means I realise).

Actually, I've just had another thought. Could we introduce a specific Rails 3 driver that knows about these special attributes? I'm still not massively keen even on that idea because if someone uses that and doesn't have the stock rails.js file they're still not testing against a realistic environment.

I've created a simple test to expose one side of the problem - where another rack app uses data-method in a way that's incompatible with the Rails 3 use[1]

[1] https://github.com/chrisroos/capybara-data-method-naughtiness

@jnicklas
Copy link
Collaborator

jnicklas commented Nov 9, 2010

Well, we already have a capybara/rails file, so we could set :respect_data_method to true, and leave it false when not in a Rails environment. Care to cook up a patch for all this? (with specs please of course)

@scottmartin
Copy link

I have run into a similar situation which I submitted as an issue but then found this one already open.
#441

I ended up having to patch the Capybara::RackTest::Node.click method in order to get Capybara to ignore data-method. I too think there should be some kind of option to turn this behavior off.

@jnicklas
Copy link
Collaborator

This will be the default in Capybara 2.0

@jnicklas
Copy link
Collaborator

See also #478

radar pushed a commit to reinteractive/capybara that referenced this issue Nov 1, 2011
tomstuart referenced this issue Feb 26, 2013
This change enables the `:respect_data_method` option from the RackTest
driver for Rails projects that don't use RSpec.
@lock lock bot locked and limited conversation to collaborators Aug 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants