Sha256: f78e583d0c019b251a1584b0d7226ea1f852b4e50703258142ceeae13d92553e

Contents?: true

Size: 1002 Bytes

Versions: 10

Compression:

Stored size: 1002 Bytes

Contents

require 'rails_helper'

# Mocks the actual shell-out, yeah we're not testing that we don't want
# to have to install mediainfo on travis. A mistake? We'll see.
describe Kithe::MediainfoAnalyzer do
  let(:io) { StringIO.new("fakecontnet") }
  let(:analyzer) { Kithe::MediainfoAnalyzer.new }

  describe "when mediainfo knows mime-type" do
    let(:content_type) { "audio/mpeg" }

    before do
      allow(analyzer.send(:tty_command)).to receive(:run).
        with('mediainfo --Inform="General;%InternetMediaType%"', /.*/).
        and_return(content_type)
    end

    it "returns mime_type" do
      expect(analyzer.call(io)).to eq(content_type)
    end

    it "rewinds" do
      expect(analyzer.call(io))
      expect(io.lineno).to eq(0)
    end
  end

  describe "when mediainfo does not know mime-type" do
    before do
      allow(analyzer.send(:tty_command)).to receive(:run).and_return("\n")
    end

    it "returns mime_type" do
      expect(analyzer.call(io)).to eq(nil)
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kithe-2.0.2 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-2.0.1 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-2.0.0 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-2.0.0.pre.rc1 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-2.0.0.pre.beta1 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-2.0.0.pre.alpha2 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-2.0.0.pre.alpha1 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-1.1.2 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-1.1.1 spec/models/kithe/mediainfo_analyzer_spec.rb
kithe-1.1.0 spec/models/kithe/mediainfo_analyzer_spec.rb