2016-10-05 19:35:55 +00:00
|
|
|
# frozen_string_literal: true
|
2016-10-05 20:57:28 +00:00
|
|
|
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
|
2016-10-05 21:31:19 +00:00
|
|
|
expect do
|
2016-10-05 20:57:28 +00:00
|
|
|
described_class.new(
|
|
|
|
git_remote: "origin",
|
|
|
|
strength: "super-strength",
|
|
|
|
wisdom: "deep"
|
|
|
|
)
|
2016-10-05 21:31:19 +00:00
|
|
|
end.to raise_error("[:strength, :wisdom]")
|
2016-10-05 20:57:28 +00:00
|
|
|
end
|
|
|
|
end
|
2016-10-05 19:35:55 +00:00
|
|
|
end
|
|
|
|
|
2016-10-05 20:57:28 +00:00
|
|
|
describe "#[]=(key, value)" do
|
|
|
|
let(:options) { described_class.new(git_remote: "origin") }
|
|
|
|
|
|
|
|
context "with known options" do
|
|
|
|
it "sets the option value" do
|
2016-10-05 21:31:19 +00:00
|
|
|
expect do
|
2016-10-05 20:57:28 +00:00
|
|
|
options[:git_remote] = "in the cloud"
|
2016-10-05 21:31:19 +00:00
|
|
|
end.to change { options[:git_remote] }.to "in the cloud"
|
2016-10-05 20:57:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with unknown options" do
|
|
|
|
it "raises an error" do
|
2016-10-05 21:31:19 +00:00
|
|
|
expect do
|
2016-10-05 20:57:28 +00:00
|
|
|
options[:charisma] = 8
|
2016-10-05 21:31:19 +00:00
|
|
|
end.to raise_error(":charisma")
|
2016-10-05 20:57:28 +00:00
|
|
|
end
|
|
|
|
end
|
2016-10-05 19:35:55 +00:00
|
|
|
end
|
|
|
|
end
|