Permalink
Browse files

IntegrationTests de Articulos

  • Loading branch information...
Shelvak committed Mar 4, 2012
1 parent cde13ea commit 652b5bd2015389c23fb26f27ecd0f9a65d9f1c44
Showing with 59 additions and 0 deletions.
  1. +59 −0 test/integration/articles_test.rb
@@ -0,0 +1,59 @@
require 'test_helper'
class ArticlesTest < ActionDispatch::IntegrationTest
fixtures :all
setup do
Capybara.current_driver = Capybara.javascript_driver # :selenium by default
Capybara.server_port = '54163'
Capybara.app_host = "http://localhost:54163"
page.driver.options[:resynchronize] = true
end
test 'should create an article' do
adm_login
assert_page_has_no_errors!
assert_equal prints_path, current_path
visit new_article_path
assert_page_has_no_errors!
assert_equal new_article_path, current_path
within 'form.new_article'do
fill_in Article.human_attribute_name('code'), with: '007'
fill_in Article.human_attribute_name('name'), with: 'Laminate'
fill_in Article.human_attribute_name('price'), with: '1.50'
fill_in Article.human_attribute_name('description'),
with: 'Laminate a carnet or anything'
assert_difference 'Article.count' do
click_button I18n.t(
'helpers.submit.create', model: Article.model_name.human
)
end
end
end
test 'should delete an article' do
adm_login
assert_page_has_no_errors!
assert_equal prints_path, current_path
visit articles_path
assert_page_has_no_errors!
assert_equal articles_path, current_path
within 'table.list' do
assert_difference 'Article.count', -1 do
all("input[value='Eliminar']")[1].click #El 1ro esta usado
page.driver.browser.switch_to.alert.accept
sleep(0.5)
end
end
assert_page_has_no_errors!
assert_equal articles_path, current_path
end
end

0 comments on commit 652b5bd

Please sign in to comment.