Sha256: cfc1e7ca5777d4fb33a104a34ef50746dce29200ee4bb03ae35ee46eda968917

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
require 'wordlist/format'

describe Wordlist::Format do
  describe ".infer" do
    context "when given a path ending in '.txt'" do
      it "must return :txt" do
        expect(subject.infer("path/to/file.txt")).to eq(:txt)
      end
    end

    context "when given a path ending in '.gz'" do
      it "must return :gzip" do
        expect(subject.infer("path/to/file.gz")).to eq(:gzip)
      end
    end

    context "when given a path ending in '.bz2'" do
      it "must return :bzip2" do
        expect(subject.infer("path/to/file.bz2")).to eq(:bzip2)
      end
    end

    context "when given a path ending in '.xz'" do
      it "must return :xz" do
        expect(subject.infer("path/to/file.xz")).to eq(:xz)
      end
    end

    context "when given a path ending in another file extension" do
      let(:path) { "path/to/file.foo" }

      it do
        expect {
          subject.infer(path)
        }.to raise_error(Wordlist::UnknownFormat,"could not infer the format of file: #{path.inspect}")
      end
    end

    context "when given a path has no file extension" do
      let(:path) { "path/to/file" }

      it do
        expect {
          subject.infer(path)
        }.to raise_error(Wordlist::UnknownFormat,"could not infer the format of file: #{path.inspect}")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wordlist-1.0.3 spec/format_spec.rb
wordlist-1.0.2 spec/format_spec.rb
wordlist-1.0.1 spec/format_spec.rb
wordlist-1.0.0 spec/format_spec.rb