Hi all,
On a basic negative test case, we want to ensure that when we PATCH to the wrong URL, we get a 404 error. The test looks like this (slightly modified to improve clarity):
it 'fails if using a bad id' dowhen we run this, we get an exception, ActiveRecord::RecordNotFound
It is thrown by #find not finding anything:
def updateMy question is: if we're doing RSPec testing, shouldn't the default configuration be to return a 404 HTTP response instead of a Ruby exception? Is my understanding of the paradigm broken? All the examples showing RSpec testing API's work fine - return an HTTP response - for a success (200 response), but if it fails, it throws an exception (and doesn't return an HTTP response)
By the way, I know how to correct this: as a workaround, we change the configuration in config > environments > test.rb as follows:
# Raise exceptions instead of rendering exception templates.or alternately, we can put that setting in the before method of the RSpec file, or in the rails_helper.rb under the spec directory, and again it works fine, but why wouldn't that be already set as default, given the paradigm I'm assuming of how RSpec is meant to work - that is, as much as possible with a outward-facing mentality?
Thanks,
Byron
--You received this message because you are subscribed to the Google Groups "rspec" group.To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/e216b303-0061-4e16-bf17-2f36894b77can%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/a4880d32-7dba-4e88-a65f-a25a2a8384a8n%40googlegroups.com.