spin icon indicating copy to clipboard operation
spin copied to clipboard

Running single tests cases

Open jstorimer opened this issue 13 years ago • 13 comments

spin push test/unit/product_test.rb -n /testing_price/

jstorimer avatar Nov 07 '11 12:11 jstorimer

I was able to hack something together to make this work with test/unit. I'll push it later tonight.

Anyone know if RSpec supports this kind of behaviour?

jstorimer avatar Nov 09 '11 01:11 jstorimer

RSpec supports sending a single file.

Typically the specs have require "spec_helper" at the top. Or have the correct requires at the top of the file to run the individual spec.

spin push spec/models/product_spec.rb

vizjerai avatar Nov 14 '11 18:11 vizjerai

Looks like RSpec supports this as either a line number (spec foo.rb:42 / spec foo.rb --line 42) or a regex matching the example name (spec foo.rb --example bar / spec foo.rb -e bar).

  • https://www.relishapp.com/rspec/rspec-core/docs/command-line/example-option
  • https://www.relishapp.com/rspec/rspec-core/docs/command-line/line-number-option
  • https://www.relishapp.com/rspec/rspec-core/docs/command-line/line-number-appended-to-file-path

dstrelau avatar Nov 16 '11 13:11 dstrelau

I created a branch that makes it possible for RSpec users to run a single example by adding a line number.

The problem is that I'm not sure if this is the right way to go - it's very Rspec-centric, and as such, it does not enable any future extending (for TestUnit/Shoulda user, for example).

I have tried several other ways how to enable this (like not checking if the files exist, etc), but they all ended up being very complex and just impractical.

What do you think?

maprihoda avatar Nov 30 '11 08:11 maprihoda

What if all options are blindly passed to the tests?

matthuhiggins avatar Dec 25 '11 22:12 matthuhiggins

@matthuhiggins Can you please provide some example of what you mean?

maprihoda avatar Dec 26 '11 14:12 maprihoda

In test/unit, autorun is enabled by default. It is implemented here: http://ruby-doc.org/stdlib-1.9.3/libdoc/test/unit/rdoc/Test/Unit/Runner.html#method-c-autorun. ARGV is passed in, where the "-n test_name" logic takes place. I was thinking that "spin push" could pass all those arguments to "spin serve", and spin serve would set ARGV.

matthuhiggins avatar Dec 27 '11 01:12 matthuhiggins

@matthuhiggins that was the hack that I mentioned a while back, it does indeed work, but I haven't implemented the logic to actually pass the arguments yet. Anyone else tried?

jstorimer avatar Dec 27 '11 13:12 jstorimer

I changed just the line 199 to socket.puts ARGV and all the rspec tests ran ok!

maprihoda avatar Dec 28 '11 13:12 maprihoda

@maprihoda patch?

jstorimer avatar Jan 02 '12 05:01 jstorimer

Unfortunately, with socket.puts ARGV, I'm getting a Broken pipe (Errno::EPIPE) when trying to push two or more files. Also, at this time, I'm not sure how to pass the arguments when using testunit (-n test_name just does not seem to work).

maprihoda avatar Jan 02 '12 16:01 maprihoda

There is a chance that this functionality will be?

accessd avatar Aug 22 '12 08:08 accessd

you can take a look at zeus, the basic implementation + run-by-line-number support is there

grosser avatar Aug 22 '12 15:08 grosser