Skip to content

Commit

Permalink
Extend config specs to handle empty external config file
Browse files Browse the repository at this point in the history
  • Loading branch information
apexatoll committed Nov 9, 2023
1 parent 4e7dd8d commit e25d3b7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
24 changes: 16 additions & 8 deletions spec/features/external_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,25 @@ module SomeGem
end

context "and config exists at the specified path" do
let(:config_file) do
<<~YAML
frodo:
race: hobbit
age: 48
YAML
before { config_path.write(config_file) }

context "and config file is empty", skip: :bug_fix do
let(:config_file) { "" }

include_examples :does_not_set_external_config
end

before { config_path.write(config_file) }
context "and config file is not empty" do
let(:config_file) do
<<~YAML
frodo:
race: hobbit
age: 48
YAML
end

include_examples :sets_external_config
include_examples :sets_external_config
end
end
end
end
30 changes: 23 additions & 7 deletions spec/kangaru/configurators/open_configurator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,32 @@
context "when specified file exists" do
let(:exists?) { true }

it "does not raise any errors" do
expect { open_configurator }.not_to raise_error
end
context "and file is empty", skip: :bug_fix do
let(:string_hash) { nil }

it "does not raise any errors" do
expect { open_configurator }.not_to raise_error
end

it "returns an OpenConfigurator" do
expect(open_configurator).to be_a(described_class)
it "returns an OpenConfigurator" do
expect(open_configurator).to be_a(described_class)
end
end

it "parses and sets the attributes" do
expect(open_configurator).to have_attributes(**expected_attributes)
context "and file is not empty" do
let(:string_hash) { { "foo" => "foo", "bar" => "bar", "baz" => "baz" } }

it "does not raise any errors" do
expect { open_configurator }.not_to raise_error
end

it "returns an OpenConfigurator" do
expect(open_configurator).to be_a(described_class)
end

it "parses and sets the attributes" do
expect(open_configurator).to have_attributes(**expected_attributes)
end
end
end
end
Expand Down

0 comments on commit e25d3b7

Please sign in to comment.