Improve existing tests for Livecheck DSL
This commit is contained in:
parent
b99e8626e2
commit
47d07b2f1b
@ -4,19 +4,25 @@ require "formula"
|
||||
require "livecheck"
|
||||
|
||||
describe Livecheck do
|
||||
HOMEPAGE_URL = "https://example.com/"
|
||||
STABLE_URL = "https://example.com/example-1.2.3.tar.gz"
|
||||
HEAD_URL = "https://example.com/example.git"
|
||||
|
||||
let(:f) do
|
||||
formula do
|
||||
url "https://brew.sh/test-0.1.tbz"
|
||||
homepage HOMEPAGE_URL
|
||||
url STABLE_URL
|
||||
head HEAD_URL
|
||||
end
|
||||
end
|
||||
let(:livecheckable) { described_class.new(f) }
|
||||
|
||||
describe "#regex" do
|
||||
it "returns nil if unset" do
|
||||
it "returns nil if not set" do
|
||||
expect(livecheckable.regex).to be nil
|
||||
end
|
||||
|
||||
it "returns the Regex if set" do
|
||||
it "returns the Regexp if set" do
|
||||
livecheckable.regex(/foo/)
|
||||
expect(livecheckable.regex).to eq(/foo/)
|
||||
end
|
||||
@ -29,14 +35,14 @@ describe Livecheck do
|
||||
end
|
||||
|
||||
describe "#skip" do
|
||||
it "sets the instance variable skip to true and skip_msg to nil when the argument is not present" do
|
||||
livecheckable.skip
|
||||
it "sets @skip to true when no argument is provided" do
|
||||
expect(livecheckable.skip).to be true
|
||||
expect(livecheckable.instance_variable_get(:@skip)).to be true
|
||||
expect(livecheckable.instance_variable_get(:@skip_msg)).to be nil
|
||||
end
|
||||
|
||||
it "sets the instance variable skip to true and skip_msg to the argument when present" do
|
||||
livecheckable.skip("foo")
|
||||
it "sets @skip to true and @skip_msg to the provided String" do
|
||||
expect(livecheckable.skip("foo")).to be true
|
||||
expect(livecheckable.instance_variable_get(:@skip)).to be true
|
||||
expect(livecheckable.instance_variable_get(:@skip_msg)).to eq("foo")
|
||||
end
|
||||
@ -49,8 +55,9 @@ describe Livecheck do
|
||||
end
|
||||
|
||||
describe "#skip?" do
|
||||
it "returns the value of the instance variable skip" do
|
||||
it "returns the value of @skip" do
|
||||
expect(livecheckable.skip?).to be false
|
||||
|
||||
livecheckable.skip
|
||||
expect(livecheckable.skip?).to be true
|
||||
end
|
||||
@ -74,7 +81,7 @@ describe Livecheck do
|
||||
end
|
||||
|
||||
describe "#url" do
|
||||
it "returns nil if unset" do
|
||||
it "returns nil if not set" do
|
||||
expect(livecheckable.url).to be nil
|
||||
end
|
||||
|
||||
@ -82,6 +89,16 @@ describe Livecheck do
|
||||
livecheckable.url("foo")
|
||||
expect(livecheckable.url).to eq("foo")
|
||||
|
||||
livecheckable.url(:homepage)
|
||||
expect(livecheckable.url).to eq(HOMEPAGE_URL)
|
||||
|
||||
livecheckable.url(:stable)
|
||||
expect(livecheckable.url).to eq(STABLE_URL)
|
||||
|
||||
livecheckable.url(:head)
|
||||
expect(livecheckable.url).to eq(HEAD_URL)
|
||||
end
|
||||
|
||||
it "raises a TypeError if the argument isn't a String or Symbol" do
|
||||
expect {
|
||||
livecheckable.url(/foo/)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user