Sha256: d69463ddcad27b87e6f6dbb340f593ba194c2ff9217015d55cd69183f14025e8
Contents?: true
Size: 1.1 KB
Versions: 12
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' require 'copy_tuner_client/helper_extension' require 'copy_tuner_client/copyray' describe CopyTunerClient::HelperExtension do # rails <= 6.0.x module HashArgumentHelper def translate(key, options = {}) "Hello, #{options[:name]}" end end # rails >= 6.1.x module KeywordArgumentsHelper def translate(key, **options) "Hello, #{options[:name]}" end end class HashArgumentView include HashArgumentHelper end class KeywordArgumentsView include KeywordArgumentsHelper end CopyTunerClient::HelperExtension.hook_translation_helper(HashArgumentHelper, middleware_enabled: true) CopyTunerClient::HelperExtension.hook_translation_helper(KeywordArgumentsHelper, middleware_enabled: true) it 'works with hash argument method' do view = HashArgumentView.new expect(view.translate('some.key', name: 'World')).to eq '<!--COPYRAY some.key-->Hello, World' end it 'works with keyword argument method' do view = KeywordArgumentsView.new expect(view.translate('some.key', name: 'World')).to eq '<!--COPYRAY some.key-->Hello, World' end end
Version data entries
12 entries across 12 versions & 1 rubygems