How to use initialize method of Plugins Package

Best Inspec_ruby code snippet using Plugins.initialize

initializer_test.rb

Source:initializer_test.rb Github

copy

Full Screen

1require "#{File.dirname(__FILE__)}/abstract_unit"2require 'initializer'3class ConfigurationMock < Rails::Configuration4 attr_reader :environment_path5 def initialize(envpath)6 super()7 @environment_path = envpath8 end9end10class Initializer_load_environment_Test < Test::Unit::TestCase11 def test_load_environment_with_constant12 config = ConfigurationMock.new("#{File.dirname(__FILE__)}/fixtures/environment_with_constant.rb")13 assert_nil $initialize_test_set_from_env14 Rails::Initializer.run(:load_environment, config)15 assert_equal "success", $initialize_test_set_from_env16 ensure17 $initialize_test_set_from_env = nil18 end19end20class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase21 def setup22 config = ConfigurationMock.new("")23 config.after_initialize do24 $test_after_initialize_block1 = "success"25 end26 config.after_initialize do27 $test_after_initialize_block2 = "congratulations"28 end 29 assert_nil $test_after_initialize_block130 assert_nil $test_after_initialize_block2 31 Rails::Initializer.run(:after_initialize, config)32 end33 34 def teardown35 $test_after_initialize_block1 = nil36 $test_after_initialize_block2 = nil 37 end38 def test_should_have_called_the_first_after_initialize_block39 assert_equal "success", $test_after_initialize_block140 end41 42 def test_should_have_called_the_second_after_initialize_block43 assert_equal "congratulations", $test_after_initialize_block244 end45end46 47class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase48 def setup49 config = ConfigurationMock.new("")50 config.after_initialize do51 $test_after_initialize_block1 = "success"52 end53 config.after_initialize # don't pass a block, this is what we're testing!54 config.after_initialize do55 $test_after_initialize_block2 = "congratulations"56 end 57 assert_nil $test_after_initialize_block158 Rails::Initializer.run(:after_initialize, config)59 end60 def teardown61 $test_after_initialize_block1 = nil62 $test_after_initialize_block2 = nil 63 end64 def test_should_have_called_the_first_after_initialize_block65 assert_equal "success", $test_after_initialize_block1, "should still get set"66 end67 def test_should_have_called_the_second_after_initialize_block68 assert_equal "congratulations", $test_after_initialize_block269 end70end71uses_mocha 'framework paths' do72 class ConfigurationFrameworkPathsTests < Test::Unit::TestCase73 def setup74 @config = Rails::Configuration.new75 @config.frameworks.clear76 77 File.stubs(:directory?).returns(true)78 @config.stubs(:framework_root_path).returns('')79 end80 def test_minimal81 expected = %w(82 /railties83 /railties/lib84 /activesupport/lib85 )86 assert_equal expected, @config.framework_paths87 end88 def test_actioncontroller_or_actionview_add_actionpack89 @config.frameworks << :action_controller90 assert_framework_path '/actionpack/lib'91 92 @config.frameworks = [:action_view]93 assert_framework_path '/actionpack/lib'94 end95 def test_paths_for_ar_ares_and_mailer96 [:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework|97 @config.frameworks = [framework]98 assert_framework_path "/#{framework.to_s.gsub('_', '')}/lib"99 end100 end101 def test_unknown_framework_raises_error102 @config.frameworks << :action_foo103 initializer = Rails::Initializer.new @config104 initializer.expects(:require).raises(LoadError)105 assert_raise RuntimeError do106 initializer.send :require_frameworks107 end108 end109 protected110 def assert_framework_path(path)111 assert @config.framework_paths.include?(path),112 "<#{path.inspect}> not found among <#{@config.framework_paths.inspect}>"113 end114 end115end116uses_mocha "Initializer plugin loading tests" do117 require File.dirname(__FILE__) + '/plugin_test_helper'118 class InitializerPluginLoadingTests < Test::Unit::TestCase119 def setup120 @configuration = Rails::Configuration.new121 @configuration.plugin_paths << plugin_fixture_root_path122 @initializer = Rails::Initializer.new(@configuration)123 @valid_plugin_path = plugin_fixture_path('default/stubby')124 @empty_plugin_path = plugin_fixture_path('default/empty')125 end126 def test_no_plugins_are_loaded_if_the_configuration_has_an_empty_plugin_list127 only_load_the_following_plugins! []128 @initializer.load_plugins129 assert_equal [], @initializer.loaded_plugins130 end131 def test_only_the_specified_plugins_are_located_in_the_order_listed132 plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon]133 only_load_the_following_plugins! plugin_names134 load_plugins!135 assert_plugins plugin_names, @initializer.loaded_plugins136 end137 def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched138 failure_tip = "It's likely someone has added a new plugin fixture without updating this list"139 load_plugins!140 assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip141 end142 def test_all_plugins_loaded_when_all_is_used143 plugin_names = [:stubby, :acts_as_chunky_bacon, :all]144 only_load_the_following_plugins! plugin_names145 load_plugins!146 failure_tip = "It's likely someone has added a new plugin fixture without updating this list"147 assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip148 end149 def test_all_plugins_loaded_after_all150 plugin_names = [:stubby, :all, :acts_as_chunky_bacon]151 only_load_the_following_plugins! plugin_names152 load_plugins!153 failure_tip = "It's likely someone has added a new plugin fixture without updating this list"154 assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @initializer.loaded_plugins, failure_tip155 end156 def test_plugin_names_may_be_strings157 plugin_names = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]158 only_load_the_following_plugins! plugin_names159 load_plugins!160 failure_tip = "It's likely someone has added a new plugin fixture without updating this list"161 assert_plugins plugin_names, @initializer.loaded_plugins, failure_tip162 end163 def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error164 only_load_the_following_plugins! [:stubby, :acts_as_a_non_existant_plugin]165 assert_raises(LoadError) do166 load_plugins!167 end168 end169 170 def test_should_ensure_all_loaded_plugins_load_paths_are_added_to_the_load_path171 only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]172 @initializer.add_plugin_load_paths173 174 assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))175 assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))176 end177 178 private179 180 def load_plugins!181 @initializer.add_plugin_load_paths182 @initializer.load_plugins183 end184 end185 186end ...

Full Screen

Full Screen

initialize

Using AI Code Generation

copy

Full Screen

1plugins.add_plugin('Plugin 1')2plugins.add_plugin('Plugin 2')3plugins.add_plugin('Plugin 3')4plugins.add_plugin('Plugin 4')5plugins.add_plugin('Plugin 5')6plugins.add_plugin('Plugin 6')

Full Screen

Full Screen

initialize

Using AI Code Generation

copy

Full Screen

1plugins.add_plugin('Plugin 1')2plugins.add_plugin('Plugin 2')3plugins.add_plugin('Plugin 3')4plugins.add_plugin('Plugin 4')5plugins.add_plugin('Plugin 5')6plugins.add_plugin('Plugin 6')

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Inspec_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful