Sha256: 31b7b91d140d91b4467a9f75366ffaf32d690c381744e97716402797ccec8b1c
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
# frozen_string_literal: true VALID_TOKEN = "0123456789abcdef" INVALID_TOKEN = "0000000000000000" DEFAULT_OPTIONS = { user: "skywinder", project: "changelog_test" } def options_with_invalid_token options = DEFAULT_OPTIONS options[:token] = INVALID_TOKEN options end 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 => VALID_TOKEN)) } subject { @fetcher.fetch_github_token } it { is_expected.to eq(VALID_TOKEN) } 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 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 describe "#github_fetch_tags" do context "when wrong token provided" do before do options = options_with_invalid_token @fetcher = GitHubChangelogGenerator::Fetcher.new(options) end it "should raise Unauthorized error" do expect { @fetcher.github_fetch_tags }.to raise_error Github::Error::Unauthorized end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
github_changelog_generator-1.13.2 | spec/unit/fetcher_spec.rb |