Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. feature "Manage todos" do
  2. scenario "create a new todo" do
  3. visit root_path
  4. fill_in 'Email address', with: 'junk@snap2web.com'
  5. click_button 'Sign in'
  6. click_link('Add a new todo')
  7. fill_in 'Description', with: 'Buy some milk'
  8. click_button 'Create todo'
  9. expect(page).to have_css 'li.todo', text: 'Buy some Milk'
  10. end
  11. end
  12.  
  13. 1) Manage todos create a new todo
  14. Failure/Error: click_button 'Create todo'
  15. ActionController::RoutingError:
  16. No route matches [POST] "/todos/new"
  17.  
  18. Todos::Application.routes.draw do
  19. root 'high_voltage/pages#show', id: 'homepage'
  20. resource :session, only: [:create]
  21. resources :todos
  22. end
  23.  
  24. Prefix Verb URI Pattern Controller#Action
  25. root GET / high_voltage/pages#show {:id=>"homepage"}
  26. session POST /session(.:format) sessions#create
  27. todos GET /todos(.:format) todos#index
  28. POST /todos(.:format) todos#create
  29. new_todo GET /todos/new(.:format) todos#new
  30. edit_todo GET /todos/:id/edit(.:format) todos#edit
  31. todo GET /todos/:id(.:format) todos#show
  32. PATCH /todos/:id(.:format) todos#update
  33. PUT /todos/:id(.:format) todos#update
  34. DELETE /todos/:id(.:format) todos#destroy
  35. page GET /pages/*id high_voltage/pages#show
  36.  
  37. $ cat app/controllers/todos_controller.rb
  38. class TodosController < ApplicationController
  39. def index
  40. end
  41.  
  42. def new
  43. end
  44.  
  45. end
  46.  
  47. $ cat app/views/todos/new.html.erb
  48. Add a new todo
  49. <%= form_for :todo do |f| %>
  50. <%= f.label :description %>
  51. <%= f.text_field :description %>
  52. <%= f.submit 'Create todo' %>
  53. <% end %>
  54.  
  55. <%= form_for Todo.new do |f| %>
  56.  
  57. <div class="col-sm-8 contact-form">
  58. <form id="contact" method="post" class="form" role="form">
  59. <div class="row">
  60.  
  61. <%= form_for @contact, url: contacts_path do |f| %>
  62.  
  63. <%= form_for :todo do, url: todos_path |f| %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement