Skip to content

Commit

Permalink
removing :each from before and after
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuscmelo committed Mar 19, 2018
1 parent d99daaa commit 92ca2f7
Show file tree
Hide file tree
Showing 137 changed files with 532 additions and 532 deletions.
2 changes: 1 addition & 1 deletion spec/lib/ems_event_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe EmsEventHelper do
context "fb12322 - MiqAeEvent.build_evm_event blows up expecting inputs[:policy] to be an instance of MiqPolicy, but it is a hash of { :vmdb_class => 'MiqPolicy', :vmdb_id => 42}" do
before(:each) do
before do
[Zone, ExtManagementSystem, Host, Vm, Storage, EmsEvent, MiqEventDefinition, MiqPolicy, MiqAction, MiqPolicyContent, MiqPolicySet].each(&:delete_all)

@zone = FactoryGirl.create(:zone)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/evm_database_ops_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'util/runcmd'
describe EvmDatabaseOps do
context "#backup" do
before(:each) do
before do
@connect_opts = {:username => 'blah', :password => 'blahblah', :uri => "smb://myserver.com/share"}
@db_opts = {:dbname => 'vmdb_production', :username => 'root'}
allow(MiqSmbSession).to receive(:runcmd)
Expand Down Expand Up @@ -47,7 +47,7 @@
end

context "#restore" do
before(:each) do
before do
@connect_opts = {:username => 'blah', :password => 'blahblah'}
@db_opts = {:dbname => 'vmdb_production', :username => 'root'}
allow(MiqSmbSession).to receive(:runcmd)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/extensions/ar_extract_objects_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe "ArExtractObjects" do
context "ArExtractObjectsTest" do
before(:each) do
before do
vms = (0...2).collect { FactoryGirl.create(:vm_vmware) }
@vm1, @vm2 = *vms
@id1, @id2 = vms.collect(&:id)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/extensions/ar_nested_count_by_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe "AR Nested Count By extension" do
context "miq_queue with messages" do
before(:each) do
before do
@zone = EvmSpecHelper.local_miq_server.zone

FactoryGirl.create(:miq_queue, :zone => @zone.name, :state => MiqQueue::STATE_DEQUEUE, :role => "role1", :priority => 20)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/extensions/ar_taggable_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe ActsAsTaggable do
before(:each) do
before do
@host1 = FactoryGirl.create(:host, :name => "HOST1")
@host1.tag_with("red blue yellow", :ns => "/test", :cat => "tags")
@host2 = FactoryGirl.create(:host, :name => "HOST2")
Expand Down
20 changes: 10 additions & 10 deletions spec/lib/extensions/ar_virtual_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe VirtualFields do
context "TestClass" do
before(:each) do
before do
class TestClassBase < ActiveRecord::Base
self.abstract_class = true

Expand Down Expand Up @@ -35,7 +35,7 @@ def self.connection
end
end

after(:each) do
after do
TestClassBase.remove_connection
Object.send(:remove_const, :TestClass)
Object.send(:remove_const, :TestClassBase)
Expand Down Expand Up @@ -222,7 +222,7 @@ def self.connection
end

context "with virtual columns" do
before(:each) do
before do
TestClass.virtual_column :vcol1, :type => :string
TestClass.virtual_column :vcol2, :type => :string

Expand All @@ -240,7 +240,7 @@ def self.connection
virtual_column :vcolsub1, :type => :string
end
end
before(:each) do
before do
test_sub_class
@vcols_sub_strs = @vcols_strs + ["vcolsub1"]
@vcols_sub_syms = @vcols_syms + [:vcolsub1]
Expand Down Expand Up @@ -438,7 +438,7 @@ def hosts
end

context "with virtual reflections" do
before(:each) do
before do
TestClass.virtual_has_one :vref1
TestClass.virtual_has_one :vref2

Expand All @@ -456,7 +456,7 @@ def self.reflections; super.merge(:ref2 => OpenStruct.new(:name => :ref2, :optio
virtual_has_one :vrefsub1
end
end
before(:each) do
before do
test_sub_class
@vrefs_sub_syms = @vrefs_syms + [:vrefsub1]
@refs_sub_syms = @vrefs_sub_syms + [:ref1, :ref2]
Expand All @@ -468,7 +468,7 @@ def self.reflections; super.merge(:ref2 => OpenStruct.new(:name => :ref2, :optio
end

context "with both virtual columns and reflections" do
before(:each) do
before do
TestClass.virtual_column :vcol1, :type => :string
TestClass.virtual_has_one :vref1
end
Expand Down Expand Up @@ -613,7 +613,7 @@ def col2
end

context "with relation in foreign table" do
before(:each) do
before do
class TestOtherClass < ActiveRecord::Base
def self.connection
TestClassBase.connection
Expand All @@ -624,7 +624,7 @@ def self.connection
end
end

after(:each) do
after do
TestOtherClass.remove_connection
Object.send(:remove_const, :TestOtherClass)
end
Expand Down Expand Up @@ -906,7 +906,7 @@ def col2
end

context "preloading" do
before(:each) do
before do
FactoryGirl.create(:vm_vmware,
:hardware => FactoryGirl.create(:hardware),
:operating_system => FactoryGirl.create(:operating_system),
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/extensions/database_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
let(:db_config_path) { File.expand_path "../../../config/database.yml", __dir__ }
let(:fake_db_config) { Pathname.new("does/not/exist") }

before(:each) do
before do
allow(ManageIQ).to receive_messages(:env => ActiveSupport::StringInquirer.new("production"))

@app = Vmdb::Application.new
@app.config.paths["config/database"] = fake_db_config.to_s # ignore real database.yml
end

context "ERB in the template" do
before(:each) do
before do
database_config = StringIO.new "---\nvalue: <%= 1 %>\n"
allow(database_config).to receive(:exist?).and_return(true)
allow(Pathname).to receive(:new).and_return(database_config)
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/extensions/virtual_total_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe VirtualTotal do
before(:each) do
before do
# rubocop:disable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs, Naming/AccessorMethodName
class VitualTotalTestBase < ActiveRecord::Base
self.abstract_class = true
Expand Down Expand Up @@ -71,7 +71,7 @@ def self.connection; VitualTotalTestBase.connection end
# rubocop:enable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs, Naming/AccessorMethodName
end

after(:each) do
after do
VitualTotalTestBase.remove_connection
Object.send(:remove_const, :VtAuthor)
Object.send(:remove_const, :VtBook)
Expand Down Expand Up @@ -160,7 +160,7 @@ def self.connection; VitualTotalTestBase.connection end
end

context "with order clauses in the relation" do
before(:each) do
before do
# Monkey patching VtAuthor for these specs
class VtAuthor < VitualTotalTestBase
has_many :recently_published_books, -> { published.order(:created_on => :desc) },
Expand Down Expand Up @@ -217,7 +217,7 @@ class VtAuthor < VitualTotalTestBase
end

context "with a special books class" do
before(:each) do
before do
class SpecialVtBook < VtBook
default_scope { where(:special => true) }

Expand All @@ -236,7 +236,7 @@ class VtAuthor < VitualTotalTestBase
end
end

after(:each) do
after do
Object.send(:remove_const, :SpecialVtBook)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/manageiq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def without_rails(rb_cmd)
end

describe ".env" do
before(:each) do
before do
ManageIQ.instance_variable_set(:@_env, nil)
end

Expand Down Expand Up @@ -45,7 +45,7 @@ def without_rails(rb_cmd)
end

describe ".root" do
before(:each) do
before do
ManageIQ.instance_variable_set(:@_root, nil)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/miq_cockpit_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe MiqCockpit::WS do
before(:each) do
before do
@server = FactoryGirl.create(:miq_server, :hostname => "hostname")
@miq_server = EvmSpecHelper.local_miq_server
@miq_server.ipaddress = "10.0.0.1"
Expand Down Expand Up @@ -104,7 +104,7 @@
end

describe 'update_config' do
before(:each) do
before do
@login_command = Rails.root.join("tools", "cockpit", "cockpit-auth-miq")
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/miq_environment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
describe MiqEnvironment do
context "with linux platform" do
before(:each) do
before do
@old_impl = Sys::Platform::IMPL
silence_warnings { Sys::Platform::IMPL = :linux }
end

after(:each) do
after do
silence_warnings { Sys::Platform::IMPL = @old_impl } if @old_impl
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/miq_expression_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
let(:volume_2_type_field_cost) { "#{model}-storage_allocated_#{volume_2.volume_type}_cost" }
let(:volume_3_type_field_cost) { "#{model}-storage_allocated_#{volume_3.volume_type}_cost" }

before(:each) do
before do
volume_1
volume_2
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/miq_ldap_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: US-ASCII

describe MiqLdap do
before(:each) do
before do
@host = 'mycompany.com'

# TODO: Use an actual user so this test actually tests something in the CI server
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/pid_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe PidFile do
before(:each) do
before do
@fname = 'foo.bar'
@pid_file = PidFile.new(@fname)
end
Expand All @@ -11,7 +11,7 @@
end

context "file does exist" do
before(:each) do
before do
allow(File).to receive(:file?).with(@fname).and_return(true)
end

Expand Down Expand Up @@ -68,7 +68,7 @@
end

context "#pid returns valid value" do
before(:each) do
before do
@pid = 42
allow(@pid_file).to receive(:pid).and_return(@pid)
end
Expand All @@ -84,7 +84,7 @@
end

context "MiqProcess.command_line returns valid value" do
before(:each) do
before do
@cmd_line = "my favorite program"
allow(MiqProcess).to receive(:command_line).and_return(@cmd_line)
end
Expand Down
Loading

0 comments on commit 92ca2f7

Please sign in to comment.