Skip to content

Commit

Permalink
Small fixes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Dec 21, 2016
1 parent b5ea25c commit 1f32163
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions keyboard/test/keyboard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Yast
import "XVersion"
import "Report"
import "OSRelease"
import "Keyboard"

::RSpec.configure do |c|
c.include SCRStub
Expand Down Expand Up @@ -438,9 +439,8 @@ module Yast
end
end

context "when user did not make a decision" do
context "when user did not make any decision" do
it "sets the keyboard for the current language" do
allow(Language).to receive("en_US").and_return("en_US")
expect(Keyboard).to receive(:Set).with("english-us")
Keyboard.MakeProposal(false, false)
end
Expand All @@ -456,7 +456,7 @@ module Yast
Keyboard.MakeProposal(false, true)
end

it "does nothing if language did not changed" do
it "does nothing if language did not change" do
expect(Keyboard).to_not receive(:Set)
Keyboard.MakeProposal(false, false)
end
Expand All @@ -466,9 +466,7 @@ module Yast

describe "#Probe" do
let(:chroot) { "spanish" }
let(:probed_data) do
YAML.load_file(File.join(DATA_PATH, "probe-keyboard.yml"))
end
let(:probed_data) { YAML.load_file(File.join(DATA_PATH, "probe-keyboard.yml")) }

before do
allow(SCR).to receive(:Read).with(path(".probe.keyboard"))
Expand All @@ -477,7 +475,7 @@ module Yast
end

context "when layout can be determined" do
it "sets keyboard data" do
it "sets keyboard data from hardware" do
Keyboard.Probe
expect(Keyboard.unique_key).to eq("nLyy.+49ps10DtUF")
expect(Keyboard.kb_model).to eq("pc104")
Expand All @@ -492,9 +490,7 @@ module Yast
context "when layout cannot be determined" do
let(:probed_data) { nil }

before do
allow(Language).to receive(:language).and_return("es_ES")
end
before { allow(Language).to receive(:language).and_return("es_ES") }

it "uses the keyboard for the current language" do
expect(Keyboard).to receive(:SetKeyboard).with("spanish")
Expand All @@ -506,13 +502,14 @@ module Yast
let(:stage) { "initial" }

before do
allow(AsciiFile).to receive(:RewriteFile)
allow(Linuxrc).to receive(:InstallInf).with("Keytable").and_return(keytable)
end

context "when Linuxrc Keytable setting exist" do
context "when Linuxrc Keytable setting exists" do
let(:keytable) { "de-nodeadkeys" }

it "uses the keyboard that matches that keytable" do
it "uses the keyboard that matches the Keytable value" do
expect(Keyboard).to receive(:Set).with("german").and_call_original
Keyboard.Probe
end
Expand All @@ -532,7 +529,7 @@ module Yast
Keyboard.Probe
end

it "does not set the keyboard if preselected language is en_US" do
it "does not set the keyboard if preselected language is 'en_US'" do
allow(Language).to receive(:preselected).and_return("en_US")
expect(Keyboard).to_not receive(:Set)
Keyboard.Probe
Expand Down Expand Up @@ -565,7 +562,7 @@ module Yast
expect(Keyboard.current_kbd).to eq("spanish")
end

context "when data is wrong" do
context "when value for keyboard is missing" do
before do
allow(Misc).to receive(:SysconfigRead).and_call_original
allow(Misc).to receive(:SysconfigRead)
Expand Down Expand Up @@ -613,9 +610,7 @@ module Yast
let(:os_release_id) { "sles" }
let(:kb_model) { "macintosh" }

before do
allow(Yast::OSRelease).to receive(:id).and_return(os_release_id)
end
before { allow(Yast::OSRelease).to receive(:id).and_return(os_release_id) }

around do |example|
old_kb_model = Keyboard.kb_model
Expand Down

0 comments on commit 1f32163

Please sign in to comment.