[rspec-users] RSpec newb - why is my negative test not passing?

Rick DeNatale rick.denatale at gmail.com
Sat May 8 12:43:14 EDT 2010


On Thu, May 6, 2010 at 9:03 PM, Jferg <johngferguson at gmail.com> wrote:
> Why won't this test work?
>
> I am trying to use RSpec to drive a negative test where my code will
> throw an exception which it does however, the test does not pass.  It
> fails due to my exception.  However, I am using should
> raise_exception:
> -----------------------
>
> describe "Making non-existent url tiny" do
>
>  it "should raise exception" do
>    url = "tttttt.dddddd"
>    exception_new = Exception.new "Test URL Error"
>
> TinyUrlService.should_receive(:get).with(url).and_raise(exception_new)
>
    lambda {TinyUrlService.make_tiny(url)}.should raise_exception
>  end
> end


-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale


More information about the rspec-users mailing list