0

Is there a way to just output the string in the describe and it's block and not run the actual spec. We're thinking of migrating our task list to these strings

describe "second group task001" do
  it "second example in second group" do
    #some really long task that shouldn't be run
    FactoryGirl.create(:really_long_factory)
  end
end

outputs:

rspec this_spec.rb -fd

second group task001
  second example in second group

thx

timpone
  • 19,235
  • 36
  • 121
  • 211

3 Answers3

0

The alternative method xit will do what you want. The various alternatives for treating "pending" examples like this are covered at https://www.relishapp.com/rspec/rspec-core/v/2-3/docs/pending/pending-examples.

Peter Alfvin
  • 28,599
  • 8
  • 68
  • 106
  • this looks good - but is there any way to tell rspec from the command line it -> xit? – timpone Jun 26 '13 at 00:53
  • Are you asking if you can disable all tests but still output the text? – Peter Alfvin Jun 26 '13 at 00:55
  • You can use inclusion or exclusion filters (the --example command line option) to indicate which tests to run, but they won't output anything for tests not run. I guess I don't quite understand your situation/need. Don't you want to incrementally modify your suite as you implement the tasks? – Peter Alfvin Jun 26 '13 at 01:07
  • So, we have a suite that covers some of the code and the app actually covers the requirements doc. What I'd like to be able to do is embed status information in the describe text. I'd just run the actual specs but it takes like 12 - 15 minutes currently (there's a couple hundred specs). In other words have current `describe "test creating new order" do ....` -> `describe "task001 creates new order with all options" do` and be able to just output that text without running the actual spec. We have two devs working on it so I want see progress. – timpone Jun 26 '13 at 01:12
  • Check out http://stackoverflow.com/questions/5918606/disable-a-group-of-tests-in-rspec for more discussion. – Peter Alfvin Jun 26 '13 at 01:23
0

You could create a pending example using the techniques described here or use filters to limit the runs as shown here

Jay Truluck
  • 1,509
  • 10
  • 17
  • so they won't be pending but I just want to dump the strings in the describe blocks without actually running the code. – timpone Jun 26 '13 at 00:46
  • I think it is a bit confusing why this would not be pending if you do not want to run the code? could you elaborate a bit more? – Jay Truluck Jun 26 '13 at 00:55
  • right, I agree. I have adopted some code which doesn't have full test coverage and the coverage it has is not very good. I'd like to be able to add info to the strings such as `task001` so that we can correlate this to the burn down chart. Running the whole suite takes like 12 minutes (a separate issue) so would like to be able to see at a glance what our specs currently cover in the requirements doc. I have an Excel doc now but seems like it could more easily be in the actual spec. – timpone Jun 26 '13 at 01:00
0

Use pending:

irb(main):012:0> describe "second group task001" do
irb(main):013:1*   pending "second example in second group" do
irb(main):014:2*     #some really long task that shouldn't be run
irb(main):015:2*   end
irb(main):016:1> end
=> RSpec::Core::ExampleGroup::Nested_2
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • Thx but I'd really like to be able to switch from run code in that example to just saying output the describe / it string. – timpone Jun 26 '13 at 01:06