Skip to content

Commit

Permalink
Adjust subject name in fetchers tests and set proper permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 25, 2017
1 parent 2a798d1 commit 6692e6f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
24 changes: 12 additions & 12 deletions test/lib/release_notes_fetchers/rpm_test.rb 100644 → 100755
Expand Up @@ -5,7 +5,7 @@
require "y2packager/product"

describe Y2Packager::ReleaseNotesFetchers::Rpm do
subject(:reader) { described_class.new(product) }
subject(:fetcher) { described_class.new(product) }

let(:product) { instance_double(Y2Packager::Product, name: "dummy") }
let(:package) { Y2Packager::Package.new("release-notes-dummy", 2, "15.1") }
Expand Down Expand Up @@ -42,13 +42,13 @@
it "cleans up temporary files" do
dir = Dir.mktmpdir
allow(Dir).to receive(:mktmpdir).and_return(dir)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
expect(File).to_not be_directory(dir)
end

context "when a full language code is given (xx_XX)" do
it "returns product release notes for the given language" do
rn = reader.release_notes(prefs)
rn = fetcher.release_notes(prefs)
expect(rn.content).to eq("Release Notes\n")
expect(rn.lang).to eq("en")
expect(rn.user_lang).to eq("en_US")
Expand All @@ -58,7 +58,7 @@
let(:user_lang) { "de_DE" }

it "returns product release notes for the short language code (xx)" do
rn = reader.release_notes(prefs)
rn = fetcher.release_notes(prefs)
expect(rn.content).to eq("Versionshinweise\n")
expect(rn.lang).to eq("de")
expect(rn.user_lang).to eq("de_DE")
Expand All @@ -70,7 +70,7 @@
let(:format) { :html }

it "returns product release notes in the given format" do
rn = reader.release_notes(prefs)
rn = fetcher.release_notes(prefs)
expect(rn.content).to eq("<h1>Release Notes</h1>\n")
expect(rn.format).to eq(:html)
end
Expand All @@ -80,7 +80,7 @@
let(:format) { :html }

it "returns the English version" do
rn = reader.release_notes(prefs)
rn = fetcher.release_notes(prefs)
expect(rn.content).to eq("<h1>Release Notes</h1>\n")
expect(rn.format).to eq(:html)
end
Expand All @@ -91,7 +91,7 @@
let(:provides) { [] }

it "returns nil" do
expect(reader.release_notes(prefs)).to be_nil
expect(fetcher.release_notes(prefs)).to be_nil
end
end

Expand All @@ -104,7 +104,7 @@
end

it "selects the latest one" do
rn = reader.release_notes(prefs)
rn = fetcher.release_notes(prefs)
expect(rn.version).to eq("15.1")
end
end
Expand All @@ -115,23 +115,23 @@
end

it "ignores the package" do
expect(reader.release_notes(prefs)).to be_nil
expect(fetcher.release_notes(prefs)).to be_nil
end
end
end

describe "#latest_version" do
it "returns latest version from release notes package" do
expect(reader.latest_version).to eq(package.version)
expect(fetcher.latest_version).to eq(package.version)
end

context "when no release notes package was found" do
before do
allow(reader).to receive(:release_notes_package).and_return(nil)
allow(fetcher).to receive(:release_notes_package).and_return(nil)
end

it "returns :none" do
expect(reader.latest_version).to eq(:none)
expect(fetcher.latest_version).to eq(:none)
end
end
end
Expand Down
40 changes: 20 additions & 20 deletions test/lib/release_notes_fetchers/url_test.rb 100644 → 100755
Expand Up @@ -5,7 +5,7 @@
require "y2packager/product"

describe Y2Packager::ReleaseNotesFetchers::Url do
subject(:reader) { described_class.new(product) }
subject(:fetcher) { described_class.new(product) }

let(:product) { instance_double(Y2Packager::Product, name: "dummy") }
let(:relnotes_url) { "http://doc.opensuse.org/openSUSE/release-notes-openSUSE.rpm" }
Expand Down Expand Up @@ -54,7 +54,7 @@
expect(Yast::SCR).to receive(:Execute).with(Yast::Path.new(".target.bash"), cmd)
.and_return(0)
expect(File).to receive(:read).with(/relnotes/).and_return(content)
rn = reader.release_notes(prefs)
rn = fetcher.release_notes(prefs)

expect(rn.product_name).to eq("dummy")
expect(rn.content).to eq(content)
Expand All @@ -69,7 +69,7 @@
"> '/var/log/YaST2/curl_log' 2>&1"

expect(Yast::SCR).to receive(:Execute).with(Yast::Path.new(".target.bash"), cmd)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end

context "when release notes are not found for the given language" do
Expand All @@ -83,7 +83,7 @@
expect(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash"), /RELEASE-NOTES.de.txt/)
.and_return(0)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end

context "and are not found for the generic language" do
Expand All @@ -97,7 +97,7 @@
expect(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash"), /RELEASE-NOTES.en.txt/)
.and_return(0)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end

Expand All @@ -109,7 +109,7 @@
expect(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash"), /RELEASE-NOTES.en.txt/)
.once.and_return(1)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end
end
Expand All @@ -132,7 +132,7 @@
expect(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash"), /RELEASE-NOTES.de_DE.txt/)
.and_return(0)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end

Expand All @@ -144,7 +144,7 @@
it "does not try to download release notes" do
expect(Yast::SCR).to_not receive(:Execute)
.with(Yast::Path.new(".target.bash"), /RELEASE-NOTES.de_DE.txt/)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end
end
Expand All @@ -154,7 +154,7 @@

it "blacklists the URL" do
expect(described_class).to receive(:add_to_blacklist).with(relnotes_url)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end

Expand All @@ -163,31 +163,31 @@

it "disables downloading release notes via relnotes_url" do
expect(described_class).to receive(:disable!).and_call_original
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end

context "when release notes URL is not valid" do
let(:relnotes_url) { "http" }

it "returns nil" do
expect(reader.release_notes(prefs)).to be_nil
expect(fetcher.release_notes(prefs)).to be_nil
end
end

context "when release notes URL is nil" do
let(:relnotes_url) { nil }

it "returns nil" do
expect(reader.release_notes(prefs)).to be_nil
expect(fetcher.release_notes(prefs)).to be_nil
end
end

context "when release notes URL is empty" do
let(:relnotes_url) { "" }

it "returns nil" do
expect(reader.release_notes(prefs)).to be_nil
expect(fetcher.release_notes(prefs)).to be_nil
end
end

Expand All @@ -197,13 +197,13 @@
end

it "returns nil" do
expect(reader.release_notes(prefs)).to be_nil
expect(fetcher.release_notes(prefs)).to be_nil
end

it "does not tries to download anything" do
expect(Yast::SCR).to_not receive(:Execute)
.with(Yast::Path.new(".target.bash"), /curl/)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end

Expand All @@ -213,13 +213,13 @@
end

it "returns nil" do
expect(reader.release_notes(prefs)).to be_nil
expect(fetcher.release_notes(prefs)).to be_nil
end

it "does not tries to download anything" do
expect(Yast::SCR).to_not receive(:Execute)
.with(Yast::Path.new(".target.bash"), /curl/)
reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end

Expand Down Expand Up @@ -248,7 +248,7 @@
expect(cmd).to include("--proxy http://proxy.example.com")
end

reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end

Expand All @@ -261,15 +261,15 @@
expect(cmd).to include("--proxy http://proxy.example.com --proxy-user 'baggins:thief'")
end

reader.release_notes(prefs)
fetcher.release_notes(prefs)
end
end
end
end

describe "#latest_version" do
it "returns :latest" do
expect(reader.latest_version).to eq(:latest)
expect(fetcher.latest_version).to eq(:latest)
end
end
end

0 comments on commit 6692e6f

Please sign in to comment.