Is there a way to tell Rspec not to run javascript tests? (or simply a way to tag tests in Rspec)?

859 views
Skip to first unread message

David Kahn

unread,
Dec 17, 2010, 4:04:49 PM12/17/10
to ste...@googlegroups.com
I am using this to denote if a test should run in Selenium via Steak:

scenario "As a practice user I can create a new practice member from the home page", :js => true do

.. since these tests take *forever* compared to non-js tests, is there a way to tell Rspec not to run them? In Cucumber I was using the @javascript tag and then I would just run them with:

cucumber -f pretty -t ~@javascript

I am pretty new to rspec so dont know if I can use some sort of tagging system.

David

Jaime Iniesta

unread,
Dec 17, 2010, 4:54:57 PM12/17/10
to ste...@googlegroups.com
El viernes 17 de diciembre de 2010, David Kahn
<d...@structuralartistry.com> escribió:

Hi David, this is not exactly what you're asking, but on this demo
we've got an example on how to tag scenarios to handle them in
different ways. In this case we wanted to run the ones marked with :js
=> true on Selenium, so using a helper we specify a change of the
driver with before and after.

https://github.com/jaimeiniesta/demo_steak_capybara

David Kahn

unread,
Dec 17, 2010, 5:13:55 PM12/17/10
to ste...@googlegroups.com

Hi Jaime, thanks.... I just pulled the project but dont see anything regarding tags in the project or the readme, can you point me to where to look specifically?

Jaime Iniesta

unread,
Dec 17, 2010, 5:32:53 PM12/17/10
to ste...@googlegroups.com

Look at the readme, where it talks about Selenium and javascript.rb

Not exactly tags, just talking about a way to specify options on scenarios.

David Kahn

unread,
Dec 17, 2010, 5:51:39 PM12/17/10
to ste...@googlegroups.com

I see.... this is what I have been using, but there is no way to actually tell rspec to not run those tests marked js? See, when I am developing unless working specifically on something in js or on the ui, I want to run the non-js tests as running the whole suite with the js tests is not practical. No worries if this cant be done yet, as it is I am having a lot of success with Steak, then at some point I will try to find a way or hack :)

Luismi Cavallé

unread,
Dec 17, 2010, 6:01:09 PM12/17/10
to ste...@googlegroups.com
I'm not sure if this is released or just in rspec edge, but there's a new --tag option for the `rspec` command line that adds the functionality that you're asking for. 

You can investigate further here [1] or ask in the rspec mailing list.


Cheers,

-- Luismi

David Kahn

unread,
Dec 17, 2010, 6:47:00 PM12/17/10
to ste...@googlegroups.com
On Fri, Dec 17, 2010 at 5:01 PM, Luismi Cavallé <lmca...@gmail.com> wrote:
I'm not sure if this is released or just in rspec edge, but there's a new --tag option for the `rspec` command line that adds the functionality that you're asking for. 

You can investigate further here [1] or ask in the rspec mailing list.


Thanks, that's going to be very useful!
 

David Kahn

unread,
Dec 18, 2010, 3:03:45 PM12/18/10
to ste...@googlegroups.com
On Fri, Dec 17, 2010 at 5:47 PM, David Kahn <d...@structuralartistry.com> wrote:


On Fri, Dec 17, 2010 at 5:01 PM, Luismi Cavallé <lmca...@gmail.com> wrote:
I'm not sure if this is released or just in rspec edge, but there's a new --tag option for the `rspec` command line that adds the functionality that you're asking for. 

You can investigate further here [1] or ask in the rspec mailing list.


Thanks, that's going to be very useful!

I just tried it out and this feature has been implemented on rspec --- if you 'rspec -h' in terminal you see it:

-t, --tag TAG[:VALUE]            Run examples with the specified tag
                                              To exclude examples, add ~ before the tag (e.g. ~slow)
                                              (TAG is always converted to a symbol)

So....

Given a long running test I want to exclude (travel_card tag added):

  context "Verify Travel Card Javascript", :js => true, :travel_card => true do
     ...
  end


So I can run: "rspec spec -t ~travel_card" and this context does not run.

Also running "rspec spec -t ~js" gives me all my non-js tests....

Awesome!




 
Reply all
Reply to author
Forward
0 new messages