Sha256: 0893853b76c16f48385121d13974b8447174f510301523860de7d82d8f832f62

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

describe BrowseEverythingHelper do
  let(:test_class) do
    Class.new do
      include BrowseEverythingHelper
      attr_reader :params
      def initialize(params)
        @params = params
      end
    end
  end

  let(:test_file) { BrowseEverything::FileEntry.new 0, '/path/to/file.mp4', 'file.mp4', 12345, Time.now, false }

  it 'should match a full type' do
    expect(test_class.new(accept: 'video/mp4').is_acceptable?(test_file)).to eq(true)
  end

  it 'should match a wildcard type' do
    expect(test_class.new(accept: 'video/*').is_acceptable?(test_file)).to eq(true)
  end

  it 'should not match the wrong full type' do
    expect(test_class.new(accept: 'video/mpeg').is_acceptable?(test_file)).to eq(false)
  end

  it 'should not match the wrong wildcard type' do
    expect(test_class.new(accept: 'audio/*').is_acceptable?(test_file)).to eq(false)
  end

  it 'should match a type list' do
    expect(test_class.new(accept: 'audio/*, video/mp4').is_acceptable?(test_file)).to eq(true)
  end

  it 'should not match the wrong type list' do
    expect(test_class.new(accept: 'audio/*, application/json').is_acceptable?(test_file)).to eq(false)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
browse-everything-0.11.1 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.11.0 spec/unit/browse_everything_helper_spec.rb