R
RichardOnRails
Hi All,
I have a Search class with a :nameRE setter which may validly be
either nil or a regular expression.
I setup the unit test:
def test_002_IfNameGivenThenRE
@search.nameRE = '/\.rb$'
assert_raise(RuntimeError, @search.run)
end
search.run invokes validate which in turn invokes:
fail "'#{@nameRE.source}' is not a valid regular expression for
nameRE!" if
@nameRE && Regexp.new(@nameRE).class != Regexp
That lead to the unit test result:
2) Failure:
test_002_IfNameGivenThenRE(TestValidation) [UnitTestSearch.rb:23]:
<RuntimeError> exception expected but was
Class: <LocalJumpError>
Message: <"no block given">
So I thought I should change the assert to:
@search.nameRE = '/\.rb$'
assert_raise(LocalJumpError, @search.run)
but that gave me the test result: Only other failures but none for
the nameRE.
Did I present my question clearly? Any ideas?
Thanks in Advance,
Richard
I have a Search class with a :nameRE setter which may validly be
either nil or a regular expression.
I setup the unit test:
def test_002_IfNameGivenThenRE
@search.nameRE = '/\.rb$'
assert_raise(RuntimeError, @search.run)
end
search.run invokes validate which in turn invokes:
fail "'#{@nameRE.source}' is not a valid regular expression for
nameRE!" if
@nameRE && Regexp.new(@nameRE).class != Regexp
That lead to the unit test result:
2) Failure:
test_002_IfNameGivenThenRE(TestValidation) [UnitTestSearch.rb:23]:
<RuntimeError> exception expected but was
Class: <LocalJumpError>
Message: <"no block given">
So I thought I should change the assert to:
@search.nameRE = '/\.rb$'
assert_raise(LocalJumpError, @search.run)
but that gave me the test result: Only other failures but none for
the nameRE.
Did I present my question clearly? Any ideas?
Thanks in Advance,
Richard