From 83b7fd8c69562c34f9d3a0a0e264fce376df9c0e Mon Sep 17 00:00:00 2001 From: Jackson Pires Date: Tue, 20 Feb 2018 21:29:55 -0300 Subject: [PATCH] Criando e Testando os links (mostrar, editar) --- tdd_app/app/views/customers/edit.html.erb | 2 +- tdd_app/app/views/customers/index.html.erb | 25 +++++++++++++------ tdd_app/app/views/customers/show.html.erb | 2 ++ tdd_app/spec/features/customers_spec.rb | 28 ++++++++++++++++++++++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/tdd_app/app/views/customers/edit.html.erb b/tdd_app/app/views/customers/edit.html.erb index c6f8909..458aa56 100644 --- a/tdd_app/app/views/customers/edit.html.erb +++ b/tdd_app/app/views/customers/edit.html.erb @@ -8,7 +8,7 @@ <% end %> -

Editando um Cliente

+

Editando Cliente

<%= form_for @customer do |f| %> <%= f.label :name %> diff --git a/tdd_app/app/views/customers/index.html.erb b/tdd_app/app/views/customers/index.html.erb index 56ce166..49ebd3b 100644 --- a/tdd_app/app/views/customers/index.html.erb +++ b/tdd_app/app/views/customers/index.html.erb @@ -3,12 +3,23 @@ <% end %>

Listando Clientes

- + + + + + + + + + + <% @customers.each do |customer| %> + + + + + + <% end %> + +
Nome
<%= customer.name %><%= link_to "Mostrar", customer_path(customer) %><%= link_to "Editar", edit_customer_path(customer) %>
<%= link_to "Novo Cliente", new_customer_path %> diff --git a/tdd_app/app/views/customers/show.html.erb b/tdd_app/app/views/customers/show.html.erb index 60039ee..00930a6 100644 --- a/tdd_app/app/views/customers/show.html.erb +++ b/tdd_app/app/views/customers/show.html.erb @@ -2,6 +2,8 @@

<%= flash[:notice] %>

<% end %> +

Mostrando Cliente

+

Nome <%= @customer.name %> diff --git a/tdd_app/spec/features/customers_spec.rb b/tdd_app/spec/features/customers_spec.rb index c6bd51d..9f6deed 100644 --- a/tdd_app/spec/features/customers_spec.rb +++ b/tdd_app/spec/features/customers_spec.rb @@ -93,6 +93,34 @@ expect(page).to have_content('Cliente atualizado com sucesso!') expect(page).to have_content(new_name) end + + scenario 'Clica no link Mostrar da Index' do + customer = Customer.create!( + name: Faker::Name.name, + email: Faker::Internet.email, + phone: Faker::PhoneNumber.phone_number, + smoker: ['S','N'].sample, + avatar: "#{Rails.root}/spec/fixtures/avatar.png" + ) + + visit(customers_path) + find(:xpath, "/html/body/table/tbody/tr[1]/td[2]/a").click + expect(page).to have_content("Mostrando Cliente") + end + + scenario 'Clica no link Editar da Index' do + customer = Customer.create!( + name: Faker::Name.name, + email: Faker::Internet.email, + phone: Faker::PhoneNumber.phone_number, + smoker: ['S','N'].sample, + avatar: "#{Rails.root}/spec/fixtures/avatar.png" + ) + + visit(customers_path) + find(:xpath, "/html/body/table/tbody/tr[1]/td[3]/a").click + expect(page).to have_content("Editando Cliente") + end end