jstorimer/spin

Running single tests cases

Opened this issue · 13 comments

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

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?

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

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).

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?

What if all options are blindly passed to the tests?

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

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 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?

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

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).

There is a chance that this functionality will be?

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