back to

Ruby on Rails To-do List

ARCHIVED

Archived: This project has been archived. Cards can no longer be completed.

Validating Length

Stefy
Stefy completed this card.
Last updated
En > create_spec.rb 

it "displays an error when the todo list has a title less than 3 characteres" do
		expect(TodoList.count).to eq(0)

		visit "/todo_lists"
		click_link "New Todo list"
		expect(page).to have_content("New todo_list")

		fill_in "Title", with: "Hi"
		fill_in "Description", with: "This is what I'm doing today"
		click_button "Create Todo list"

		expect(page).to have_content("error")
		expect(TodoList.count).to eq(0)

		visit "/todo_lists"
		expect(page).to_not have_content("This is what I'm doing today")

	end		

To test, run:
% bin/rspec spec/features/todo_lists/create_spec.rb

To make it pass:
> todo_list.rb

validates :title, length: { minimum: 3 }
validates :description, presence: true