views:

34

answers:

1

Hi guys, I'm using rspec to test a code that may fail depending on the change of a site structure (the external influence I mentioned). I would like to write an example that involves "should raise an error" but I'm not sure if rspec is the right tool to test code in such situations. Could someone point me in some direction?

Thanks in advance

+1  A: 

You could write custom matchers

Something like :

site.should_have_valid_structure

Spec::Matchers.define :have_structure
  match do |actual|
    actual.structure == Site::VALID_STRUCTURE
  end
end
Erwan
Hi Erwan, thanks for the help. I think I'm gonna use mechanize to test whether something in a page is still present in the site or not (in this case raising an error). I liked your idea but I'm actually testing minor differences in a site, like a div that is no more , things like that.
thiagobrandam