Forum: Ruby Parameterising RSpec tests

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3dc06f587d1ff4c7366b102bfda9204?d=identicon&s=25 David Mitchell (Guest)
on 2008-10-10 08:40
(Received via mailing list)
Hello everyone,

I'm trying to work out how to use RSpec to bundle up some existing
test cases (created with a tool that is so nasty it defies
description).  For reasons that I won't go into, I'm stuck with using
the test cases that have been generated with this (non-Ruby) tool, but
I've managed to wrap the execution of individual test cases in a Ruby
class that makes them somewhat easier to work with:

class Test
    def execute_test(test_id)
        ...
    end

    def test_passed?
        ...
    end
end

All this works OK now.

What I'd like to have is something like:

describe 'The shakeout test suite' do
    it 'should complete test case 47 successfully'
    it 'should complete test case 173 successfully'
    it 'should complete test case 957 successfully'
end

then have

describe 'should complete test case #{some_number} successfully' do
   m = Test.new()
   m.execute_test(#{some_number})
   ...
end


Is there some elegant way to parameterise RSpec test "describes" in this
manner?

Regards

Dave M.
This topic is locked and can not be replied to.