From 07e926b37e4a623dd036783ce6c715ce8f63f93c Mon Sep 17 00:00:00 2001 From: Matheus Melo Date: Sun, 20 May 2018 18:22:16 -0300 Subject: [PATCH] removing :each from before and after --- spec/models/assigned_server_role_spec.rb | 2 +- spec/models/dialog_field_sorted_item_spec.rb | 4 ++-- spec/models/ems_event_spec.rb | 8 ++++---- spec/models/manageiq/providers/cloud_manager_spec.rb | 2 +- spec/models/manager_refresh/persister/finders_spec.rb | 2 +- .../manager_refresh/persister/local_db_finders_spec.rb | 4 ++-- .../manager_refresh/persister/serializing_spec.rb | 2 +- .../acyclic_graph_of_inventory_collections_spec.rb | 8 ++++---- .../graph_of_inventory_collections_spec.rb | 6 +++--- ...h_of_inventory_collections_targeted_refresh_spec.rb | 2 +- .../save_inventory/saver_strategies_spec.rb | 4 ++-- .../save_inventory/single_inventory_collection_spec.rb | 10 +++++----- .../save_inventory/strategies_and_references_spec.rb | 4 ++-- spec/models/metric/ci_mixin/capture_spec.rb | 2 +- spec/models/metric_spec.rb | 4 ++-- spec/models/miq_group_spec.rb | 2 +- spec/models/miq_region_spec.rb | 2 +- spec/models/miq_report/generator_spec.rb | 2 +- spec/models/miq_report_result_spec.rb | 4 ++-- spec/models/tag_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- spec/models/vmdb_database_connection_spec.rb | 2 +- spec/models/vmdb_database_setting_spec.rb | 2 +- spec/models/vmdb_database_spec.rb | 4 ++-- spec/models/vmdb_index_spec.rb | 2 +- spec/models/vmdb_table_evm_spec.rb | 2 +- spec/models/zone_spec.rb | 2 +- .../openstack/tests/interaction_methods_spec.rb | 2 +- tools/radar/rollup_radar_mixin_spec.rb | 8 ++++---- 29 files changed, 51 insertions(+), 51 deletions(-) diff --git a/spec/models/assigned_server_role_spec.rb b/spec/models/assigned_server_role_spec.rb index 20cd7460144..40c9a60214f 100644 --- a/spec/models/assigned_server_role_spec.rb +++ b/spec/models/assigned_server_role_spec.rb @@ -5,7 +5,7 @@ end context "Server Role" do - before (:each) do + before do @server_role = FactoryGirl.create( :server_role, :name => "smartproxy", diff --git a/spec/models/dialog_field_sorted_item_spec.rb b/spec/models/dialog_field_sorted_item_spec.rb index b13c03fbb8f..7fbd000b85a 100644 --- a/spec/models/dialog_field_sorted_item_spec.rb +++ b/spec/models/dialog_field_sorted_item_spec.rb @@ -146,7 +146,7 @@ let(:default_value) { "test2" } context "when show_refresh_button is true" do - before(:each) do + before do allow(dialog_field).to receive(:force_multi_value).and_return(false) end let(:show_refresh_button) { true } @@ -195,7 +195,7 @@ context "when show_refresh_button is false" do let(:show_refresh_button) { false } - before(:each) do + before do allow(dialog_field).to receive(:force_multi_value).and_return(false) end diff --git a/spec/models/ems_event_spec.rb b/spec/models/ems_event_spec.rb index 4b4946fb507..0ed59a2719b 100644 --- a/spec/models/ems_event_spec.rb +++ b/spec/models/ems_event_spec.rb @@ -69,7 +69,7 @@ context "with availability zones" do let(:vm) { FactoryGirl.create(:vm_openstack, :ems_ref => "vm1") } - before :each do + before do @zone = FactoryGirl.create(:small_environment) @ems = @zone.ext_management_systems.first @availability_zone = FactoryGirl.create(:availability_zone_openstack, :ems_ref => "az1") @@ -78,7 +78,7 @@ context ".process_availability_zone_in_event!" do let(:event_hash) { { :vm_or_template_id => vm.id } } context "when the event has an availability zone" do - before :each do + before do event_hash[:availability_zone_ems_ref] = @availability_zone.ems_ref end @@ -90,7 +90,7 @@ context "when the event has no availability zone" do context "and the VM has an availability zone" do - before :each do + before do vm.availability_zone_id = @availability_zone.id vm.save end @@ -160,7 +160,7 @@ end context ".add" do - before :each do + before do @event_hash = { :event_type => "event_with_availability_zone", :target_type => vm.class.name, diff --git a/spec/models/manageiq/providers/cloud_manager_spec.rb b/spec/models/manageiq/providers/cloud_manager_spec.rb index 936a106b81e..3c2febb73ae 100644 --- a/spec/models/manageiq/providers/cloud_manager_spec.rb +++ b/spec/models/manageiq/providers/cloud_manager_spec.rb @@ -295,7 +295,7 @@ def tenant_from_cloud_tenant_by(vm) FactoryGirl.create(:cloud_tenant_openstack, :ext_management_system => ems_cloud, :name => ct_name_3) end - before(:each) do + before do vm_1.cloud_tenant.update_attributes!(:parent => ct_3, :ext_management_system => ems_cloud, :name => ct_name_1) vm_2.cloud_tenant.update_attributes!(:ext_management_system => ems_cloud, :name => ct_name_2) end diff --git a/spec/models/manager_refresh/persister/finders_spec.rb b/spec/models/manager_refresh/persister/finders_spec.rb index 9841178fb10..0b232206fc5 100644 --- a/spec/models/manager_refresh/persister/finders_spec.rb +++ b/spec/models/manager_refresh/persister/finders_spec.rb @@ -10,7 +10,7 @@ # Spec scenarios for asserts giving hints to developers ###################################################################################################################### # - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone, diff --git a/spec/models/manager_refresh/persister/local_db_finders_spec.rb b/spec/models/manager_refresh/persister/local_db_finders_spec.rb index 3cdb38ab4a9..177cbf8ec1b 100644 --- a/spec/models/manager_refresh/persister/local_db_finders_spec.rb +++ b/spec/models/manager_refresh/persister/local_db_finders_spec.rb @@ -12,7 +12,7 @@ # Spec scenarios for making sure the local db index is able to build complex queries using references ###################################################################################################################### # - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone, @@ -22,7 +22,7 @@ allow(Settings.ems_refresh).to receive(:mock).and_return({}) end - before :each do + before do initialize_mocked_records end diff --git a/spec/models/manager_refresh/persister/serializing_spec.rb b/spec/models/manager_refresh/persister/serializing_spec.rb index a3415a9510c..7f9c526e521 100644 --- a/spec/models/manager_refresh/persister/serializing_spec.rb +++ b/spec/models/manager_refresh/persister/serializing_spec.rb @@ -10,7 +10,7 @@ # Spec scenarios testing Persister can serialize/deserialize, with having complex nested lazy_find links ###################################################################################################################### # - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone, diff --git a/spec/models/manager_refresh/save_inventory/acyclic_graph_of_inventory_collections_spec.rb b/spec/models/manager_refresh/save_inventory/acyclic_graph_of_inventory_collections_spec.rb index 46bfd55445c..e55464a7a84 100644 --- a/spec/models/manager_refresh/save_inventory/acyclic_graph_of_inventory_collections_spec.rb +++ b/spec/models/manager_refresh/save_inventory/acyclic_graph_of_inventory_collections_spec.rb @@ -68,7 +68,7 @@ [{:inventory_object_saving_strategy => nil}, {:inventory_object_saving_strategy => :recursive},].each do |inventory_object_settings| context "with settings #{inventory_object_settings}" do - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone) @@ -77,7 +77,7 @@ end context 'with empty DB' do - before :each do + before do initialize_data_and_inventory_collections end @@ -586,7 +586,7 @@ end context "lazy_find vs find" do - before :each do + before do # Initialize the InventoryCollections @data = {} @data[:vms] = ::ManagerRefresh::InventoryCollection.new( @@ -663,7 +663,7 @@ end context "assert_referential_integrity" do - before :each do + before do # Initialize the InventoryCollections @data = {} @data[:vms] = ::ManagerRefresh::InventoryCollection.new( diff --git a/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_spec.rb b/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_spec.rb index 40dcf95b66f..6664f3aeb5c 100644 --- a/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_spec.rb +++ b/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_spec.rb @@ -279,7 +279,7 @@ [{:inventory_object_saving_strategy => nil}, {:inventory_object_saving_strategy => :recursive},].each do |inventory_object_settings| context "with settings #{inventory_object_settings}" do - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone) @ems_network = FactoryGirl.create(:ems_network, :zone => @zone, :parent_manager => @ems) @@ -289,7 +289,7 @@ end context 'with empty DB' do - before :each do + before do initialize_inventory_collections end @@ -359,7 +359,7 @@ end context 'with empty DB and reversed InventoryCollections' do - before :each do + before do initialize_inventory_collections_reversed end diff --git a/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_targeted_refresh_spec.rb b/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_targeted_refresh_spec.rb index bd98ebc3764..08ba2de6745 100644 --- a/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_targeted_refresh_spec.rb +++ b/spec/models/manager_refresh/save_inventory/graph_of_inventory_collections_targeted_refresh_spec.rb @@ -15,7 +15,7 @@ [{:inventory_object_saving_strategy => nil}, {:inventory_object_saving_strategy => :recursive}].each do |inventory_object_settings| context "with settings #{inventory_object_settings}" do - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone) diff --git a/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb b/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb index 7253d0c603c..0f5a4cd90e5 100644 --- a/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb +++ b/spec/models/manager_refresh/save_inventory/saver_strategies_spec.rb @@ -21,7 +21,7 @@ {:saver_strategy => :batch, :use_ar_object => false}, ].each do |options| context "with options #{options}" do - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone, @@ -31,7 +31,7 @@ allow(Settings.ems_refresh).to receive(:mock).and_return(inventory_object_settings) end - before :each do + before do @image1 = FactoryGirl.create(:miq_template, image_data(1)) @image2 = FactoryGirl.create(:miq_template, image_data(2)) @image3 = FactoryGirl.create(:miq_template, image_data(3)) diff --git a/spec/models/manager_refresh/save_inventory/single_inventory_collection_spec.rb b/spec/models/manager_refresh/save_inventory/single_inventory_collection_spec.rb index d8f0a9a6a97..d96b9dad673 100644 --- a/spec/models/manager_refresh/save_inventory/single_inventory_collection_spec.rb +++ b/spec/models/manager_refresh/save_inventory/single_inventory_collection_spec.rb @@ -18,7 +18,7 @@ [{:inventory_object_saving_strategy => nil}, {:inventory_object_saving_strategy => :recursive},].each do |inventory_object_settings| context "with settings #{inventory_object_settings}" do - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone) @@ -99,14 +99,14 @@ end context 'with existing Vms in the DB' do - before :each do + before do # Fill DB with test Vms @vm1 = FactoryGirl.create(:vm_cloud, vm_data(1).merge(:ext_management_system => @ems)) @vm2 = FactoryGirl.create(:vm_cloud, vm_data(2).merge(:ext_management_system => @ems)) end context 'with VM InventoryCollection with default settings' do - before :each do + before do # Initialize the InventoryCollections @data = {} @data[:vms] = ::ManagerRefresh::InventoryCollection.new( @@ -237,7 +237,7 @@ end context 'with VM InventoryCollection with :delete_method => :disconnect_inv' do - before :each do + before do # Initialize the InventoryCollections @data = {} @data[:vms] = ::ManagerRefresh::InventoryCollection.new( @@ -529,7 +529,7 @@ end context 'with VM InventoryCollection with :complete => false' do - before :each do + before do # Initialize the InventoryCollections @data = {} @data[:vms] = ::ManagerRefresh::InventoryCollection.new( diff --git a/spec/models/manager_refresh/save_inventory/strategies_and_references_spec.rb b/spec/models/manager_refresh/save_inventory/strategies_and_references_spec.rb index 8e8d0ddc20c..860a2dfcf6e 100644 --- a/spec/models/manager_refresh/save_inventory/strategies_and_references_spec.rb +++ b/spec/models/manager_refresh/save_inventory/strategies_and_references_spec.rb @@ -17,7 +17,7 @@ context "with settings #{inventory_object_settings}" do [:local_db_find_references, :local_db_cache_all].each do |db_strategy| context "with db strategy #{db_strategy}" do - before :each do + before do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, :zone => @zone, @@ -27,7 +27,7 @@ allow(Settings.ems_refresh).to receive(:mock).and_return(inventory_object_settings) end - before :each do + before do @image1 = FactoryGirl.create(:miq_template, image_data(1).merge(:ext_management_system => @ems)) @image2 = FactoryGirl.create(:miq_template, image_data(2).merge(:ext_management_system => @ems)) @image3 = FactoryGirl.create(:miq_template, image_data(3).merge(:ext_management_system => @ems)) diff --git a/spec/models/metric/ci_mixin/capture_spec.rb b/spec/models/metric/ci_mixin/capture_spec.rb index aca11711215..2234c979dc8 100644 --- a/spec/models/metric/ci_mixin/capture_spec.rb +++ b/spec/models/metric/ci_mixin/capture_spec.rb @@ -97,7 +97,7 @@ def mock_adapter(postgre_adapter) ["miq_postgres", "miq_postgres_legacy"].each do |postgre_adapter| context "with adapter #{postgre_adapter}" do - before :each do + before do mock_adapter(postgre_adapter) end diff --git a/spec/models/metric_spec.rb b/spec/models/metric_spec.rb index cbfb6fa4f69..28efe2ffee9 100644 --- a/spec/models/metric_spec.rb +++ b/spec/models/metric_spec.rb @@ -6,7 +6,7 @@ end context "as vmware" do - before :each do + before do @ems_vmware = FactoryGirl.create(:ems_vmware, :zone => @zone) end @@ -991,7 +991,7 @@ end context "as openstack" do - before :each do + before do @ems_openstack = FactoryGirl.create(:ems_openstack, :zone => @zone) end diff --git a/spec/models/miq_group_spec.rb b/spec/models/miq_group_spec.rb index bdf0be1a3b9..78d25f39213 100644 --- a/spec/models/miq_group_spec.rb +++ b/spec/models/miq_group_spec.rb @@ -150,7 +150,7 @@ let(:num_cpu) { 2 } let(:ems) { FactoryGirl.create(:ems_vmware, :name => "test_vcenter") } let(:storage) { FactoryGirl.create(:storage, :name => "test_storage_nfs", :store_type => "NFS") } - before :each do + before do @hw1 = FactoryGirl.create(:hardware, :cpu_total_cores => num_cpu, :memory_mb => ram_size) @hw2 = FactoryGirl.create(:hardware, :cpu_total_cores => num_cpu, :memory_mb => ram_size) @hw3 = FactoryGirl.create(:hardware, :cpu_total_cores => num_cpu, :memory_mb => ram_size) diff --git a/spec/models/miq_region_spec.rb b/spec/models/miq_region_spec.rb index 21827587be5..7fefc69f484 100644 --- a/spec/models/miq_region_spec.rb +++ b/spec/models/miq_region_spec.rb @@ -18,7 +18,7 @@ end context "with cloud and infra EMSes" do - before :each do + before do _, _, zone = EvmSpecHelper.create_guid_miq_server_zone ems_vmware = FactoryGirl.create(:ems_vmware, :zone => zone) ems_openstack = FactoryGirl.create(:ems_openstack, :zone => zone) diff --git a/spec/models/miq_report/generator_spec.rb b/spec/models/miq_report/generator_spec.rb index 932a014fee2..aa1e6a44740 100644 --- a/spec/models/miq_report/generator_spec.rb +++ b/spec/models/miq_report/generator_spec.rb @@ -8,7 +8,7 @@ describe "#generate" do context "Memory Utilization Trends report (daily)" do - before :each do + before do @miq_report_profile_all = FactoryGirl.create( :miq_report, :db => "VimPerformanceTrend", diff --git a/spec/models/miq_report_result_spec.rb b/spec/models/miq_report_result_spec.rb index cb17a9272bf..f553669f497 100644 --- a/spec/models/miq_report_result_spec.rb +++ b/spec/models/miq_report_result_spec.rb @@ -1,5 +1,5 @@ describe MiqReportResult do - before :each do + before do EvmSpecHelper.local_miq_server @user1 = FactoryGirl.create(:user_with_group) @@ -28,7 +28,7 @@ end context "report result created by User 1 with current group 1" do - before :each do + before do @report_1 = FactoryGirl.create(:miq_report) group_1 = FactoryGirl.create(:miq_group) group_2 = FactoryGirl.create(:miq_group) diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 45df9e47d9b..49150355952 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -173,7 +173,7 @@ let(:filters) { [["/managed/prov_max_memory/test"], ["/managed/my_name/test"]] } let(:tag) { FactoryGirl.create(:tag, :name => "/managed/my_name/test") } - before :each do + before do miq_group.entitlement.set_managed_filters(filters) other_miq_group.entitlement.set_managed_filters(filters) [miq_group, other_miq_group].each(&:save) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c829395bad6..c6614e28784 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -277,7 +277,7 @@ end context "Testing active VM aggregation" do - before :each do + before do @ram_size = 1024 @disk_size = 1_000_000 @num_cpu = 2 diff --git a/spec/models/vmdb_database_connection_spec.rb b/spec/models/vmdb_database_connection_spec.rb index 93af4210111..56eb30fc242 100644 --- a/spec/models/vmdb_database_connection_spec.rb +++ b/spec/models/vmdb_database_connection_spec.rb @@ -1,7 +1,7 @@ require "concurrent/atomic/event" describe VmdbDatabaseConnection do - before :each do + before do @db = FactoryGirl.create(:vmdb_database) end diff --git a/spec/models/vmdb_database_setting_spec.rb b/spec/models/vmdb_database_setting_spec.rb index 968aa7f0bb2..cb2b6a83dd9 100644 --- a/spec/models/vmdb_database_setting_spec.rb +++ b/spec/models/vmdb_database_setting_spec.rb @@ -1,5 +1,5 @@ describe VmdbDatabaseSetting do - before :each do + before do @db = FactoryGirl.create(:vmdb_database) end diff --git a/spec/models/vmdb_database_spec.rb b/spec/models/vmdb_database_spec.rb index e9a235873d5..f4cfb94081b 100644 --- a/spec/models/vmdb_database_spec.rb +++ b/spec/models/vmdb_database_spec.rb @@ -1,5 +1,5 @@ describe VmdbDatabase do - before :each do + before do @db = FactoryGirl.create(:vmdb_database) @table = FactoryGirl.create(:vmdb_table_evm, :vmdb_database => @db, :name => 'accounts') @text = FactoryGirl.create(:vmdb_table_text, :vmdb_database => @db, :name => 'accounts', :parent_id => @table.id) @@ -85,7 +85,7 @@ end context "#top_tables_by" do - before :each do + before do @table_1 = FactoryGirl.create(:vmdb_table_evm, :vmdb_database => @db, :name => 'accounts1') @table_2 = FactoryGirl.create(:vmdb_table_evm, :vmdb_database => @db, :name => 'accounts2') @table_3 = FactoryGirl.create(:vmdb_table_evm, :vmdb_database => @db, :name => 'accounts3') diff --git a/spec/models/vmdb_index_spec.rb b/spec/models/vmdb_index_spec.rb index c48003b0aa6..1586f454339 100644 --- a/spec/models/vmdb_index_spec.rb +++ b/spec/models/vmdb_index_spec.rb @@ -32,7 +32,7 @@ end context "#rollup_metrics" do - before :each do + before do db = VmdbDatabase.seed_self @evm_table = FactoryGirl.create(:vmdb_table_evm, :vmdb_database => db, :name => 'accounts') @evm_index = FactoryGirl.create(:vmdb_index, :vmdb_table => @evm_table, :name => "accounts_pkey") diff --git a/spec/models/vmdb_table_evm_spec.rb b/spec/models/vmdb_table_evm_spec.rb index f397d18d2bd..3e7d9e5eedf 100644 --- a/spec/models/vmdb_table_evm_spec.rb +++ b/spec/models/vmdb_table_evm_spec.rb @@ -129,7 +129,7 @@ end context "#rollup_metrics" do - before :each do + before do db = VmdbDatabase.seed_self @evm_table = FactoryGirl.create(:vmdb_table_evm, :vmdb_database => db, :name => 'accounts') diff --git a/spec/models/zone_spec.rb b/spec/models/zone_spec.rb index 6971b953be9..c74fac3a64b 100644 --- a/spec/models/zone_spec.rb +++ b/spec/models/zone_spec.rb @@ -37,7 +37,7 @@ end context "when dealing with clouds" do - before :each do + before do _, _, @zone = EvmSpecHelper.create_guid_miq_server_zone end diff --git a/spec/tools/environment_builders/openstack/tests/interaction_methods_spec.rb b/spec/tools/environment_builders/openstack/tests/interaction_methods_spec.rb index 16ccd4946a9..a0c487eb1c5 100644 --- a/spec/tools/environment_builders/openstack/tests/interaction_methods_spec.rb +++ b/spec/tools/environment_builders/openstack/tests/interaction_methods_spec.rb @@ -62,7 +62,7 @@ context "#Openstack::InteractionMethods" do let(:subject) { (Class.new { include Openstack::InteractionMethods }).new } - before :each do + before do allow($stdout).to receive(:puts) end diff --git a/tools/radar/rollup_radar_mixin_spec.rb b/tools/radar/rollup_radar_mixin_spec.rb index 698b1f19393..0c59e865312 100644 --- a/tools/radar/rollup_radar_mixin_spec.rb +++ b/tools/radar/rollup_radar_mixin_spec.rb @@ -123,7 +123,7 @@ def check_results(results, expected) sett end - before(:each) do + before do add_metrics([container_a, container_b]) end @@ -177,7 +177,7 @@ def check_results(results, expected) sett end - before(:each) do + before do add_metrics([container_a, container_b]) end @@ -276,7 +276,7 @@ def check_results(results, expected) :section => 'docker_labels') end - before(:each) do + before do add_metrics([container_a, container_b]) end @@ -298,7 +298,7 @@ def check_results(results, expected) end end - after(:each) do + after do Timecop.return end end