Sha256: b6fce0253207fd61c6aeca53c16d395a88459920f19a78bcbb49cfeeab1e6773
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true require 'test_helper' class BuoysBuoyTest < ActiveSupport::TestCase setup do @view_context = if ActionView::Base.respond_to?(:empty) ActionView::Base.empty else ActionView::Base.new # Rails 5.2 or lower end Buoys::Loader.load_buoys_files end test 'can interpret multiple `link`s in one buoy block with argument' do links = Buoys::Buoy.new(@view_context, :help, true).links assert_equal links.size, 2 assert_equal links[0].text, 'help' assert_equal links[0].url, 'https://example.com/help' assert_equal links[1].text, 'usage' assert_equal links[1].url, 'https://example.com/help/usage' links = Buoys::Buoy.new(@view_context, :help, false).links assert_equal links[0].url, 'http://example.com/help' assert_equal links[1].url, 'http://example.com/help/usage' end test 'can use :symbol as link name' do links = Buoys::Buoy.new(@view_context, :account).links assert_equal links[0].text, 'Account' assert_equal links[0].url, 'http://example.com/account' end test 'delegate unknown methods to view context' do def @view_context.hello(arg, kwarg:, &block) [arg, kwarg, block] end arg, kwarg, block = Buoys::Buoy.new(@view_context, :account).hello('hello', kwarg: ',') { 'world' } assert_equal arg, 'hello' assert_equal kwarg, ',' assert_equal block.call, 'world' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
buoys-2.1.0 | test/buoys_buoy_test.rb |
buoys-2.0.2 | test/buoys_buoy_test.rb |