Skip to content

Commit

Permalink
Simplify tests using let :architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Mar 18, 2019
1 parent c1bfdfe commit f8195d2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 31 deletions.
7 changes: 3 additions & 4 deletions test/y2storage/autoinst_profile/drive_section_test.rb
Expand Up @@ -409,10 +409,9 @@ def lvm_vg(name)
end

context "given a bcache" do
before do
allow(Yast::Arch).to receive(:x86_64).and_return("x86_64")
fake_scenario("btrfs_bcache.xml")
end
let(:architecture) { :x86_64 }

before { fake_scenario("btrfs_bcache.xml") }

it "initializes #type to :CT_BCACHE" do
expect(described_class.new_from_storage(device("bcache0")).type).to eq :CT_BCACHE
Expand Down
15 changes: 2 additions & 13 deletions test/y2storage/autoinst_profile/partition_section_test.rb
Expand Up @@ -30,12 +30,9 @@
subject(:section) { described_class.new }

let(:scenario) { "autoyast_drive_examples" }
let(:arch) { "x86_64" }
let(:architecture) { :x86_64 }

before do
allow(Yast::Arch).to receive(:architecture).and_return(arch)
fake_scenario(scenario)
end
before { fake_scenario(scenario) }

include_examples "autoinst section"

Expand Down Expand Up @@ -102,10 +99,6 @@ def section_for(name)
let(:scenario) { "btrfs_bcache.xml" }
let(:dev) { device("vdb") }

before do
allow(Yast::Arch).to receive(:x86_64).and_return("x86_64")
end

it "initializes #bcache_backing_for" do
section = described_class.new_from_storage(dev)
expect(section.bcache_backing_for).to eq("/dev/bcache0")
Expand All @@ -116,10 +109,6 @@ def section_for(name)
let(:scenario) { "btrfs_bcache.xml" }
let(:dev) { device("vda3") }

before do
allow(Yast::Arch).to receive(:x86_64).and_return("x86_64")
end

it "initializes #bcache_caching_for" do
section = described_class.new_from_storage(dev)
expect(section.bcache_caching_for).to eq(["/dev/bcache0"])
Expand Down
2 changes: 1 addition & 1 deletion test/y2storage/autoinst_proposal_bcache_test.rb
Expand Up @@ -33,10 +33,10 @@
end

let(:issues_list) { Y2Storage::AutoinstIssues::List.new }
let(:architecture) { :x86_64 }

before do
allow(Yast::Mode).to receive(:auto).and_return(true)
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
end

describe "#propose" do
Expand Down
5 changes: 1 addition & 4 deletions test/y2storage/proposal/autoinst_bcache_planner_test.rb
Expand Up @@ -26,18 +26,15 @@
require "y2storage/autoinst_issues/list"
require "y2storage/autoinst_profile/drive_section"

Yast.import "Arch"

describe Y2Storage::Proposal::AutoinstBcachePlanner do
using Y2Storage::Refinements::SizeCasts

subject(:planner) { described_class.new(fake_devicegraph, issues_list) }
let(:scenario) { "bcache1.xml" }
let(:issues_list) { Y2Storage::AutoinstIssues::List.new }
let(:arch) { "x86_64" }
let(:architecture) { :x86_64 }

before do
allow(Yast::Arch).to receive(:architecture).and_return(arch)
fake_scenario(scenario)
end

Expand Down
8 changes: 2 additions & 6 deletions test/y2storage/proposal/autoinst_devices_creator_test.rb
Expand Up @@ -25,8 +25,6 @@
require "y2storage/proposal/autoinst_devices_creator"
require "y2storage/planned"

Yast.import "Arch"

describe Y2Storage::Proposal::AutoinstDevicesCreator do
using Y2Storage::Refinements::SizeCasts

Expand All @@ -51,11 +49,9 @@
end

let(:planned_devices) { Y2Storage::Planned::DevicesCollection.new([disk]) }
let(:architecture) { :x86_64 }

before do
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
fake_scenario(scenario)
end
before { fake_scenario(scenario) }

subject(:creator) do
described_class.new(Y2Storage::StorageManager.instance.probed)
Expand Down
4 changes: 1 addition & 3 deletions test/y2storage/proposal/bcache_creator_test.rb
Expand Up @@ -23,15 +23,12 @@
require_relative "../spec_helper"
require "y2storage"

Yast.import "Arch"

describe Y2Storage::Proposal::BcacheCreator do
using Y2Storage::Refinements::SizeCasts

subject(:creator) { described_class.new(fake_devicegraph) }

before do
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
fake_scenario(scenario)
end

Expand All @@ -52,6 +49,7 @@
mount_point: "/", type: Y2Storage::Filesystems::Type::BTRFS, min_size: 1.GiB, max_size: 1.GiB
)
end
let(:architecture) { :x86_64 }

describe "#create_bcache" do
it "creates a new bcache device" do
Expand Down

0 comments on commit f8195d2

Please sign in to comment.