On 17/03/2008, Kyle Hargraves <[EMAIL PROTECTED]> wrote:
>
> We discussed this in a ticket on lighthouse, and I ended up writing a
> workalike that's sitting atop hpricot. It's not quite identical, but
> generally close enough and so far does everything I've needed:
>
> http://github.com/pd/rspec_hpricot_matchers
>
> Patches and/or suggestions welcome if you need anything else out of it
>
> Kyle
Hi Kyle
Really impressed with that! Seems to be working ok in our app, only
starting to use it though. Here's how I got it working in Rails:
git clone into RAILS_ROOT/lib
However you are using a require that depends on rspec_hpricot_matchers/lib
being in the load path, so for now I added this to spec_helper:
rspec_hpricot_matcher_lib_path = File.expand_path(
File.join(RAILS_ROOT, "/lib/rspec_hpricot_matchers/lib"))
$:.unshift(rspec_hpricot_matcher_lib_path) unless
$:.include?(rspec_hpricot_matcher_lib_path)
I could have changed the line:
require 'rspec_hpricot_matchers/have_tag'
to something like (untested):
File.expand_path(
File.join(File.dirname(__FILE__), "/rspec_hpricot_matchers/lib"))
so it would work from any location - but I wasn't sure how to get the patch
back from git.
I also found it's pretty easy to replace the RSpec assert_select wrapper:
module Spec::Rails
module Matchers
undef_method :have_tag, :with_tag, :without_tag, :with_encoded
end
module Example
class RailsExampleGroup
include RspecHpricotMatchers
end
end
end
Already rolling this out across the developers here, everyone seems pretty
positive about it.
Any chance this will make it into RSpec, David?
Ashley
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users