Sha256: ce63fd600db04eba9899a9846072fc5ec7155ce58d07cb6f78d444f84a11e9a9

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
RSpec.describe Ferver::FoundFile do
  subject { described_class.new("/dir", "file") }

  describe "#name" do
    it "is the file name" do
      expect(subject.name).to eq "file"
    end
  end

  describe "#path_to_file" do
    it "is the full path to file" do
      expect(subject.path_to_file).to eq "/dir/file"
    end
  end

  describe "#valid?" do
    context "when file exists" do
      before do
        allow(File).to receive(:file?).and_return true
      end

      context "when file is not empty" do
        before do
          allow(File).to receive(:zero?).and_return false
        end

        it "is valid" do
          expect(subject).to be_valid
        end
      end

      context "when file is empty" do
        before do
          allow(File).to receive(:zero?).and_return true
        end

        it "is not valid" do
          expect(subject).not_to be_valid
        end
      end
    end

    context "when file does not exist" do
      before do
        allow(File).to receive(:file?).and_return false
      end

      it "is not valid" do
        expect(subject).not_to be_valid
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ferver-1.4.0 spec/found_file_spec.rb
ferver-1.3.1 spec/found_file_spec.rb