Sha256: 84e47fb9ef8ca3542f66685d98eb20bcf5e646ee03daf93d70d89263ae10ec4d

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

RSpec.describe GitHubChangelogGenerator::Options do
  describe "#initialize" do
    context "with known options" do
      it "instantiates successfully" do
        expect(described_class.new(user: "olle")[:user]).to eq("olle")
      end
    end

    context "with unknown options" do
      it "raises an error" do
        expect do
          described_class.new(
            project: "rails",
            strength: "super-strength",
            wisdom: "deep"
          )
        end.to raise_error("[:strength, :wisdom]")
      end
    end
  end

  describe "#[]=(key, value)" do
    let(:options) { described_class.new(project: "rails") }

    context "with known options" do
      it "sets the option value" do
        expect do
          options[:project] = "trails"
        end.to change { options[:project] }.to "trails"
      end
    end

    context "with unknown options" do
      it "raises an error" do
        expect do
          options[:charisma] = 8
        end.to raise_error(":charisma")
      end
    end
  end

  describe "#write_to_file?" do
    subject { options.write_to_file? }

    let(:options) { described_class.new(output: output) }

    context "with filename" do
      let(:output) { "CHANGELOG.md" }

      it { is_expected.to eq true }
    end

    context "with nil" do
      let(:output) { nil }

      it { is_expected.to eq false }
    end

    context "with empty string" do
      let(:output) { "" }

      it { is_expected.to eq false }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
github_changelog_generator-1.16.4 spec/unit/options_spec.rb
github_changelog_generator-1.16.3 spec/unit/options_spec.rb
github_changelog_generator-1.16.2 spec/unit/options_spec.rb
github_changelog_generator-1.16.1 spec/unit/options_spec.rb
github_changelog_generator-1.16.0 spec/unit/options_spec.rb
github_changelog_generator-1.15.2 spec/unit/options_spec.rb
github_changelog_generator-1.15.0 spec/unit/options_spec.rb