Skip to content

Commit

Permalink
Specify blog post accessors
Browse files Browse the repository at this point in the history
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 #<BlogPost id: nil>

With this specification, we've reproduced the error from the acceptance test.
  • Loading branch information
Josh Justice committed Jan 10, 2018
1 parent 8097591 commit 2072fcf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/models/blog_post_spec.rb
Expand Up @@ -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

0 comments on commit 2072fcf

Please sign in to comment.