Sha256: 44e9410c6bfe529a1e36229bd562673640ee2981610d43ca348b145e944a671e

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

describe FiletypeDetector do
  context '#use' do
    it 'adds filetype if it\'s known' do
      test_file = create_file('file.html', '<html></html>')

      file = double 'file'
      expect(file).to receive(:path).and_return(test_file)
      expect(file).to receive(:filetype=).with('HTML document, ASCII text, with no line terminators')

      detector = FiletypeDetector.new
      detector.use file

    end

    it 'adds error message if an error occured during filetype detection' do
      test_file = SecureRandom.hex

      file = double 'file'
      expect(file).to receive(:path).and_return(test_file)
      allow(file).to receive(:name).and_return(File.basename(test_file))
      expect(file).to receive(:filetype=).with("cannot open `#{test_file}' (No such file or directory)")

      detector = FiletypeDetector.new
      detector.use file

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test_server-0.5.2 spec/filetype_detector_spec.rb
test_server-0.5.1 spec/filetype_detector_spec.rb
test_server-0.5.0 spec/filetype_detector_spec.rb