How do I test that a given helper method only takes exactly one argument?
I thought of doing this:
describe "#textile" do
it "should take only one argument" do
textile().should raise_error
end
end
but that seems to still break the test, with the error wrong number of arguments 0 for 1.
Regardless of why you’d want to test this, here’s one way to write it:
Note that you could leave off the
ArgumentErrorand just say that these invocations should or should not raise an error, but by specifically saying they should or should not raise ArgumentError, you’re isolating the case that you’re trying to specify.textile("foo")may raise some other kind of exception but will still pass the second example.