Skip to content

Commit

Permalink
Refactor logic to stub a file as ignored in file_reference_spec.rb
Browse files Browse the repository at this point in the history
See also #248.

I actually had already addressed this in
b63a2a3, but then reverted it to track
the RuboCop violation and didn't realize the revert made it upstream...

This is a better solution anyways, I think.
  • Loading branch information
mokagio committed May 12, 2021
1 parent 1e285d1 commit 81512a3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions spec/file_reference_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
describe '#apply' do
context 'when the destination is not ignored in Git' do
it 'raises' do
allow(Fastlane::Helper::GitHelper).to receive(:is_ignored?)
.with(path: subject.destination_file_path)
.and_return(false)
stub_path_as_ignored(path: subject.destination_file_path, ignored: false)

expect(FileUtils).not_to receive(:mkdir_p)
expect(subject).not_to receive(:source_contents)
Expand All @@ -44,9 +42,7 @@

context 'when the destination is ignored in Git' do
it 'copies the source to the destination' do
allow(Fastlane::Helper::GitHelper).to receive(:is_ignored?)
.with(path: subject.destination_file_path)
.and_return(true)
stub_path_as_ignored(path: subject.destination_file_path, ignored: true)

allow(FileUtils).to receive(:mkdir_p)
allow(subject).to receive(:source_contents).and_return('source contents')
Expand Down Expand Up @@ -131,3 +127,9 @@
end
end
end

def stub_path_as_ignored(path:, ignored:)
allow(Fastlane::Helper::GitHelper).to receive(:is_ignored?)
.with(path: path)
.and_return(ignored)
end

0 comments on commit 81512a3

Please sign in to comment.