Skip to content

Commit

Permalink
Criando e Testando os links (mostrar, editar)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Pires authored and Jackson Pires committed Feb 21, 2018
1 parent 7fbb357 commit 83b7fd8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tdd_app/app/views/customers/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% end %>


<h1>Editando um Cliente</h1>
<h1>Editando Cliente</h1>

<%= form_for @customer do |f| %>
<%= f.label :name %>
Expand Down
25 changes: 18 additions & 7 deletions tdd_app/app/views/customers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@
<% end %>

<h1>Listando Clientes</h1>
<ul>
<% @customers.each do |customer| %>
<li>
<%= customer.name %>
</li>
<% end %>
</ul>
<table>
<thead>
<tr>
<td>Nome</td>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<% @customers.each do |customer| %>
<tr>
<td><%= customer.name %></td>
<td><%= link_to "Mostrar", customer_path(customer) %></td>
<td><%= link_to "Editar", edit_customer_path(customer) %></td>
</tr>
<% end %>
</tbody>
</table>

<%= link_to "Novo Cliente", new_customer_path %>
2 changes: 2 additions & 0 deletions tdd_app/app/views/customers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<p><%= flash[:notice] %></p>
<% end %>

<h1>Mostrando Cliente</h1>

<p>
<strong>Nome</strong>
<%= @customer.name %>
Expand Down
28 changes: 28 additions & 0 deletions tdd_app/spec/features/customers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 83b7fd8

Please sign in to comment.