Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Run the same spec multiple times w/ different filters #470

@jfelchner

Description

@jfelchner

Disclaimer: This request specifically stems from doing JavaScript acceptance tests with Capybara. Although I can see use cases for other situations.

All of my applications are coded so that they work fine with JS turned off, but with JS turned on, you get a lot of nice bells and whistles to make the user experience more pleasant. Because of this, from the user's point of view, the interactions on most things are identical; however I want to test that it works both w/ and w/o JS.

What I'd like is to be able to do is set some sort of flag to tell RSpec to run the same spec twice w/ each filter set. Something like:

it 'does this same thing with and without JS enabled', :run_with => [{:js => true}, {:js => false}] do
    # stuff here
end

I know this can be accomplished with shared examples but the resulting code is not very elegant.

It could additionally be used if you wanted to test w/o JS (Rack test) w/ JS on Firefox (Selenium) and w/ JS on Webkit (capybara-webkit) like this:

it 'does this same thing with and without JS enabled', :run_with => [{:js => false}, {:driver => :selenium}, {:driver => :webkit}] do
    # stuff here
end

I'm also envisioning a way to use custom filters to specify the run_with options so it's not quite so verbose such as:

it 'does this same thing with and without JS enabled', :run_with_all_drivers => true do
    # stuff here
end

Thoughts? I looked through the docs and the code and didn't see a way to currently do this with filters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions