Sha256: f266146ace4ecbe59247fd0b1af130d01b47c9a6db3f6b6d4bfebb66f0c57df0

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require "spec_helper"

describe Pidgin2Adium::FileFinder do
  if on_travis_ci?
    before do
      FileUtils.rm_rf(expanded_directory)
    end
  else
    include FakeFS::SpecHelpers
  end

  before do
    FileUtils.mkdir_p(expanded_directory_with_username)
  end

  it "finds .html files" do
    create_file_with_extension("html")

    file_finder = Pidgin2Adium::FileFinder.new(unexpanded_directory)

    expect(file_finder.find).to eq ["#{expanded_directory_with_username}/in.html"]
  end

  it "finds .htm files" do
    create_file_with_extension("htm")

    file_finder = Pidgin2Adium::FileFinder.new(unexpanded_directory)

    expect(file_finder.find).to eq ["#{expanded_directory_with_username}/in.htm"]
  end

  it "finds .txt files" do
    create_file_with_extension("txt")

    file_finder = Pidgin2Adium::FileFinder.new(unexpanded_directory)

    expect(file_finder.find).to eq ["#{expanded_directory_with_username}/in.txt"]
  end

  it "does not find files with other extensions" do
    create_file_with_extension("bad")

    file_finder = Pidgin2Adium::FileFinder.new(unexpanded_directory)

    expect(file_finder.find).to eq []
  end

  def unexpanded_directory
    "~/input-logs/"
  end

  def expanded_directory_with_username
    File.join(expanded_directory, "gabebw")
  end

  def expanded_directory
    File.expand_path(unexpanded_directory)
  end

  def create_file_with_extension(extension)
    FileUtils.touch(File.join(expanded_directory_with_username, "in.#{extension}"))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pidgin2adium-4.0.0.beta2 spec/pidgin2adium/file_finder_spec.rb
pidgin2adium-4.0.0.beta1 spec/pidgin2adium/file_finder_spec.rb