you have to wrap that in a lambda

lambda { PrimeService.new.is_prime -2 }.assert_throws System::Exception

you can't assert code that has already been executed. Basically anything
that asserts exceptions needs to be able to execute the code later because,
and this is true for any language, in  the end the code looks a little like
this

class Proc

def assert_throws( expected_exception)
  begin
     self.call
  rescue expected_exception
     return true
  end
  return false
end

end


---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Tue, Jul 7, 2009 at 8:27 PM, Mohammad Azam <[email protected]> wrote:

> Hi,
>
> I want to say that whatever exception is thrown just pass the test.
>
> class When_a_negative_number_is_passed_to_the_prime_service < TestCase
>
> def test_should_throw_an_exception
>
> primeService = PrimeService.new
> primeService.IsPrime(-2)
> assert_throws System::Exception
>
> end
>
> end
>
> The exception thrown from the C# side is ArgumentException
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to