sorry for my english, I have a problem while testing views with capybara. Capybara can't view the elements validated with cancan, I have this in my tests, to simulate that the user has permissions for all.
before(:each) do
permission = FactoryGirl.create(:permission)
role = FactoryGirl.build(:role)
role.permissions << permission
role.save
user = FactoryGirl.create(:user, :role_id => role.id)
sign_in user
end
and this in my views...
= link_to t('actions.new'), new_user_path if can?(:create, User)
But my tests don't pass
Failure/Error: click_link t('actions.new')
Capybara::ElementNotFound:
no link with title, id or text 'Crear nuev@' found
# (eval):2:in `click_link'
# ./spec/views/users_spec.rb:53:in `block (3 levels) in <top (required)>'
I don't understand, my controllers hasn't problems.
Some help?
Thanks in advance, Regards...