Sha256: c998cab732a62dd07c459ec0d945789df6ec6ceb73aae18d60253b03ae455564

Contents?: true

Size: 1.2 KB

Versions: 19

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path('../../spec_helper',__FILE__)

describe BrowseEverythingHelper do

  let(:test_class) {
    Class.new do
      include BrowseEverythingHelper
      attr_reader :params
      def initialize params
        @params = params
      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

19 entries across 19 versions & 1 rubygems

Version Path
browse-everything-0.10.4 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.10.3 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.10.2 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.10.1 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.10.0 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.9.1 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.9.0 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.8.4 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.8.3 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.8.2 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.8.1 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.8.0 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.7.1 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.7.0 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.6.3 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.6.2 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.6.1 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.6.0 spec/unit/browse_everything_helper_spec.rb
browse-everything-0.5.2 spec/unit/browse_everything_helper_spec.rb