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

Already on GitHub? Sign in to your account

Is Capybara::DSL supposed to be getting mixed into controller specs? #813

Closed
jdelStrother opened this Issue Aug 26, 2013 · 9 comments

Comments

Projects
None yet
5 participants

Hi there - I thought the capybara DSL methods like visit & co were supposed to only appear in feature specs. They're currently still mixed into controller specs - https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/vendor/capybara.rb#L14 - is this intentional?

I haven't yet had chance to dig in & verify this, but I believe it's causing a bunch of selenium driver code to execute in after-filters (via https://github.com/jnicklas/capybara/blob/master/lib/capybara/rspec.rb#L20).

In addition, Capybara already mixes in the DSL methods to feature specs, so they're getting imported twice. (again, in https://github.com/jnicklas/capybara/blob/master/lib/capybara/rspec.rb). Not found any negative effect of doing this, it just confused me for a while when I was trying to track down why Capybara::DSL was appearing in my controller specs

Owner

JonRowe commented Aug 26, 2013

@alindeman has the most experience with this, so... ping! :)

Owner

samphippen commented Aug 26, 2013

Inserting some opinions: looking at the commits it feels to me like this code was originally there to make controller specs act like full integration tests, hence grabbing capybara. Hence pulling in capybara in controller specs feels sane to me.

Owner

JonRowe commented Aug 26, 2013

I suspect it's now a question of "is this expected continuing behaviour"

Contributor

alindeman commented Oct 27, 2013

Hmm, we should consider this before 3.0.0. Offhand, it doesn't seem like many of the methods in Capybara::DSL makes sense in controller specs, but I need to make sure I understand everything that's coming in fully first. Updated milestone.

This is perhaps something that could be improved from Capybara's end (@jnicklas?) , but just as a data point, including Capybara::DSL can add 80-100ms for every example in spec/controllers.
For example, if rspec runs a feature spec first, (firing up Firefox or Chrome), then every controller spec that's run after that will try to reset the browser session, which is a relatively slow operation. It's tripling the time taken to run my controller specs.

Contributor

alindeman commented Dec 9, 2013

I think it makes sense to nuke Capybara::DSL from controller specs in 3.0.0. It might have been a mistake to include it in the first place, and we have a chance to correct it now. I can't imagine that most folks use Capybara::DSL in their controller spec, and if the performance impact is high, I'd definitely like to take this opportunity to remove it.

Any objections?

Owner

myronmarston commented Dec 9, 2013

Do it. If folks want it included, they can include it themselves, right?

Contributor

alindeman commented Dec 9, 2013

Do it. If folks want it included, they can include it themselves, right?

Definitely.

@alindeman alindeman closed this in 34483cc Dec 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment