[Rspec-devel] Adding spec helpers in rails

Jay Levitt lists-rspec at shopwatch.org
Mon Aug 28 21:05:56 EDT 2006

Using rspec 0.5.13, I had a bunch of helpers defined like so at the end 
of spec_helper.rb:

class Spec::Runner::Context 
  def fields_should_start_empty(obj, *fields)
    fields.flatten.each do |f|
      specify "should have an empty #{f} field" do
        eval(obj.id2name + ".#{f}.should.be.nil")

In 0.6.2, this doesn't seem to work.  I've tried adding them instead to

module Spec
  module Runner
    class Context
      module InstanceMethods

but that didn't work.  I also tried simply defining them in SpecTestCase 
the way setup, teardown and run are, but no matter where I try defining 
them, I get:

`call': undefined method `fields_should_start_empty' for 
#<Module:0x4fca630> (NoMethodError)

Any tips?

Jay Levitt

More information about the Rspec-devel mailing list