Skip to content

Instantly share code, notes, and snippets.

@descovi
Created February 22, 2018 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save descovi/d38d23b29aa78845176c97fd3f596ecd to your computer and use it in GitHub Desktop.
Save descovi/d38d23b29aa78845176c97fd3f596ecd to your computer and use it in GitHub Desktop.
Esempio di uso del metodo stub all'interno di un test di un helper.
# test/helpers/title_helper_test.rb
require 'test_helper'
class TitleHelperTest < ActionView::TestCase
test "return title with controller name when title content is nil" do
stub :controller_name, 'businesses' do
result = set_title_tag title_content: nil, from_layout: 'Admin Area'
assert_equal 'Clienti - Admin Area - iPY', result
end
end
end
# N.B.
# Ricordati di inserire
# require 'minitest/mock' all'interno di test_helper.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment