Skip to content

Commit

Permalink
Merge pull request #6384 from samvera/flaky-yml-strat
Browse files Browse the repository at this point in the history
Fix flaky spec by not redefining File and YAML responses
  • Loading branch information
bwatson78 authored Oct 24, 2023
2 parents d6d3485 + 220dfd3 commit 58ae4cc
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions spec/strategies/hyrax/strategies/yaml_strategy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# frozen_string_literal: true
RSpec.describe Hyrax::Strategies::YamlStrategy do
subject { described_class.new(config: "test_file") }
subject { described_class.new(config: tmpfile) }

context "when given a YAML file" do
let(:content) do
{
"assign_admin_set" => {
"enabled" => false
}
}
end
let(:content) { { "assign_admin_set" => { "enabled" => false } }.to_yaml }
let(:tmpfile) { Tempfile.new }

before do
allow(YAML).to receive(:load_file).with("test_file").and_return(content)
allow(File).to receive(:exist?).with("test_file").and_return(true)
tmpfile.write(content)
tmpfile.rewind
end

after do
tmpfile.close
tmpfile.unlink
end

it "tests for features based on an enabled key" do
expect(subject.enabled?(:assign_admin_set)).to eq false
end
Expand All @@ -24,6 +25,8 @@
end

context "when given a non-existent file" do
let(:tmpfile) { "/tmp/non-existent-file" }

it "returns nil for everything" do
expect(subject.enabled?(:assign_admin_set)).to be_nil
end
Expand Down

0 comments on commit 58ae4cc

Please sign in to comment.