Sha256: 7111e9eee7c0ca14d861697148762fda18252a7400e9dae4f98c458168b76447

Contents?: true

Size: 1.81 KB

Versions: 28

Compression:

Stored size: 1.81 KB

Contents

require 'test_helper'

module Workarea
  class Segment
    module Rules
      class BrowserInfoTest < TestCase
        def test_qualifies?
          refute(BrowserInfo.new.qualifies?(create_visit))

          visit = create_visit('HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15')
          refute(BrowserInfo.new(general: %w(chrome)).qualifies?(visit))
          assert(BrowserInfo.new(general: %w(safari)).qualifies?(visit))
          refute(BrowserInfo.new(device: %w(mobile)).qualifies?(visit))
          assert(BrowserInfo.new(device: %w(unknown)).qualifies?(visit))
          refute(BrowserInfo.new(platform: %w(android)).qualifies?(visit))
          assert(BrowserInfo.new(platform: %w(mac)).qualifies?(visit))
          refute(BrowserInfo.new(general: %w(chrome), device: %w(mobile)).qualifies?(visit))
          assert(BrowserInfo.new(general: %w(safari), device: %w(mobile)).qualifies?(visit))

          visit = create_visit('HTTP_USER_AGENT' => 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10')
          refute(BrowserInfo.new(general: %w(chrome)).qualifies?(visit))
          assert(BrowserInfo.new(general: %w(safari)).qualifies?(visit))
          refute(BrowserInfo.new(device: %w(mobile)).qualifies?(visit))
          assert(BrowserInfo.new(device: %w(ipad)).qualifies?(visit))
          refute(BrowserInfo.new(platform: %w(android)).qualifies?(visit))
          assert(BrowserInfo.new(platform: %w(ios)).qualifies?(visit))
          refute(BrowserInfo.new(general: %w(chrome), platform: %w(mobile)).qualifies?(visit))
          assert(BrowserInfo.new(general: %w(chrome), platform: %w(ios)).qualifies?(visit))
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.26 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.25 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.23 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.22 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.21 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.20 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.19 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.18 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.17 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.16 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.15 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.14 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.13 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.12 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.11 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.10 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.9 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.8 test/models/workarea/segment/rules/browser_info_test.rb
workarea-core-3.5.7 test/models/workarea/segment/rules/browser_info_test.rb