[rspec-users] Can Rspec do module spec? What if module uses test data?

Shaker flyeminent at hotmail.com
Tue Aug 21 23:44:40 EDT 2007

Dear fellows:
    I am currently working on writing specs on some ruby modules(e.g.
myModule). At first I try to use script/generate to generate rspec_module,
but it failed. :-(
    Later I manually created a file (e.g. named myModule_spec.rb) and put
the 'require ....spec_helper.rb' as the first line of code followed by
'describe' block. Luckily, it seemed to be working. But it was not likely to
be a logical way to generate module specs.
    Question 1:Is there any better way of creating module spec??:confused:
    Anyway, I started to write method specs in these manually created module
specs, and I found another problem. Module specs do not support 'fixtures'.
This means that if you test some methods which modify test data in your
module specs, that data won't be restored after you finish running each
spec. In other words, all the modules specs actually share a copy of test
data. This will cause some module specs to fail if other modules do modified
the shared data beforehand.
    Question 2:What should I do to resolve this problem, making module specs
access test data independently? :confused:
View this message in context: http://www.nabble.com/Can-Rspec-do-module-spec--What-if-module-uses-test-data--tf4309226.html#a12267615
Sent from the rspec-users mailing list archive at Nabble.com.

More information about the rspec-users mailing list