[rspec-users] Migrating spec_helper with modifications

David Chelimsky dchelimsky at gmail.com
Mon Apr 30 15:31:12 EDT 2007


On 4/30/07, Chris Hoffman <chris.c.hoffman at gmail.com> wrote:
> Hello,
>
> After moving into the HEAD of rspec, I am greeted with a mountain of errors,
> which I expected, due to my specs not being migrated.
>
> I use hpricot for a lot of my view tests, as it is extremely simple to
> traverse the DOM with it.  I used to include HpricotSpecHelper in
> spec_helper.rb, like so:
>
> require 'hpricot_spec_helper'
>
> module Spec
>   module Rails
>     module Runner
>       class EvalContext < Test::Unit::TestCase
>         include HpricotSpecHelper
>       end
>     end
>    end
> end
>
> However, I am now getting errors that indicate that this inclusion no longer
> does what I want.  Is there a different class in which I should be including
> this module?
>
> The errors I'm getting are of the following type:
>
> undefined method `elements' for
> #<#<Class:0xb6f12a14>:0xb6eb8ff0>
>
> element(s) is a top-level method, so I would do things like the following:
>
> element("p").inner_text.should == "Hello World"
>
> The following link shows HpricotSpecHelper (with syntax highlighting):
>
> http://src.chrishoffman.net/lib/hpricot_spec_helper.rb
>
> Please let me know if I am not being clear with my difficulty.  Thanks for
> the help.

The easy way to include modules now is like this:

Spec::Runner.configure do |config|
  config.include SomeModule
end

That gets included in every behaviour.

That help?

>
> -Chris
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list