I want to write a test using Rspec and Capybara.
I have a Post
model and I want to add a draft
attribute to it. If the user checks that field the post is saved as draft (draft = true
). Only posts that have he attribute draft = false
will show in the post index page. Posts with draft = true
will only show in the page of the user who created that post.
I've never made a Rspec + Capybara test in my life. So I was wondering if someone could tell me how to start or give me an example. Thanks in advance!
schema.rb:
create_table "posts", :force => true do |t|
t.string "title"
t.string "content"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "comments_count", :default => 0, :null => false
t.datetime "published_at"
t.boolean "draft", :default => false
end
(By the way, do I need to post the model, controller or view pages?)