From 2072fcfe822ee8e2f22c57d18766fc6e5d07ed80 Mon Sep 17 00:00:00 2001 From: Josh Justice Date: Tue, 14 Jun 2016 12:30:58 -0400 Subject: [PATCH] Specify blog post accessors Once again, rather than fixing the acceptance error directly, we drop down to the model test level to reproduce the error. We specify that we want a `title` field--as well as a `body` field, since we know we'll need that and it feels safe to go ahead and add it. The behavior we want is that we want those fields to be `nil` for a new model instance. Inner red: undefined method `title' for # With this specification, we've reproduced the error from the acceptance test. --- spec/models/blog_post_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/models/blog_post_spec.rb b/spec/models/blog_post_spec.rb index 56cd315..dbe10ec 100644 --- a/spec/models/blog_post_spec.rb +++ b/spec/models/blog_post_spec.rb @@ -6,4 +6,11 @@ expect{ blog_post = BlogPost.new }.not_to raise_error end + it "defaults fields to nil" do + blog_post = BlogPost.new + + expect(blog_post.title).to be_nil + expect(blog_post.body).to be_nil + end + end