Permalink
Browse files

Specify model should be instantiable

The previous error wasn't enough for us to want to create a `BlogPost` model test, because it was just a structural error: there was no `BlogPost` class. But now we have an error that a `BlogPost` can't be instantiated, which is a logic error: and that means we should create a model test. It's not strictly a unit test because it's not isolated from the database, but it _is_ following the outside-in-testing principle of stepping down from the acceptance test to the test of an individual class.

We reproduce the error that occurred in the acceptance test in the model test: the error of being unable to find the `blog_posts` table when creating a new instance.

Inner red: PG::UndefinedTable: ERROR:  relation "blog_posts" does not exist
  • Loading branch information...
CodingItWrong committed Jun 14, 2016
1 parent 259c646 commit 2dbc3e6df70403f5f1d098603f746a2e9e42186f
Showing with 9 additions and 0 deletions.
  1. +9 −0 spec/models/blog_post_spec.rb
@@ -0,0 +1,9 @@
require 'rails_helper'
describe BlogPost do
it "is instantiable" do
expect{ blog_post = BlogPost.new }.not_to raise_error
end
end

0 comments on commit 2dbc3e6

Please sign in to comment.