Mock Rails root
This commit is contained in:
parent
13d4927461
commit
f244252ade
|
@ -104,6 +104,8 @@ RSpec.describe Exporter do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#finalize" do
|
describe "#finalize" do
|
||||||
|
let(:fake_rails_root) { Pathname(Dir.mktmpdir) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
instance.instance_variable_set(:@obj, {
|
instance.instance_variable_set(:@obj, {
|
||||||
some: {
|
some: {
|
||||||
|
@ -112,6 +114,7 @@ RSpec.describe Exporter do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
allow(Rails).to receive(:root).and_return(fake_rails_root)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { instance.send(:finalize) }
|
subject { instance.send(:finalize) }
|
||||||
|
@ -122,7 +125,7 @@ RSpec.describe Exporter do
|
||||||
|
|
||||||
it "prepares files to be archived" do
|
it "prepares files to be archived" do
|
||||||
subject
|
subject
|
||||||
expect(File.directory?(Rails.root.join("public/export"))).to eq(true)
|
expect(File.directory?(fake_rails_root.join("public/export"))).to eq(true)
|
||||||
expect(File.directory?("#{dir}/pictures")).to eq(true)
|
expect(File.directory?("#{dir}/pictures")).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue