add test for token in options
This commit is contained in:
parent
7b356bf01a
commit
50ba2695fb
|
@ -1,4 +1,5 @@
|
||||||
describe GitHubChangelogGenerator::Fetcher do
|
describe GitHubChangelogGenerator::Fetcher do
|
||||||
|
VALID_TOKEN = "0123456789abcdef"
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@fetcher = GitHubChangelogGenerator::Fetcher.new
|
@fetcher = GitHubChangelogGenerator::Fetcher.new
|
||||||
end
|
end
|
||||||
|
@ -6,14 +7,30 @@ describe GitHubChangelogGenerator::Fetcher do
|
||||||
describe "#fetch_github_token" do
|
describe "#fetch_github_token" do
|
||||||
token = GitHubChangelogGenerator::Fetcher::CHANGELOG_GITHUB_TOKEN
|
token = GitHubChangelogGenerator::Fetcher::CHANGELOG_GITHUB_TOKEN
|
||||||
context "when token in ENV exist" do
|
context "when token in ENV exist" do
|
||||||
before { stub_const("ENV", ENV.to_hash.merge(token => "0123456789abcdef")) }
|
before { stub_const("ENV", ENV.to_hash.merge(token => VALID_TOKEN)) }
|
||||||
subject { @fetcher.fetch_github_token }
|
subject { @fetcher.fetch_github_token }
|
||||||
it { is_expected.to eq("0123456789abcdef") }
|
it { is_expected.to eq(VALID_TOKEN) }
|
||||||
end
|
end
|
||||||
context "when token in ENV is nil" do
|
context "when token in ENV is nil" do
|
||||||
before { stub_const("ENV", ENV.to_hash.merge(token => nil)) }
|
before { stub_const("ENV", ENV.to_hash.merge(token => nil)) }
|
||||||
subject { @fetcher.fetch_github_token }
|
subject { @fetcher.fetch_github_token }
|
||||||
it { is_expected.to be_nil }
|
it { is_expected.to be_nil }
|
||||||
end
|
end
|
||||||
|
context "when token in options and ENV is nil" do
|
||||||
|
before do
|
||||||
|
stub_const("ENV", ENV.to_hash.merge(token => nil))
|
||||||
|
@fetcher = GitHubChangelogGenerator::Fetcher.new(token: VALID_TOKEN)
|
||||||
|
end
|
||||||
|
subject { @fetcher.fetch_github_token }
|
||||||
|
it { is_expected.to eq(VALID_TOKEN) }
|
||||||
|
end
|
||||||
|
context "when token in options and ENV specified" do
|
||||||
|
before do
|
||||||
|
stub_const("ENV", ENV.to_hash.merge(token => "no_matter_what"))
|
||||||
|
@fetcher = GitHubChangelogGenerator::Fetcher.new(token: VALID_TOKEN)
|
||||||
|
end
|
||||||
|
subject { @fetcher.fetch_github_token }
|
||||||
|
it { is_expected.to eq(VALID_TOKEN) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user