add tests for fetching token

This commit is contained in:
Petr Korolev
2015-05-14 15:57:31 +03:00
parent c67cbb31f2
commit 7b356bf01a
2 changed files with 21 additions and 1 deletions

19
spec/unit/fetcher_spec.rb Normal file
View File

@@ -0,0 +1,19 @@
describe GitHubChangelogGenerator::Fetcher do
before(:all) do
@fetcher = GitHubChangelogGenerator::Fetcher.new
end
describe "#fetch_github_token" do
token = GitHubChangelogGenerator::Fetcher::CHANGELOG_GITHUB_TOKEN
context "when token in ENV exist" do
before { stub_const("ENV", ENV.to_hash.merge(token => "0123456789abcdef")) }
subject { @fetcher.fetch_github_token }
it { is_expected.to eq("0123456789abcdef") }
end
context "when token in ENV is nil" do
before { stub_const("ENV", ENV.to_hash.merge(token => nil)) }
subject { @fetcher.fetch_github_token }
it { is_expected.to be_nil }
end
end
end