Sha256: 2f0f263eeb9af7997bb49a0fe69d99fda3df6e17c087eb4fa1e47fa34bed8e79
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true require "test_helper" class MetaTest < Minitest::Test class CustomRule < Browser::Meta::Base def meta "custom" if browser.ua.include?("Custom") end end test "extends rules" do Browser::Meta.rules.unshift(CustomRule) browser = Browser.new("Custom") assert_includes browser.meta, "custom" browser = Browser.new("Safari") refute_includes browser.meta, "custom" Browser::Meta.rules.shift browser = Browser.new("Custom") refute_includes browser.meta, "custom" end test "sets meta" do browser = Browser.new(Browser["CHROME"]) assert_kind_of Array, browser.meta end test "returns string representation" do browser = Browser.new(Browser["CHROME"]) meta = browser.to_s assert_includes meta, "chrome" assert_includes meta, "webkit" assert_includes meta, "mac" end test "returns string representation for mobile" do browser = Browser.new(Browser["BLACKBERRY"]) meta = browser.to_s assert_includes meta, "blackberry" assert_includes meta, "mobile" end test "returns string representation for unknown platform/device/browser" do browser = Browser.new("Unknown") meta = browser.to_s assert_includes meta, "unknown_platform" assert_includes meta, "unknown_device" assert_includes meta, "unknown_browser" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
browser-6.1.0 | test/unit/meta_test.rb |
browser-6.0.0 | test/unit/meta_test.rb |