April 2016
Intermediate to advanced
222 pages
4h 30m
English
We've been using RSpec's eq matcher to make assertions so far. We don't absolutely need this or any of RSpec's other matchers. We could use standard Ruby or define our own helper methods, like so:
describe 'no matchers' do
it "valid? returns false for incomplete address" do
expected = AddressValidator.valid?(address)
if expected != false
# RSpec's fail method allows us to manually fail an example
fail "Expected #{expected} to have value of false"
end
end
endThere are a few problems with this approach. First, it is clumsy to write and read. Second, without a standard way of handling assertions, we're likely to wind up with a bunch of variations on the code above, making our output confusing. Finally, it is very easy to make mistakes with ...
Read now
Unlock full access