From 460a32ce8316b12d018411ada0ecc3ee396890da Mon Sep 17 00:00:00 2001 From: Orien Madgwick <497874+orien@users.noreply.github.com> Date: Wed, 25 Jan 2023 22:56:35 +1100 Subject: [PATCH 1/4] Use GitHub Actions for CI --- .github/workflows/test.yml | 21 +++++++++++++++++++++ .travis.yml | 14 -------------- README.md | 2 +- useragent.gemspec | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1cd06e4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +--- +name: Tests +on: [ push, pull_request ] +jobs: + test: + name: Test (Ruby ${{ matrix.ruby }}) + runs-on: ubuntu-${{ matrix.ubuntu }} + strategy: + fail-fast: false + matrix: + ruby: [ '3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4', '2.3', 'jruby-9.4' ] + ubuntu: [ 'latest' ] + include: + - { ruby: '2.2', ubuntu: '20.04' } + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4cf28fd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: ruby -cache: bundler -sudo: false - -before_install: - - gem update --system - -rvm: - - 2.2 - - 2.3 - - 2.4 - - 2.5 - - 2.6 - - jruby-head diff --git a/README.md b/README.md index fda1b7e..b4a7e7d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # UserAgent -[![Build Status](https://travis-ci.org/gshutler/useragent.svg?branch=master)](https://travis-ci.org/gshutler/useragent) +[![Build Status](https://github.com/gshutler/useragent/actions/workflows/test.yml/badge.svg)](https://github.com/gshutler/useragent/actions/workflows/test.yml) [![Gem Version](https://badge.fury.io/rb/useragent.svg)](http://badge.fury.io/rb/useragent) UserAgent is a Ruby library that parses and compares HTTP User Agents. diff --git a/useragent.gemspec b/useragent.gemspec index dc2c5eb..953ae63 100644 --- a/useragent.gemspec +++ b/useragent.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |s| s.files = Dir["LICENSE", "README.md", "lib/**/*.rb"] - s.add_development_dependency "rake", "~> 10.0" + s.add_development_dependency "rake", "~> 13.0" s.add_development_dependency "rspec", "~> 3.0" s.authors = ["Joshua Peek", "Garry Shutler"] From 22d2271e88af1d0eea22e25ae4ce841ae7408dbb Mon Sep 17 00:00:00 2001 From: Ankur Patel Date: Mon, 28 Oct 2024 20:49:25 -0700 Subject: [PATCH 2/4] Adding fix for Chrome Lighthouse not being detected as a bot --- lib/user_agent/browsers/base.rb | 4 ++++ spec/browsers/chrome_lighthouse_user_agent_spec.rb | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 spec/browsers/chrome_lighthouse_user_agent_spec.rb diff --git a/lib/user_agent/browsers/base.rb b/lib/user_agent/browsers/base.rb index eda5a11..86e5e9d 100644 --- a/lib/user_agent/browsers/base.rb +++ b/lib/user_agent/browsers/base.rb @@ -78,6 +78,10 @@ def bot? # list will be rejected. elsif detect_comment_match(/bot/i) true + # Google PageSpeed Insights adds "Chrome-Lighthouse" to the user agent + # https://stackoverflow.com/questions/16403295/what-is-the-name-of-the-google-pagespeed-user-agent + elsif detect_product("Chrome-Lighthouse") + true elsif product = application.product product.include?('bot') else diff --git a/spec/browsers/chrome_lighthouse_user_agent_spec.rb b/spec/browsers/chrome_lighthouse_user_agent_spec.rb new file mode 100644 index 0000000..5f54d4a --- /dev/null +++ b/spec/browsers/chrome_lighthouse_user_agent_spec.rb @@ -0,0 +1,9 @@ +require 'user_agent' + +describe "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4590.2 Safari/537.36 Chrome-Lighthouse" do + before do + @useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4590.2 Safari/537.36 Chrome-Lighthouse") + end + + it { expect(@useragent).to be_bot } +end From 680915aa9e271592fac15d9853da1ff5e589da06 Mon Sep 17 00:00:00 2001 From: Garry Shutler Date: Wed, 4 Dec 2024 11:50:09 +0000 Subject: [PATCH 3/4] Prepare 0.16.11 --- useragent.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/useragent.gemspec b/useragent.gemspec index 953ae63..feff0ed 100644 --- a/useragent.gemspec +++ b/useragent.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "useragent" - s.version = "0.16.10" + s.version = "0.16.11" s.homepage = "https://github.com/gshutler/useragent" s.summary = "HTTP User Agent parser" From df9a605b6442638b18c3f7b628e98c83c32760a4 Mon Sep 17 00:00:00 2001 From: Manel Ghorbal <41969874+mghorb@users.noreply.github.com> Date: Wed, 2 Jul 2025 14:15:36 -0700 Subject: [PATCH 4/4] Specify whether each browser is a web browser or not --- lib/user_agent/browsers/base.rb | 4 + lib/user_agent/browsers/chrome.rb | 4 + lib/user_agent/browsers/edge.rb | 4 + lib/user_agent/browsers/gecko.rb | 4 + lib/user_agent/browsers/internet_explorer.rb | 4 + lib/user_agent/browsers/opera.rb | 4 + lib/user_agent/browsers/samsung.rb | 31 +++ lib/user_agent/browsers/vivaldi.rb | 4 + lib/user_agent/browsers/webkit.rb | 4 + lib/user_agent/browsers/wechat_browser.rb | 4 + spec/browsers/acast_user_agent_spec.rb | 51 ++++ .../air_traffic_framework_user_agent_spec.rb | 190 ++++++++++++++ spec/browsers/airr_user_agent_spec.rb | 40 +++ spec/browsers/alexa_user_agent_spec.rb | 59 +++++ spec/browsers/amazon_echo_user_agent_spec.rb | 31 +++ spec/browsers/amazon_music_user_agent_spec.rb | 71 ++++++ ...ndroid_download_manager_user_agent_spec.rb | 39 +++ spec/browsers/android_user_agent_spec.rb | 57 +++++ .../apple_home_pod_user_agent_spec.rb | 39 +++ .../apple_podcasts_user_agent_spec.rb | 173 +++++++++++++ spec/browsers/audible_user_agent_spec.rb | 45 ++++ spec/browsers/audio_clip_user_agent_spec.rb | 51 ++++ spec/browsers/beyond_pod_user_agent_spec.rb | 37 +++ spec/browsers/black_berry_user_agent_spec.rb | 41 +++ spec/browsers/breaker_user_agent_spec.rb | 75 ++++++ spec/browsers/castbox_user_agent_spec.rb | 69 +++++ spec/browsers/castro_user_agent_spec.rb | 81 ++++++ spec/browsers/chrome_user_agent_spec.rb | 25 ++ .../deezer_crawler_user_agent_spec.rb | 24 ++ spec/browsers/deezer_user_agent_spec.rb | 87 +++++++ .../downcast_crawler_user_agent_spec.rb | 24 ++ spec/browsers/downcast_user_agent_spec.rb | 69 +++++ spec/browsers/edge_user_agent_spec.rb | 20 ++ spec/browsers/facebook_user_agent_spec.rb | 69 +++++ spec/browsers/gecko_user_agent_spec.rb | 16 ++ spec/browsers/google_home_user_agent_spec.rb | 57 +++++ .../google_podcasts_user_agent_spec.rb | 69 +++++ spec/browsers/googlebot_user_agent_spec.rb | 107 ++++++++ spec/browsers/himalaya_user_agent_spec.rb | 63 +++++ spec/browsers/icatcher_user_agent_spec.rb | 75 ++++++ spec/browsers/iheart_radio_user_agent_spec.rb | 75 ++++++ .../internet_explorer_user_agent_spec.rb | 12 + spec/browsers/iron_user_agent_spec.rb | 8 + spec/browsers/itunes_user_agent_spec.rb | 6 + spec/browsers/luminary_user_agent_spec.rb | 57 +++++ spec/browsers/npr_one_user_agent_spec.rb | 51 ++++ spec/browsers/ok_http_user_agent_spec.rb | 62 +++++ spec/browsers/opera_user_agent_spec.rb | 15 ++ spec/browsers/other_user_agent_spec.rb | 3 + spec/browsers/overcast_user_agent_spec.rb | 57 +++++ .../pandora_rss_crawler_user_agent_spec.rb | 27 ++ spec/browsers/pandora_user_agent_spec.rb | 93 +++++++ spec/browsers/playstation_user_agent_spec.rb | 2 + spec/browsers/pocket_casts_user_agent_spec.rb | 90 +++++++ spec/browsers/pod_2_watch_spec.rb | 58 +++++ spec/browsers/pod_mn_user_agent_spec.rb | 57 +++++ spec/browsers/podbean_user_agent_spec.rb | 63 +++++ .../podcast_addict_user_agent_spec.rb | 8 +- .../podcast_republic_user_agent_spec.rb | 39 +++ spec/browsers/podimo_user_agent_spec.rb | 45 ++++ spec/browsers/podkicker_user_agent_spec.rb | 45 ++++ spec/browsers/podverse_user_agent_spec.rb | 63 +++++ .../radio_public_crawler_user_agent_spec.rb | 24 ++ spec/browsers/radio_public_user_agent_spec.rb | 69 +++++ spec/browsers/samsung_user_agent_spec.rb | 61 +++++ spec/browsers/sonos_user_agent_spec.rb | 48 ++++ spec/browsers/sound_on_user_agent_spec.rb | 69 +++++ spec/browsers/spotify_user_agent_spec.rb | 111 +++++++++ spec/browsers/spreaker_user_agent_spec.rb | 69 +++++ spec/browsers/stagefright_user_agent_spec.rb | 235 ++++++++++++++++++ spec/browsers/stitcher_bot_user_agent_spec.rb | 29 +++ spec/browsers/stitcher_user_agent_spec.rb | 99 ++++++++ .../the_podcast_app_user_agent_spec.rb | 45 ++++ spec/browsers/tune_in_user_agent_spec.rb | 123 +++++++++ spec/browsers/vivaldi_user_agent_spec.rb | 6 + spec/browsers/webkit_user_agent_spec.rb | 16 ++ .../wechat_browser_user_agent_spec.rb | 2 + .../windows_media_player_user_agent_spec.rb | 16 ++ spec/browsers/wondery_user_agent_spec.rb | 111 +++++++++ 79 files changed, 3987 insertions(+), 3 deletions(-) create mode 100644 lib/user_agent/browsers/samsung.rb create mode 100644 spec/browsers/acast_user_agent_spec.rb create mode 100644 spec/browsers/air_traffic_framework_user_agent_spec.rb create mode 100644 spec/browsers/airr_user_agent_spec.rb create mode 100644 spec/browsers/alexa_user_agent_spec.rb create mode 100644 spec/browsers/amazon_echo_user_agent_spec.rb create mode 100644 spec/browsers/amazon_music_user_agent_spec.rb create mode 100644 spec/browsers/android_download_manager_user_agent_spec.rb create mode 100644 spec/browsers/android_user_agent_spec.rb create mode 100644 spec/browsers/apple_home_pod_user_agent_spec.rb create mode 100644 spec/browsers/apple_podcasts_user_agent_spec.rb create mode 100644 spec/browsers/audible_user_agent_spec.rb create mode 100644 spec/browsers/audio_clip_user_agent_spec.rb create mode 100644 spec/browsers/beyond_pod_user_agent_spec.rb create mode 100644 spec/browsers/black_berry_user_agent_spec.rb create mode 100644 spec/browsers/breaker_user_agent_spec.rb create mode 100644 spec/browsers/castbox_user_agent_spec.rb create mode 100644 spec/browsers/castro_user_agent_spec.rb create mode 100644 spec/browsers/deezer_crawler_user_agent_spec.rb create mode 100644 spec/browsers/deezer_user_agent_spec.rb create mode 100644 spec/browsers/downcast_crawler_user_agent_spec.rb create mode 100644 spec/browsers/downcast_user_agent_spec.rb create mode 100644 spec/browsers/facebook_user_agent_spec.rb create mode 100644 spec/browsers/google_home_user_agent_spec.rb create mode 100644 spec/browsers/google_podcasts_user_agent_spec.rb create mode 100644 spec/browsers/googlebot_user_agent_spec.rb create mode 100644 spec/browsers/himalaya_user_agent_spec.rb create mode 100644 spec/browsers/icatcher_user_agent_spec.rb create mode 100644 spec/browsers/iheart_radio_user_agent_spec.rb create mode 100644 spec/browsers/luminary_user_agent_spec.rb create mode 100644 spec/browsers/npr_one_user_agent_spec.rb create mode 100644 spec/browsers/ok_http_user_agent_spec.rb create mode 100644 spec/browsers/overcast_user_agent_spec.rb create mode 100644 spec/browsers/pandora_rss_crawler_user_agent_spec.rb create mode 100644 spec/browsers/pandora_user_agent_spec.rb create mode 100644 spec/browsers/pocket_casts_user_agent_spec.rb create mode 100644 spec/browsers/pod_2_watch_spec.rb create mode 100644 spec/browsers/pod_mn_user_agent_spec.rb create mode 100644 spec/browsers/podbean_user_agent_spec.rb create mode 100644 spec/browsers/podcast_republic_user_agent_spec.rb create mode 100644 spec/browsers/podimo_user_agent_spec.rb create mode 100644 spec/browsers/podkicker_user_agent_spec.rb create mode 100644 spec/browsers/podverse_user_agent_spec.rb create mode 100644 spec/browsers/radio_public_crawler_user_agent_spec.rb create mode 100644 spec/browsers/radio_public_user_agent_spec.rb create mode 100644 spec/browsers/samsung_user_agent_spec.rb create mode 100644 spec/browsers/sonos_user_agent_spec.rb create mode 100644 spec/browsers/sound_on_user_agent_spec.rb create mode 100644 spec/browsers/spotify_user_agent_spec.rb create mode 100644 spec/browsers/spreaker_user_agent_spec.rb create mode 100644 spec/browsers/stagefright_user_agent_spec.rb create mode 100644 spec/browsers/stitcher_bot_user_agent_spec.rb create mode 100644 spec/browsers/stitcher_user_agent_spec.rb create mode 100644 spec/browsers/the_podcast_app_user_agent_spec.rb create mode 100644 spec/browsers/tune_in_user_agent_spec.rb create mode 100644 spec/browsers/wondery_user_agent_spec.rb diff --git a/lib/user_agent/browsers/base.rb b/lib/user_agent/browsers/base.rb index 86e5e9d..8781560 100644 --- a/lib/user_agent/browsers/base.rb +++ b/lib/user_agent/browsers/base.rb @@ -32,6 +32,10 @@ def browser application && application.product end + def web_browser? + false + end + def version application && application.version end diff --git a/lib/user_agent/browsers/chrome.rb b/lib/user_agent/browsers/chrome.rb index d26b1a9..e210692 100644 --- a/lib/user_agent/browsers/chrome.rb +++ b/lib/user_agent/browsers/chrome.rb @@ -19,6 +19,10 @@ def build webkit.version end + def web_browser? + true + end + # Prior to Safari 3, the user agent did not include a version number def version str = if detect_product("CriOs") diff --git a/lib/user_agent/browsers/edge.rb b/lib/user_agent/browsers/edge.rb index 8b9a8c7..24cbe8e 100644 --- a/lib/user_agent/browsers/edge.rb +++ b/lib/user_agent/browsers/edge.rb @@ -23,6 +23,10 @@ def os OperatingSystems.normalize_os(os_comment) end + def web_browser? + true + end + private def os_comment diff --git a/lib/user_agent/browsers/gecko.rb b/lib/user_agent/browsers/gecko.rb index 649d04a..42d1a42 100644 --- a/lib/user_agent/browsers/gecko.rb +++ b/lib/user_agent/browsers/gecko.rb @@ -17,6 +17,10 @@ def browser GeckoBrowsers.detect { |browser| respond_to?(browser) } || super end + def web_browser? + true + end + def version v = send(browser).version v.nil? ? super : v diff --git a/lib/user_agent/browsers/internet_explorer.rb b/lib/user_agent/browsers/internet_explorer.rb index 5e7b35e..1a4d5a2 100644 --- a/lib/user_agent/browsers/internet_explorer.rb +++ b/lib/user_agent/browsers/internet_explorer.rb @@ -20,6 +20,10 @@ def browser "Internet Explorer" end + def web_browser? + true + end + def version str = application.comment.join('; ')[/(MSIE\s|rv:)([\d\.]+)/, 2] Version.new(str) diff --git a/lib/user_agent/browsers/opera.rb b/lib/user_agent/browsers/opera.rb index 86adb68..d3e3b86 100644 --- a/lib/user_agent/browsers/opera.rb +++ b/lib/user_agent/browsers/opera.rb @@ -11,6 +11,10 @@ def browser 'Opera' end + def web_browser? + true + end + def version if mini? Version.new(application.comment.detect{|c| c =~ /Opera Mini/}[/Opera Mini\/([\d\.]+)/, 1]) rescue Version.new diff --git a/lib/user_agent/browsers/samsung.rb b/lib/user_agent/browsers/samsung.rb new file mode 100644 index 0000000..734d4b3 --- /dev/null +++ b/lib/user_agent/browsers/samsung.rb @@ -0,0 +1,31 @@ +class UserAgent + module Browsers + class Samsung < Webkit + + SAMSUNG_BROWSER = 'SamsungBrowser' + + def self.extend?(agent) + agent.detect { |useragent| useragent.product == SAMSUNG_BROWSER } + end + + def version + self.detect { |useragent| useragent.product == SAMSUNG_BROWSER }.version + end + + ## + # @return [Boolean] + # SamsungBrowser is a mobile device + def mobile? + true + end + + def browser + 'Samsung Internet Browser' + end + + def web_browser? + true + end + end + end +end diff --git a/lib/user_agent/browsers/vivaldi.rb b/lib/user_agent/browsers/vivaldi.rb index 013f558..9d466cc 100644 --- a/lib/user_agent/browsers/vivaldi.rb +++ b/lib/user_agent/browsers/vivaldi.rb @@ -35,6 +35,10 @@ def platform end end + def web_browser? + true + end + def webkit detect_product("AppleWebKit") end diff --git a/lib/user_agent/browsers/webkit.rb b/lib/user_agent/browsers/webkit.rb index 50ee150..069da28 100644 --- a/lib/user_agent/browsers/webkit.rb +++ b/lib/user_agent/browsers/webkit.rb @@ -86,6 +86,10 @@ def platform end end + def web_browser? + true + end + def webkit if product_match = detect { |useragent| useragent.product =~ WEBKIT_PRODUCT_REGEXP } product_match diff --git a/lib/user_agent/browsers/wechat_browser.rb b/lib/user_agent/browsers/wechat_browser.rb index c6c097c..712929f 100644 --- a/lib/user_agent/browsers/wechat_browser.rb +++ b/lib/user_agent/browsers/wechat_browser.rb @@ -9,6 +9,10 @@ def browser 'Wechat Browser' end + def web_browser? + true + end + def version micro_messenger = detect_product("MicroMessenger") Version.new(micro_messenger.version) diff --git a/spec/browsers/acast_user_agent_spec.rb b/spec/browsers/acast_user_agent_spec.rb new file mode 100644 index 0000000..9107f6f --- /dev/null +++ b/spec/browsers/acast_user_agent_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Acast' do |version, platform, os| + it "returns 'Acast' as its browser" do + expect(useragent.browser).to eq('Acast') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Acast/1.63.0 (Phone; iOS 11.2.6; iPad6,11)" do + let!(:useragent) { UserAgent.parse("Acast/1.63.0 (Phone; iOS 11.2.6; iPad6,11)") } + + it_behaves_like 'Acast', '1.63.0', 'iPad', 'iOS 11.2.6' +end + +describe "UserAgent: Acast/1.63.0 (Phone; iOS 11.2.5; iPhone9,4)" do + let!(:useragent) { UserAgent.parse("Acast/1.63.0 (Phone; iOS 11.2.5; iPhone9,4)") } + + it_behaves_like 'Acast', '1.63.0', 'iPhone', 'iOS 11.2.5' +end + +describe "UserAgent: Acast/1.42.1 (phone; android 10; Google Pixel 3 XL)" do + let!(:useragent) { UserAgent.parse("Acast/1.42.1 (phone; android 10; Google Pixel 3 XL)") } + + it_behaves_like 'Acast', '1.42.1', 'Android', 'Android 10' +end + +describe "UserAgent: Acast/1.26.0 (Linux;Android 9) ExoPlayerLib/2.2.0" do + let!(:useragent) { UserAgent.parse("Acast/1.26.0 (Linux;Android 9) ExoPlayerLib/2.2.0") } + + it_behaves_like 'Acast', '1.26.0', 'Android', 'Android 9' +end diff --git a/spec/browsers/air_traffic_framework_user_agent_spec.rb b/spec/browsers/air_traffic_framework_user_agent_spec.rb new file mode 100644 index 0000000..05d9589 --- /dev/null +++ b/spec/browsers/air_traffic_framework_user_agent_spec.rb @@ -0,0 +1,190 @@ +# frozen_string_literal: true + +require 'user_agent' + +describe UserAgent::Browsers::AirTrafficFramework do + let(:user_agent) { UserAgent.parse(ua_string) } + + shared_examples 'an ATC browser' do |version = nil| + it { expect(user_agent.browser).to eql 'atc' } + it { expect(user_agent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } + + if version + it { expect(user_agent.version.to_s).to eql version } + else + it { expect(user_agent.version).to be_nil } + end + end + + shared_examples 'a browser on unknown OS' do + it { expect(user_agent.os).to be_nil} + end + + shared_examples 'a browser on Apple Watch / watchOS' do |os_version = nil| + it { expect(user_agent.os).to eql ['watchOS', os_version].compact.join(' ') } + it { expect(user_agent.platform).to eql 'Apple Watch' } + it { expect(user_agent).to be_mobile } + end + + shared_examples 'a browser on Macintosh / macOS' do |os_version = nil| + it { expect(user_agent.os).to eq ['macOS', os_version].compact.join(' ') } + it { expect(user_agent.platform).to eql 'Macintosh' } + it { expect(user_agent).not_to be_mobile } + end + + shared_examples 'a browser on an iOS device' do |os_version = nil| + it { expect(user_agent.os).to eq ['iOS', os_version].compact.join(' ') } + it { expect(user_agent.platform).to eql 'iOS' } + it { expect(user_agent).to be_mobile } + end + + context 'with "(null)/(null) watchOS/5.0 model/Watch2 ,7 hwp/t8002 build/16R349 (6; dt:149)"' do + let(:ua_string) { '(null)/(null) watchOS/5.0 model/Watch2 ,7 hwp/t8002 build/16R349 (6; dt:149)' } + + it_behaves_like 'an ATC browser' + it_behaves_like 'a browser on Apple Watch / watchOS', '5.0' + end + + context 'with "(null)/(null) model/Watch2"' do + let(:ua_string) { '(null)/(null) model/Watch2' } + + it { expect(user_agent.browser).to eql '(null)' } + it { expect(user_agent).not_to be_bot } + it { expect(user_agent).not_to be_mobile } + it { expect(user_agent.os).to be_nil } + it { expect(user_agent.platform).to be_nil } + it { expect(user_agent.version.to_s).to eql '(null)' } + end + + context 'with "atc/1.0 watchOS/5.0 model/Watch3 ,1 hwp/t8004 build/16R120 (6; dt:153)"' do + let(:ua_string) { 'atc/1.0 watchOS/4.2 model/Watch3 ,1 hwp/t8004 build/16R120 (6; dt:153)' } + + it_behaves_like 'an ATC browser', '1.0.16R120' + it_behaves_like 'a browser on Apple Watch / watchOS', '4.2' + end + + context 'with "atc/1.0 watchOS model/Watch3 ,1 hwp/t8004 build/17R90 (6; dt:153)"' do + let(:ua_string) { 'atc/1.0 watchOS model/Watch3 ,1 hwp/t8004 build/17R90 (6; dt:153)' } + + it_behaves_like 'an ATC browser', '1.0.17R90' + it_behaves_like 'a browser on Apple Watch / watchOS' + end + + context 'with "atc/1.0 watchOS/6.0 model/Watch3 ,1 hwp/t8004"' do + let(:ua_string) { 'atc/1.0 watchOS/6.0 model/Watch3 ,1 hwp/t8004' } + + it_behaves_like 'an ATC browser', '1.0' + it_behaves_like 'a browser on Apple Watch / watchOS', '6.0' + end + + context 'with "atc watchOS"' do + let(:ua_string) { 'atc watchOS' } + + it_behaves_like 'an ATC browser' + it_behaves_like 'a browser on Apple Watch / watchOS' + end + + context 'with "atc watchOS build/19R150"' do + let(:ua_string) { 'atc watchOS build/19R150' } + + it_behaves_like 'an ATC browser', '.19R150' + it_behaves_like 'a browser on Apple Watch / watchOS' + end + + context 'with "atc/"' do + let(:ua_string) { 'atc/' } + + it_behaves_like 'an ATC browser' + it_behaves_like 'a browser on unknown OS' + end + + context 'with "atc/1.0"' do + let(:ua_string) { 'atc/1.0' } + + it_behaves_like 'an ATC browser', '1.0' + it_behaves_like 'a browser on unknown OS' + end + + context 'with "atc/1.1"' do + let(:ua_string) { 'atc/1.1' } + + it_behaves_like 'an ATC browser', '1.1' + it_behaves_like 'a browser on unknown OS' + end + + context 'with "atc/2.0"' do + let(:ua_string) { 'atc/2.0' } + + it_behaves_like 'an ATC browser', '2.0' + it_behaves_like 'a browser on unknown OS' + end + + context 'with "atc/1.0 model/Watch3 hwp/t8004 build/17R50 (6; dt:154)"' do + let(:ua_string) { 'atc/1.0 model/Watch3 hwp/t8004 build/17R50 (6; dt:154)' } + + it_behaves_like 'an ATC browser', '1.0.17R50' + it_behaves_like 'a browser on unknown OS' + end + + context 'with "atc/1.1 Darwin/19.0.0 (x86_64)"' do + let(:ua_string) { 'atc/1.1 Darwin/19.0.0 (x86_64)' } + + it_behaves_like 'an ATC browser', '1.1' + it_behaves_like 'a browser on Macintosh / macOS', '10.15' + end + + context 'with "atc/1.1 Darwin (x86_64)"' do + let(:ua_string) { 'atc/1.1 Darwin (x86_64)' } + + it_behaves_like 'an ATC browser', '1.1' + it_behaves_like 'a browser on Macintosh / macOS' + end + + context 'with "atc Darwin (x86_64)"' do + let(:ua_string) { 'atc Darwin (x86_64)' } + + it_behaves_like 'an ATC browser' + it_behaves_like 'a browser on Macintosh / macOS' + end + + context 'with "atc/ build/17R50 Darwin/21.5.0 (x86_64)"' do + let(:ua_string) { 'atc/ build/17R50 Darwin/21.5.0 (x86_64)' } + + it_behaves_like 'an ATC browser', '.17R50' + it_behaves_like 'a browser on Macintosh / macOS', '12.4' + end + + context 'with "Darwin/21.5.0 (x86_64)"' do + let(:ua_string) { "Darwin/21.5.0 (x86_64)" } + + it { expect(user_agent.browser).not_to eql 'AirTraffic.framework' } + end + + context 'with "atc/2.0 AppleTV/4.1"' do + let(:ua_string) { 'atc/2.0 AppleTV/4.1' } + + it_behaves_like 'an ATC browser', '2.0' + it_behaves_like 'a browser on unknown OS' + end + + context 'with "atc/1.0 Darwin/22.0.0' do + let(:ua_string) { "atc/1.0 Darwin/22.0.0" } + + it_behaves_like 'an ATC browser', '1.0' + it_behaves_like 'a browser on an iOS device', '16.0.x' + end + + context 'with "atc Darwin"' do + let(:ua_string) { "atc Darwin" } + + it_behaves_like 'an ATC browser' + it_behaves_like 'a browser on an iOS device' + end + + context 'with "Darwin"' do + let(:ua_string) { "Darwin" } + + it { expect(user_agent.browser).not_to eql 'AirTraffic.framework' } + end +end diff --git a/spec/browsers/airr_user_agent_spec.rb b/spec/browsers/airr_user_agent_spec.rb new file mode 100644 index 0000000..bd43403 --- /dev/null +++ b/spec/browsers/airr_user_agent_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Airr' do |version, os| + it "returns 'Airr' as its browser" do + expect(useragent.browser).to eq('Airr') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'iPhone' as its platform" do + expect(useragent.platform).to eq('iPhone') + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Airr/3916 CFNetwork/1202 Darwin/20.1.0" do + let!(:useragent) { UserAgent.parse("Airr/3916 CFNetwork/1202 Darwin/20.1.0") } + + it_behaves_like 'Airr', '3916', 'iOS 14.2.x' +end + +describe "UserAgent: Airr/3186 CFNetwork/1128.0.1 Darwin/19.6.0" do + let!(:useragent) { UserAgent.parse("Airr/3186 CFNetwork/1128.0.1 Darwin/19.6.0") } + + it_behaves_like 'Airr', '3186', 'iOS 13.6.x' +end + diff --git a/spec/browsers/alexa_user_agent_spec.rb b/spec/browsers/alexa_user_agent_spec.rb new file mode 100644 index 0000000..1b11edd --- /dev/null +++ b/spec/browsers/alexa_user_agent_spec.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Alexa' do |version, os, type| + it "returns 'Alexa' as its browser" do + expect(useragent.browser).to eq('Alexa') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'Android' as its platform" do + expect(useragent.platform).to eq('Android') + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :speaker + it { expect(useragent).to be_speaker } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + else + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + end + + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: AlexaMediaPlayer/1.0.1560.0 (Linux;Android 10) ExoPlayerLib/1.5.9" do + let!(:useragent) { UserAgent.parse("AlexaMediaPlayer/1.0.1560.0 (Linux;Android 10) ExoPlayerLib/1.5.9") } + + it_behaves_like 'Alexa', '1.0.1560.0', 'Android 10', :speaker +end + +describe "UserAgent: AlexaMediaPlayer/1.0.2098.2 (Linux;Android 5.1.1) ExoPlayerLib/1.5.9" do + let!(:useragent) { UserAgent.parse("AlexaMediaPlayer/1.0.2098.2 (Linux;Android 5.1.1) ExoPlayerLib/1.5.9") } + + it_behaves_like 'Alexa', '1.0.2098.2', 'Android 5.1.1', :speaker +end + +describe "UserAgent: Alexa Mobile Voice/17.8.5 (Linux;Android 11) ExoPlayerLib/2.5.4" do + let!(:useragent) { UserAgent.parse("Alexa Mobile Voice/17.8.5 (Linux;Android 11) ExoPlayerLib/2.5.4") } + + it_behaves_like 'Alexa', '17.8.5', 'Android 11' +end + +describe "UserAgent: Alexa Mobile Voice/1.0.0 (Linux;Android 8.1.0) ExoPlayerLib/2.2.0" do + let!(:useragent) { UserAgent.parse("Alexa Mobile Voice/1.0.0 (Linux;Android 8.1.0) ExoPlayerLib/2.2.0") } + + it_behaves_like 'Alexa', '1.0.0', 'Android 8.1.0' +end diff --git a/spec/browsers/amazon_echo_user_agent_spec.rb b/spec/browsers/amazon_echo_user_agent_spec.rb new file mode 100644 index 0000000..a7848e1 --- /dev/null +++ b/spec/browsers/amazon_echo_user_agent_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Amazon Echo' do |version| + it "returns 'Amazon Echo' as its browser" do + expect(useragent.browser).to eq('Amazon Echo') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it { expect(useragent).to be_speaker } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe 'UserAgent: Echo/1.0(APNG)' do + let(:useragent) { UserAgent.parse('Echo/1.0(APNG)') } + + it_behaves_like 'Amazon Echo', '1.0' +end + +describe 'UserAgent: Echo/1.0(MRM)' do + let(:useragent) { UserAgent.parse('Echo/1.0(MRM)') } + + it_behaves_like 'Amazon Echo', '1.0' +end diff --git a/spec/browsers/amazon_music_user_agent_spec.rb b/spec/browsers/amazon_music_user_agent_spec.rb new file mode 100644 index 0000000..3d28d50 --- /dev/null +++ b/spec/browsers/amazon_music_user_agent_spec.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Amazon Music' do |version, platform, os, type| + it "returns 'Amazon Music' as its browser" do + expect(useragent.browser).to eq('Amazon Music') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + elsif type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + end + + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: AmazonMusic/17.7.2 Mozilla/5.0 (Linux; Android 8.1.0; 5059X Build/O11019; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36" do + let!(:useragent) { UserAgent.parse("AmazonMusic/17.7.2 Mozilla/5.0 (Linux; Android 8.1.0; 5059X Build/O11019; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36") } + + it_behaves_like 'Amazon Music', '17.7.2', 'Android', 'Android 8.1.0', :mobile +end + +describe "UserAgent: AmazonMusic/10.0.0 iPad8,9 CFNetwork/1220.1 Darwin/20.3.0" do + let!(:useragent) { UserAgent.parse("AmazonMusic/10.0.0 iPad8,9 CFNetwork/1220.1 Darwin/20.3.0") } + + it_behaves_like 'Amazon Music', '10.0.0', 'iPad', 'iOS 14.4.x', :mobile +end + +describe "UserAgent: AmazonMusic/10.2.0 iPhone11,6 CFNetwork/1237 Darwin/20.4.0" do + let!(:useragent) { UserAgent.parse("AmazonMusic/10.2.0 iPhone11,6 CFNetwork/1237 Darwin/20.4.0") } + + it_behaves_like 'Amazon Music', '10.2.0', 'iPhone', 'iOS 14.5', :mobile +end + +describe "UserAgent: AmazonMusic/1.0 x86_64 CFNetwork/1121.2.1 Darwin/19.6.0" do + let!(:useragent) { UserAgent.parse("AmazonMusic/1.0 x86_64 CFNetwork/1121.2.1 Darwin/19.6.0") } + + it_behaves_like 'Amazon Music', '1.0', 'Macintosh', 'macOS 10.15.6', :desktop +end + +describe "UserAgent: AmazonMusic/16.17.1 Dalvik/2.1.0 (Linux; U; Android 7.0; LGL83BL Build/NRD90U)" do + let!(:useragent) { UserAgent.parse("AmazonMusic/16.17.1 Dalvik/2.1.0 (Linux; U; Android 7.0; LGL83BL Build/NRD90U)") } + + it_behaves_like 'Amazon Music', '16.17.1', 'Android', 'Android 7.0', :mobile +end + +describe "UserAgent: AmazonMusic" do + let!(:useragent) { UserAgent.parse("AmazonMusic") } + + it_behaves_like 'Amazon Music', nil, nil, nil, nil +end diff --git a/spec/browsers/android_download_manager_user_agent_spec.rb b/spec/browsers/android_download_manager_user_agent_spec.rb new file mode 100644 index 0000000..8e418b6 --- /dev/null +++ b/spec/browsers/android_download_manager_user_agent_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'AndroidDownloadManager' do |version, os| + it "returns 'Android Download Manager' as its browser" do + expect(useragent.browser).to eq('Android Download Manager') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'Android' as its platform" do + expect(useragent.platform).to eq('Android') + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: AndroidDownloadManager/10 (Linux; U; Android 10; HMA-AL00 Build/HUAWEIHMA-AL00)" do + let(:useragent) { UserAgent.parse("AndroidDownloadManager/10 (Linux; U; Android 10; HMA-AL00 Build/HUAWEIHMA-AL00)") } + + it_behaves_like 'AndroidDownloadManager', '10', 'Android 10' +end + +describe "UserAgent: AndroidDownloadManager" do + let(:useragent) { UserAgent.parse("AndroidDownloadManager") } + + it_behaves_like 'AndroidDownloadManager', nil, nil +end diff --git a/spec/browsers/android_user_agent_spec.rb b/spec/browsers/android_user_agent_spec.rb new file mode 100644 index 0000000..082aee2 --- /dev/null +++ b/spec/browsers/android_user_agent_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Android' do |browser, version, os| + it "returns '#{browser}' as its browser" do + expect(useragent.browser).to eq(browser) + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'Android' as its platform" do + expect(useragent.platform).to eq('Android') + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: ExoPlayerWrapper/5.4.9 (Linux;Android 10) ExoPlayerLib/2.11.5" do + let(:useragent) { UserAgent.parse("ExoPlayerWrapper/5.4.9 (Linux;Android 10) ExoPlayerLib/2.11.5") } + + it_behaves_like 'Android', 'ExoPlayerWrapper', '5.4.9', 'Android 10' +end + +describe "UserAgent: Dalvik/2.1.0 (Linux; U; Android 11; SM-G991N Build/RP1A.200720.012)" do + let(:useragent) { UserAgent.parse("Dalvik/2.1.0 (Linux; U; Android 11; SM-G991N Build/RP1A.200720.012)") } + + it_behaves_like 'Android', 'Dalvik', '2.1.0', 'Android 11' +end + +describe "UserAgent: de.danoeh.antennapod/1.8.1 (Linux;Android 10) ExoPlayerLib/2.10.8" do + let(:useragent) { UserAgent.parse("de.danoeh.antennapod/1.8.1 (Linux;Android 10) ExoPlayerLib/2.10.8") } + + it_behaves_like 'Android', 'de.danoeh.antennapod', '1.8.1', 'Android 10' +end + +describe "UserAgent: radio.de/app-5.4.2.5 (Linux;Android 7.0) ExoPlayerLib/2.13.3" do + let(:useragent) { UserAgent.parse("radio.de/app-5.4.2.5 (Linux;Android 7.0) ExoPlayerLib/2.13.3") } + + it_behaves_like 'Android', 'radio.de', 'app-5.4.2.5', 'Android 7.0' +end + +describe "UserAgent: NaverPlaybackLib/2.4.1 (Linux;Android 11) ExoPlayerLib/2.11.8" do + let(:useragent) { UserAgent.parse("NaverPlaybackLib/2.4.1 (Linux;Android 11) ExoPlayerLib/2.11.8") } + + it_behaves_like 'Android', 'NaverPlaybackLib', '2.4.1', 'Android 11' +end diff --git a/spec/browsers/apple_home_pod_user_agent_spec.rb b/spec/browsers/apple_home_pod_user_agent_spec.rb new file mode 100644 index 0000000..7847ea6 --- /dev/null +++ b/spec/browsers/apple_home_pod_user_agent_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'HomePod' do |version, os| + it "returns 'HomePod' as its browser" do + expect(useragent.browser).to eq('HomePod') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'HomePod' as its platform" do + expect(useragent.platform).to eq('HomePod') + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_speaker } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: AppleCoreMedia/1.0.0.16A5288c (HomePod; U; CPU OS 12_0 like Mac OS X; en_us)" do + let!(:useragent) { UserAgent.parse("AppleCoreMedia/1.0.0.16A5288c (HomePod; U; CPU OS 12_0 like Mac OS X; en_us)") } + + it_should_behave_like 'HomePod', '1.0.0.16A5288c', 'iOS 12.0' +end + +describe "UserAgent: AppleCoreMedia/1.0.0.18L203 (HomePod; U; CPU OS 14_5 like Mac OS X; fr_fr)" do + let!(:useragent) { UserAgent.parse("AppleCoreMedia/1.0.0.18L203 (HomePod; U; CPU OS 14_5 like Mac OS X; fr_fr)") } + + it_should_behave_like 'HomePod', '1.0.0.18L203', 'HomePod Software 14.5' +end diff --git a/spec/browsers/apple_podcasts_user_agent_spec.rb b/spec/browsers/apple_podcasts_user_agent_spec.rb new file mode 100644 index 0000000..5848c62 --- /dev/null +++ b/spec/browsers/apple_podcasts_user_agent_spec.rb @@ -0,0 +1,173 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Apple Podcasts with details' do |version, platform, os| + it "returns 'Apple Podcasts' as its browser" do + expect(useragent.browser).to eq('Apple Podcasts') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its os" do + expect(useragent.os).to eq(os) + end + + if platform == 'iOS' + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + else + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + end + + it { expect(useragent).not_to be_web_browser } +end + +describe "%D8%A7%D9%84%D8%A8%D9%88%D8%AF%D9%83%D8%A7%D8%B3%D8%AA/1430.27 CFNetwork/1150 Darwin/20.0.0" do + let!(:useragent) { UserAgent.parse("%D8%A7%D9%84%D8%A8%D9%88%D8%AF%D9%83%D8%A7%D8%B3%D8%AA/1430.27 CFNetwork/1150 Darwin/20.0.0") } + + it_behaves_like 'Apple Podcasts with details', '1430.27', 'iOS', 'iOS 14.0.x' +end + +describe "Podcasty/1400.173.3 CFNetwork/1085.4 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("Podcasty/1400.173.3 CFNetwork/1085.4 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1400.173.3', 'Macintosh', 'macOS 10.15' +end + +describe "Podcastit/1425.5 CFNetwork/1121.1.1 Darwin/19.2.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("Podcastit/1425.5 CFNetwork/1121.1.1 Darwin/19.2.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1425.5', 'Macintosh', 'macOS 10.15.2' +end + +describe "Balados/1400.173.3 CFNetwork/1085.4 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("Balados/1400.173.3 CFNetwork/1085.4 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1400.173.3', 'Macintosh', 'macOS 10.15' +end + +describe "%D7%A4%D7%95%D7%93%D7%A7%D7%90%D7%A1%D7%98%D7%99%D7%9D/1400.195 CFNetwork/1089 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("%D7%A4%D7%95%D7%93%D7%A7%D7%90%D7%A1%D7%98%D7%99%D7%9D/1400.195 CFNetwork/1089 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1400.195', 'Macintosh', 'macOS 10.15' +end + +describe "%E0%A4%AA%E0%A5%89%E0%A4%A1%E0%A4%95%E0%A4%BE%E0%A4%B8%E0%A5%8D%E0%A4%9F/1500.2 CFNetwork/1156 Darwin/20.0.0" do + let!(:useragent) { UserAgent.parse("%E0%A4%AA%E0%A5%89%E0%A4%A1%E0%A4%95%E0%A4%BE%E0%A4%B8%E0%A5%8D%E0%A4%9F/1500.2 CFNetwork/1156 Darwin/20.0.0") } + + it_behaves_like 'Apple Podcasts with details', '1500.2', 'iOS', 'iOS 14.0.x' +end + +describe "Podcasti/1400.192 CFNetwork/1088.1 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("Podcasti/1400.192 CFNetwork/1088.1 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1400.192', 'Macintosh', 'macOS 10.15' +end + +describe "Podcastok/1425.5 CFNetwork/1121.1.2 Darwin/19.2.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("Podcastok/1425.5 CFNetwork/1121.1.2 Darwin/19.2.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1425.5', 'Macintosh', 'macOS 10.15.2' +end + +describe "%ED%8C%9F%EC%BA%90%EC%8A%A4%ED%8A%B8/1430.39 CFNetwork/1125 Darwin/19.4.0" do + let!(:useragent) { UserAgent.parse("%ED%8C%9F%EC%BA%90%EC%8A%A4%ED%8A%B8/1430.39 CFNetwork/1125 Darwin/19.4.0") } + + it_behaves_like 'Apple Podcasts with details', '1430.39', 'iOS', 'iOS 13.4.x' +end + +describe "Podkaster/1420.34 CFNetwork/1120 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("Podkaster/1420.34 CFNetwork/1120 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1420.34', 'Macintosh', 'macOS 10.15' +end + +describe "Podcasturi/1400.174 CFNetwork/1085.1 Darwin/19.0.0" do + let!(:useragent) { UserAgent.parse("Podcasturi/1400.174 CFNetwork/1085.1 Darwin/19.0.0") } + + it_behaves_like 'Apple Podcasts with details', '1400.174', 'iOS', 'iOS 13.0' +end + +describe "%D0%9F%D0%BE%D0%B4%D0%BA%D0%B0%D1%81%D1%82%D1%8B/1500.3 CFNetwork/1156 Darwin/20.0.0" do + let!(:useragent) { UserAgent.parse("%D0%9F%D0%BE%D0%B4%D0%BA%D0%B0%D1%81%D1%82%D1%8B/1500.3 CFNetwork/1156 Darwin/20.0.0") } + + it_behaves_like 'Apple Podcasts with details', '1500.3', 'iOS', 'iOS 14.0.x' +end + +describe "Podcaster/1400.173.4 CFNetwork/1085.4 Darwin/19.0.0" do + let!(:useragent) { UserAgent.parse("Podcaster/1400.173.4 CFNetwork/1085.4 Darwin/19.0.0") } + + it_behaves_like 'Apple Podcasts with details', '1400.173.4', 'iOS', 'iOS 13.0' +end + +describe "%E0%B8%9E%E0%B9%87%E0%B8%AD%E0%B8%94%E0%B8%84%E0%B8%B2%E0%B8%AA%E0%B8%97%E0%B9%8C/1425.5 CFNetwork/1121.2.2 Darwin/19.3.0" do + let!(:useragent) { UserAgent.parse("%E0%B8%9E%E0%B9%87%E0%B8%AD%E0%B8%94%E0%B8%84%E0%B8%B2%E0%B8%AA%E0%B8%97%E0%B9%8C/1425.5 CFNetwork/1121.2.2 Darwin/19.3.0") } + + it_behaves_like 'Apple Podcasts with details', '1425.5', 'iOS', 'iOS 13.3.1' +end + +describe "Podcast%E2%80%99ler/1420.30 CFNetwork/1120 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("Podcast%E2%80%99ler/1420.30 CFNetwork/1120 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1420.30', 'Macintosh', 'macOS 10.15' +end + +describe "%D0%9F%D0%BE%D0%B4%D0%BA%D0%B0%D1%81%D1%82%D0%B8/1430.33 CFNetwork/1121.4 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("%D0%9F%D0%BE%D0%B4%D0%BA%D0%B0%D1%81%D1%82%D0%B8/1430.33 CFNetwork/1121.4 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1430.33', 'Macintosh', 'macOS 10.15' +end + +describe "%E6%92%AD%E5%AE%A2/1410.33 CFNetwork/1108 Darwin/19.0.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("%E6%92%AD%E5%AE%A2/1410.33 CFNetwork/1108 Darwin/19.0.0 (x86_64)") } + + it_behaves_like 'Apple Podcasts with details', '1410.33', 'Macintosh', 'macOS 10.15' +end + +describe "Podcasts/0 CFNetwork/1156 Darwin/20.0.0" do + let!(:useragent) { UserAgent.parse("Podcasts/0 CFNetwork/1156 Darwin/20.0.0") } + + it_behaves_like 'Apple Podcasts with details', '0', 'iOS', 'iOS 14.0.x' +end + +describe "Podcasts/1.0.0.218659818 CFNetwork/974.2.1 Darwin/18.0.0" do + let!(:useragent) { UserAgent.parse("Podcasts/1.0.0.218659818 CFNetwork/974.2.1 Darwin/18.0.0") } + + it_behaves_like 'Apple Podcasts with details', '1.0.0.218659818', 'iOS', 'iOS 12.0.x' +end + +describe "Podcast/1 CFNetwork/901.1 Darwin/17.6.0" do + let!(:useragent) { UserAgent.parse("Podcast/1 CFNetwork/901.1 Darwin/17.6.0") } + + it_behaves_like 'Apple Podcasts with details', '1', 'iOS', 'iOS 11.4' +end + +describe "Podcast/22 CFNetwork/978.0.7 Darwin/18.6.0" do + let!(:useragent) { UserAgent.parse("Podcast/22 CFNetwork/978.0.7 Darwin/18.6.0") } + + it_behaves_like 'Apple Podcasts with details', '22', 'iOS', 'iOS 12.3.x' +end + +describe "%E3%83%9D%E3%83%83%E3%83%89%E3%82%AD%E3%83%A3%E3%82%B9%E3%83%88/1709.2.2 CFNetwork/1390 Darwin/22.0.0" do + let!(:useragent) { UserAgent.parse("%E3%83%9D%E3%83%83%E3%83%89%E3%82%AD%E3%83%A3%E3%82%B9%E3%83%88/1709.2.2 CFNetwork/1390 Darwin/22.0.0") } + + it_behaves_like 'Apple Podcasts with details', '1709.2.2', 'iOS', 'iOS 16.0.x' +end + +describe "ポッドキャスト/1709.2.2 CFNetwork/1390 Darwin/22.0.0" do + let!(:useragent) { UserAgent.parse("ポッドキャスト/1709.2.2 CFNetwork/1390 Darwin/22.2.0") } + + it_behaves_like 'Apple Podcasts with details', '1709.2.2', 'iOS', 'iOS 16.2' +end diff --git a/spec/browsers/audible_user_agent_spec.rb b/spec/browsers/audible_user_agent_spec.rb new file mode 100644 index 0000000..bb6febd --- /dev/null +++ b/spec/browsers/audible_user_agent_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Audible' do |version, platform, os| + it "returns 'Audible' as its browser" do + expect(useragent.browser).to eq('Audible') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: com.audible.playersdk.player/3.6.0 (Linux;Android 10) ExoPlayerLib/2.12.1" do + let(:useragent) { UserAgent.parse("com.audible.playersdk.player/3.6.0 (Linux;Android 10) ExoPlayerLib/2.12.1") } + + it_behaves_like 'Audible', '3.6.0', 'Android', 'Android 10' +end + +describe "UserAgent: Audible/666 CFNetwork/1220.1 Darwin/20.3.0" do + let(:useragent) { UserAgent.parse("Audible/666 CFNetwork/1220.1 Darwin/20.3.0") } + + it_behaves_like 'Audible', '666', 'iOS', 'iOS 14.4.x' +end + +describe "UserAgent: Audible, Android, 2.67.2, google, Pixel 3 XL, crosshatch, 11, 1.0, MOBILE" do + let(:useragent) { UserAgent.parse("Audible, Android, 2.67.2, google, Pixel 3 XL, crosshatch, 11, 1.0, MOBILE") } + + it_behaves_like 'Audible', '2.67.2', 'Android', nil +end diff --git a/spec/browsers/audio_clip_user_agent_spec.rb b/spec/browsers/audio_clip_user_agent_spec.rb new file mode 100644 index 0000000..08311e7 --- /dev/null +++ b/spec/browsers/audio_clip_user_agent_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'AudioClip' do |version, platform, os| + it "returns 'AudioClip' as its browser" do + expect(useragent.browser).to eq('AudioClip') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: AudioClip/125 CFNetwork/1240.0.4 Darwin/20.5.0" do + let(:useragent) { UserAgent.parse("AudioClip/125 CFNetwork/1240.0.4 Darwin/20.5.0") } + + it_should_behave_like 'AudioClip', '125', 'iOS', 'iOS 14.6' +end + +describe "UserAgent: AudioClip/iOS/2.21.1 (iOS 14.6; iPhone)" do + let(:useragent) { UserAgent.parse("AudioClip/iOS/2.21.1 (iOS 14.6; iPhone)") } + + it_should_behave_like 'AudioClip', '2.21.1', 'iPhone', 'iOS 14.6' +end + +describe "UserAgent: AudioClip/iOS/2.20.0 (iOS 14.4.2; iPad)" do + let(:useragent) { UserAgent.parse("AudioClip/iOS/2.20.0 (iOS 14.4.2; iPad)") } + + it_should_behave_like 'AudioClip', '2.20.0', 'iPad', 'iOS 14.4.2' +end + +describe "UserAgent: AudioClip/iOS/2.15.1 (iOS 12.4.8; iPod touch)" do + let(:useragent) { UserAgent.parse("AudioClip/iOS/2.15.1 (iOS 12.4.8; iPod touch)") } + + it_should_behave_like 'AudioClip', '2.15.1', 'iPod touch', 'iOS 12.4.8' +end diff --git a/spec/browsers/beyond_pod_user_agent_spec.rb b/spec/browsers/beyond_pod_user_agent_spec.rb new file mode 100644 index 0000000..a60de2b --- /dev/null +++ b/spec/browsers/beyond_pod_user_agent_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'BeyondPod' do + it "returns 'BeyondPod' as its browser" do + expect(useragent.browser).to eq('BeyondPod') + end + + it "returns 'Android' as its platform" do + expect(useragent.platform).to eq('Android') + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Mozilla/5.0 (Linux; U; en-us; BeyondPod 4)" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; U; en-us; BeyondPod 4)") } + + it_should_behave_like 'BeyondPod' +end + +describe "UserAgent: Mozilla/5.0 (Linux; U; en-us; BeyondPod 4) Dynamo/1.0" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; U; en-us; BeyondPod 4) Dynamo/1.0") } + + it_should_behave_like 'BeyondPod' +end + +describe "UserAgent: BeyondPod for Android" do + let(:useragent) { UserAgent.parse("BeyondPod for Android") } + + it_should_behave_like 'BeyondPod' +end diff --git a/spec/browsers/black_berry_user_agent_spec.rb b/spec/browsers/black_berry_user_agent_spec.rb new file mode 100644 index 0000000..a0b6068 --- /dev/null +++ b/spec/browsers/black_berry_user_agent_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'BlackBerry' do |version| + it "returns 'BlackBerry' as its browser" do + expect(useragent.browser).to eq('BlackBerry') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'BlackBerry' as its platform" do + expect(useragent.platform).to eq('BlackBerry') + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: BlackBerry8520/5.0.0.681 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/600" do + let(:useragent) { UserAgent.parse("BlackBerry8520/5.0.0.681 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/600") } + + it_behaves_like 'BlackBerry', '5.0.0.681' +end + +describe "UserAgent: BlackBerry9630/5.0.0.975 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/105" do + let(:useragent) { UserAgent.parse("BlackBerry9630/5.0.0.975 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/105") } + + it_behaves_like 'BlackBerry', '5.0.0.975' +end + +describe "UserAgent: BlackBerry9550/4.2.0.442 Profile/MIDP-2.0 Configuration/CLDC-1.1/UC Browser7.8.0.95/161/352" do + let(:useragent) { UserAgent.parse("BlackBerry9550/4.2.0.442 Profile/MIDP-2.0 Configuration/CLDC-1.1/UC Browser7.8.0.95/161/352") } + + it_behaves_like 'BlackBerry', '4.2.0.442' +end diff --git a/spec/browsers/breaker_user_agent_spec.rb b/spec/browsers/breaker_user_agent_spec.rb new file mode 100644 index 0000000..2ba3ce5 --- /dev/null +++ b/spec/browsers/breaker_user_agent_spec.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Breaker' do |version, platform, os| + it "returns 'Breaker' as its browser" do + expect(useragent.browser).to eq('Breaker') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Breaker/Android/1.0.0.RC-GP-Free(72) (72)" do + let(:useragent) { UserAgent.parse("Breaker/Android/1.0.0.RC-GP-Free(72) (72)") } + + it_should_behave_like 'Breaker', '1.0.0.RC-GP-Free(72)', 'Android', 'Android' +end + +describe "UserAgent: Breaker/Android (https://breaker.audio)" do + let(:useragent) { UserAgent.parse("Breaker/Android (https://breaker.audio)") } + + it_should_behave_like 'Breaker', nil, 'Android', 'Android' +end + +describe "UserAgent: Breaker/0.8.0 (1059)" do + let(:useragent) { UserAgent.parse("Breaker/0.8.0 (1059)") } + + it_should_behave_like 'Breaker', '0.8.0', nil, nil +end + +describe "UserAgent: Breaker/iOS (https://breaker.audio)" do + let(:useragent) { UserAgent.parse("Breaker/iOS (https://breaker.audio)") } + + it_should_behave_like 'Breaker', nil, 'iOS', 'iOS' +end + +describe "UserAgent: Breaker/515 CFNetwork/893.10 Darwin/17.3.0" do + let(:useragent) { UserAgent.parse("Breaker/515 CFNetwork/893.10 Darwin/17.3.0") } + + it_should_behave_like 'Breaker', '515', 'iOS', 'iOS 11.2' +end + +describe "UserAgent: Breaker/0.2.8 (com.Breaker.Breaker; build:0.2.8; iOS 9.3.2) Alamofire/4.0.0" do + let(:useragent) { UserAgent.parse("Breaker/0.2.8 (com.Breaker.Breaker; build:0.2.8; iOS 9.3.2) Alamofire/4.0.0") } + + it_should_behave_like 'Breaker', '0.2.8', 'iOS', 'iOS 9.3.2' +end + +describe "UserAgent: Breaker/com.Breaker.Breaker (0.2.2; iOS 9.3.2)" do + let(:useragent) { UserAgent.parse("Breaker/com.Breaker.Breaker (0.2.2; iOS 9.3.2)") } + + it_should_behave_like 'Breaker', nil, 'iOS', 'iOS 9.3.2' +end + +describe "UserAgent: Breaker/iOS/0.8.1 (1076)" do + let(:useragent) { UserAgent.parse("Breaker/iOS/0.8.1 (1076)") } + + it_should_behave_like 'Breaker', '0.8.1', 'iOS', 'iOS' +end diff --git a/spec/browsers/castbox_user_agent_spec.rb b/spec/browsers/castbox_user_agent_spec.rb new file mode 100644 index 0000000..b3f36f9 --- /dev/null +++ b/spec/browsers/castbox_user_agent_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Castbox' do |version, platform, os| + it "returns 'Castbox' as its browser" do + expect(useragent.browser).to eq('Castbox') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: CastBox/4.20 (fm.castbox.audiobook.radio.podcast; build:15; iOS 14.4.0)" do + let!(:useragent) { UserAgent.parse("CastBox/4.20 (fm.castbox.audiobook.radio.podcast; build:15; iOS 14.4.0)") } + + it_should_behave_like 'Castbox', '4.20', 'iOS', 'iOS 14.4.0' +end + +describe "UserAgent: CastBox/com.castbox.CastBox (3.0.3/4.1) ; iOS 12.1.3)" do + let!(:useragent) { UserAgent.parse("CastBox/com.castbox.CastBox (3.0.3/4.1) ; iOS 12.1.3)") } + + it_should_behave_like 'Castbox', '3.0.3/4.1', 'iOS', 'iOS 12.1.3' +end + +describe "UserAgent: Castbox/4.11.1 (fm.castbox.audiobook.radio.podcast; build:7; iOS 13.3.0) Alamofire/4.7.1" do + let!(:useragent) { UserAgent.parse("Castbox/4.11.1 (fm.castbox.audiobook.radio.podcast; build:7; iOS 13.3.0) Alamofire/4.7.1") } + + it_should_behave_like 'Castbox', '4.11.1', 'iOS', 'iOS 13.3.0' +end + +describe "UserAgent: CastBox/1.3.6-170605171 (Linux;Android 6.0.1) ExoPlayerLib/2.4.0" do + let!(:useragent) { UserAgent.parse("CastBox/1.3.6-170605171 (Linux;Android 6.0.1) ExoPlayerLib/2.4.0") } + + it_should_behave_like 'Castbox', '1.3.6-170605171', 'Android', 'Android 6.0.1' +end + +describe "UserAgent: CastBox/5.0.0-170114181.r651de0f BMID/E6804BD2F2" do + let!(:useragent) { UserAgent.parse("CastBox/5.0.0-170114181.r651de0f BMID/E6804BD2F2") } + + it_should_behave_like 'Castbox', '5.0.0-170114181.r651de0f', nil, nil +end + +describe "UserAgent: CastBox/5.10.4-200119035.r517c146 (Linux;Android 9.0)" do + let!(:useragent) { UserAgent.parse("CastBox/5.10.4-200119035.r517c146 (Linux;Android 9.0)") } + + it_should_behave_like 'Castbox', '5.10.4-200119035.r517c146', 'Android', 'Android 9.0' +end + +describe "UserAgent: CastBox/7.12.1-180306067 (Linux;Android 9) ExoPlayerLib/2.4.0" do + let!(:useragent) { UserAgent.parse("CastBox/7.12.1-180306067 (Linux;Android 9) ExoPlayerLib/2.4.0") } + + it_should_behave_like 'Castbox', '7.12.1-180306067', 'Android', 'Android 9' +end diff --git a/spec/browsers/castro_user_agent_spec.rb b/spec/browsers/castro_user_agent_spec.rb new file mode 100644 index 0000000..0777229 --- /dev/null +++ b/spec/browsers/castro_user_agent_spec.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Castro' do |version, platform, os| + it "returns 'Castro' as its browser" do + expect(useragent.browser).to eq('Castro') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Castro 2021.4/1322" do + let(:useragent) { UserAgent.parse("Castro 2021.4/1322") } + + it_behaves_like 'Castro', '2021.4', 'iOS', 'iOS' +end + +describe "UserAgent: Castro 3.1.2/1063 Dynamo/1.0" do + let(:useragent) { UserAgent.parse("Castro 3.1.2/1063 Dynamo/1.0") } + + it_behaves_like 'Castro', '3.1.2', 'iOS', 'iOS' +end + +describe "UserAgent: Castro Downloader" do + let(:useragent) { UserAgent.parse("Castro Downloader") } + + it_behaves_like 'Castro', nil, 'iOS', 'iOS' +end + +describe "UserAgent: Castro/516 CFNetwork/1237 Darwin/20.4.0" do + let(:useragent) { UserAgent.parse("Castro/516 CFNetwork/1237 Darwin/20.4.0") } + + it_behaves_like 'Castro', '516', 'iOS', 'iOS 14.5' +end + +describe "UserAgent: Castro 2, Episode Duration Lookup (iPhone; U; CPU OS 9_2 like Mac OS X; en_us)" do + let(:useragent) { UserAgent.parse("Castro 2, Episode Duration Lookup (iPhone; U; CPU OS 9_2 like Mac OS X; en_us)") } + + it_behaves_like 'Castro', '2', 'iPhone', 'iOS 9.2' +end + +describe "UserAgent: Castro 2, Episode Duration Lookup BMID/E6806A66A4" do + let(:useragent) { UserAgent.parse("Castro 2, Episode Duration Lookup BMID/E6806A66A4") } + + it_behaves_like 'Castro', '2', 'iOS', 'iOS' +end + +describe "UserAgent: Castro 2 Episode Download" do + let(:useragent) { UserAgent.parse("Castro 2 Episode Download") } + + it_behaves_like 'Castro', '2', 'iOS', 'iOS' +end + +describe "UserAgent: Castro Episode Download (http://supertop.co/castro)" do + let(:useragent) { UserAgent.parse("Castro Episode Download (http://supertop.co/castro)") } + + it_behaves_like 'Castro', nil, 'iOS', 'iOS' +end + +describe "UserAgent: Castro 2 2.2/647 Like iTunes" do + let(:useragent) { UserAgent.parse("Castro 2 2.2/647 Like iTunes") } + + it_behaves_like 'Castro', '2', 'iOS', 'iOS' +end diff --git a/spec/browsers/chrome_user_agent_spec.rb b/spec/browsers/chrome_user_agent_spec.rb index 1d0c6fe..945ea39 100644 --- a/spec/browsers/chrome_user_agent_spec.rb +++ b/spec/browsers/chrome_user_agent_spec.rb @@ -4,6 +4,31 @@ it "should return 'Chrome' as its browser" do expect(@useragent.browser).to eq("Chrome") end + + it "should return '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "should return '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "should return '#{os}' as its os" do + expect(useragent.os).to eq(os) + end + + if type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + elsif type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_bot } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).to be_web_browser } end # http://www.useragentstring.com/Chrome30.0.1599.17_id_19721.php diff --git a/spec/browsers/deezer_crawler_user_agent_spec.rb b/spec/browsers/deezer_crawler_user_agent_spec.rb new file mode 100644 index 0000000..371e832 --- /dev/null +++ b/spec/browsers/deezer_crawler_user_agent_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'DeezerCrawler' do + it "returns 'Deezer' as its browser" do + expect(useragent.browser).to eq('Deezer') + end + + it { expect(useragent.platform).to be_nil } + it { expect(useragent.os).to be_nil } + + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Deezer Podcasters/1.0" do + let(:useragent) { UserAgent.parse("Deezer Podcasters/1.0") } + + it_behaves_like 'DeezerCrawler' +end diff --git a/spec/browsers/deezer_user_agent_spec.rb b/spec/browsers/deezer_user_agent_spec.rb new file mode 100644 index 0000000..c0def0d --- /dev/null +++ b/spec/browsers/deezer_user_agent_spec.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Deezer' do |version, platform, os, type| + it "returns 'Deezer' as its browser" do + expect(useragent.browser).to eq('Deezer') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + elsif type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Deezer/6.2.28.73 (Android; 11; Mobile; fr) samsung SM-G973F" do + let(:useragent) { UserAgent.parse("Deezer/6.2.28.73 (Android; 11; Mobile; fr) samsung SM-G973F") } + + it_behaves_like 'Deezer', '6.2.28.73', 'Android', 'Android 11', :mobile +end + +describe "UserAgent: Deezer/6.0.10.201 (Android; 5.1.1; Tablet; nl) samsung SM-T280" do + let(:useragent) { UserAgent.parse("Deezer/6.0.10.201 (Android; 5.1.1; Tablet; nl) samsung SM-T280") } + + it_behaves_like 'Deezer', '6.0.10.201', 'Android', 'Android 5.1.1', :mobile +end + +describe "UserAgent: Deezer/8.39.0.6 CFNetwork/1220.1 Darwin/20.3.0" do + let(:useragent) { UserAgent.parse("Deezer/8.39.0.6 CFNetwork/1220.1 Darwin/20.3.0") } + + it_behaves_like 'Deezer', '8.39.0.6', 'iOS', 'iOS 14.4.x', :mobile +end + +describe "UserAgent: Deezer/4.34.10 (Electron; windows/10.0.19041; Desktop; de)" do + let(:useragent) { UserAgent.parse("Deezer/4.34.10 (Electron; windows/10.0.19041; Desktop; de)") } + + it_behaves_like 'Deezer', '4.34.10', 'Windows', 'Windows 10.0.19041', :desktop +end + +describe "UserAgent: Deezer/4.34.10 (Electron; osx/10.16.0; Desktop; en)" do + let(:useragent) { UserAgent.parse("Deezer/4.34.10 (Electron; osx/10.16.0; Desktop; en)") } + + it_behaves_like 'Deezer', '4.34.10', 'Macintosh', 'macOS 10.16.0', :desktop +end + +describe "UserAgent: Deezer/4.18.50 (Electron; linux/5.11.0-16-generic; Desktop; us)" do + let(:useragent) { UserAgent.parse("Deezer/4.18.50 (Electron; linux/5.11.0-16-generic; Desktop; us)") } + + it_behaves_like 'Deezer', '4.18.50', 'X11', '5.11.0-16-generic', :desktop +end + +describe "UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Deezer/4.25.0 Chrome/73.0.3683.121 Electron/5.0.10 Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Deezer/4.25.0 Chrome/73.0.3683.121 Electron/5.0.10 Safari/537.36") } + + it_behaves_like 'Deezer', '4.25.0', 'Macintosh', 'OS X 10.10.5', :desktop +end + +describe "UserAgent: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Deezer/4.27.0 Chrome/73.0.3683.121 Electron/5.0.10 Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Deezer/4.27.0 Chrome/73.0.3683.121 Electron/5.0.10 Safari/537.36") } + + it_behaves_like 'Deezer', '4.27.0', 'Windows', 'Windows 10', :desktop +end + +describe "UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Deezer/4.27.0 Chrome/76.0.3809.146 Electron/6.1.12 Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Deezer/4.27.0 Chrome/76.0.3809.146 Electron/6.1.12 Safari/537.36") } + + it_behaves_like 'Deezer', '4.27.0', 'X11', 'Linux x86_64', :desktop +end diff --git a/spec/browsers/downcast_crawler_user_agent_spec.rb b/spec/browsers/downcast_crawler_user_agent_spec.rb new file mode 100644 index 0000000..7bc260a --- /dev/null +++ b/spec/browsers/downcast_crawler_user_agent_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'DowncastCrawler' do + it "returns 'Downcast' as its browser" do + expect(useragent.browser).to eq('Downcast') + end + + it { expect(useragent.platform).to be_nil } + it { expect(useragent.os).to be_nil } + + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: downcast feed consumer/0.0.177; (mode=dev; id=jQPkOYXFJT; downcast.fm)" do + let(:useragent) { UserAgent.parse("downcast feed consumer/0.0.177; (mode=dev; id=jQPkOYXFJT; downcast.fm)") } + + it_behaves_like 'DowncastCrawler' +end diff --git a/spec/browsers/downcast_user_agent_spec.rb b/spec/browsers/downcast_user_agent_spec.rb new file mode 100644 index 0000000..8197a6e --- /dev/null +++ b/spec/browsers/downcast_user_agent_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Downcast' do |version, platform, os, type| + it "returns 'Downcast' as its browser" do + expect(useragent.browser).to eq('Downcast') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + elsif type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Downcast/2.10.3 (iPhone; iOS 14.6; Scale/3.00)" do + let(:useragent) { UserAgent.parse("Downcast/2.10.3 (iPhone; iOS 14.6; Scale/3.00)") } + + it_behaves_like 'Downcast', '2.10.3', 'iPhone', 'iOS 14.6', :mobile +end + +describe "UserAgent: Downcast/2.10.1 (iPod touch; iOS 13.6; Scale/2.00)" do + let(:useragent) { UserAgent.parse("Downcast/2.10.1 (iPod touch; iOS 13.6; Scale/2.00)") } + + it_behaves_like 'Downcast', '2.10.1', 'iPod touch', 'iOS 13.6', :mobile +end + +describe "UserAgent: Downcast/2.10.0 (iPad; iOS 14.5.1; Scale/2.00)" do + let(:useragent) { UserAgent.parse("Downcast/2.10.0 (iPad; iOS 14.5.1; Scale/2.00)") } + + it_behaves_like 'Downcast', '2.10.0', 'iPad', 'iOS 14.5.1', :mobile +end + +describe "UserAgent: Downcast/2.10.1 (Mac OS X Version 10.15.7 (Build 19H1030))" do + let(:useragent) { UserAgent.parse("Downcast/2.10.1 (Mac OS X Version 10.15.7 (Build 19H1030))") } + + it_behaves_like 'Downcast', '2.10.1', 'Macintosh', 'macOS 10.15.7', :desktop +end + +describe "UserAgent: Downcast/1224 CFNetwork/673.2.1 Darwin/13.1.0 (x86_64) (MacBookPro11%2C3)" do + let(:useragent) { UserAgent.parse("Downcast/1224 CFNetwork/673.2.1 Darwin/13.1.0 (x86_64) (MacBookPro11%2C3)") } + + it_behaves_like 'Downcast', '1224', 'Macintosh', 'macOS 10.9.2', :desktop +end + +describe "UserAgent: Downcast/7276 CFNetwork/1121.2.2 Darwin/19.3.0" do + let(:useragent) { UserAgent.parse("Downcast/7276 CFNetwork/1121.2.2 Darwin/19.3.0") } + + it_behaves_like 'Downcast', '7276', 'iOS', 'iOS 13.3.1', :mobile +end diff --git a/spec/browsers/edge_user_agent_spec.rb b/spec/browsers/edge_user_agent_spec.rb index ad4d313..7c2a9e8 100644 --- a/spec/browsers/edge_user_agent_spec.rb +++ b/spec/browsers/edge_user_agent_spec.rb @@ -8,6 +8,26 @@ it "should return 'Windows' as its platform" do expect(@useragent.platform).to eq("Windows") end + + it "should return '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "should return '#{os}' as its os" do + expect(useragent.os).to eq(os) + end + + if type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + elsif type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } end describe "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240" do diff --git a/spec/browsers/facebook_user_agent_spec.rb b/spec/browsers/facebook_user_agent_spec.rb new file mode 100644 index 0000000..4927b3e --- /dev/null +++ b/spec/browsers/facebook_user_agent_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Facebook' do |version, platform, os, type| + it "returns 'Facebook' as its browser" do + expect(useragent.browser).to eq('Facebook') + end + + it "should return '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "should return '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "should return '#{os}' as its os" do + expect(useragent.os).to eq(os) + end + + if type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + elsif type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 5.1; XT1039 Build/LPBS23.13-17.6-1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.116 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/137.0.0.24.91;]" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 5.1; XT1039 Build/LPBS23.13-17.6-1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.116 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/137.0.0.24.91;]") } + + it_behaves_like 'Facebook', '137.0.0.24.91', 'Android', 'Android 5.1', :mobile +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 7.0; SM-J710F Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.158 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/172.0.0.66.93;]" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 7.0; SM-J710F Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.158 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/172.0.0.66.93;]") } + + it_behaves_like 'Facebook', '172.0.0.66.93', 'Android', 'Android 7.0', :mobile +end + +describe "UserAgent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 [FBAN/FBIOS;FBAV/171.0.0.49.95;FBBV/107251038;FBDV/iPhone8 ,1;FBMD/iPhone;FBSN/iOS;FBSV/10.3.3;FBSS/2;FBCR/TelekomHU;FBID/phone;FBLC/hu_HU;FBOP/5;FBRV/0]" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 [FBAN/FBIOS;FBAV/171.0.0.49.95;FBBV/107251038;FBDV/iPhone8 ,1;FBMD/iPhone;FBSN/iOS;FBSV/10.3.3;FBSS/2;FBCR/TelekomHU;FBID/phone;FBLC/hu_HU;FBOP/5;FBRV/0]") } + + it_behaves_like 'Facebook', '171.0.0.49.95', 'iPhone', 'iOS 10.3.3', :mobile +end + +describe "UserAgent: Mozilla/5.0 (iPad; CPU OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F5071a [FBAN/FBIOS;FBAV/171.0.0.49.95;FBBV/107251038;FBDV/iPad7 ,3;FBMD/iPad;FBSN/iOS;FBSV/11.4;FBSS/2;FBCR/;FBID/tablet;FBLC/nl_NL;FBOP/5;FBRV/0]" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (iPad; CPU OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F5071a [FBAN/FBIOS;FBAV/171.0.0.49.95;FBBV/107251038;FBDV/iPad7 ,3;FBMD/iPad;FBSN/iOS;FBSV/11.4;FBSS/2;FBCR/;FBID/tablet;FBLC/nl_NL;FBOP/5;FBRV/0]") } + + it_behaves_like 'Facebook', '171.0.0.49.95', 'iPad', 'iOS 11.4', :mobile +end + +describe "UserAgent: Mozilla/5.0 (Linux; Tizen 3.0.0.0; Samsung SM-Z400Y) AppleWebKit/537.3 (KHTML, like Gecko) Version/3.0.0.0 Mobile Safari/537.3 [FBAN/FB4T;FBAV/1.0.57;FBBV/1.0.57;FBMF/Samsung;FBDV/SM-Z400Y;FBSN/Tizen;FBSV/3.0.0.0;FBCR/655-10;FBLC/en_ZA;FBCM/{density=233 ,width=480,height=800};]" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Tizen 3.0.0.0; Samsung SM-Z400Y) AppleWebKit/537.3 (KHTML, like Gecko) Version/3.0.0.0 Mobile Safari/537.3 [FBAN/FB4T;FBAV/1.0.57;FBBV/1.0.57;FBMF/Samsung;FBDV/SM-Z400Y;FBSN/Tizen;FBSV/3.0.0.0;FBCR/655-10;FBLC/en_ZA;FBCM/{density=233 ,width=480,height=800};]") } + + it_behaves_like 'Facebook', '1.0.57', 'Linux', 'Samsung SM-Z400Y', :mobile +end + +describe "UserAgent: Mozilla/5.0 (Windows NT 10.0.15063.413; osmeta 9.3.1233) AppleWebKit/602.1.1 (KHTML, like Gecko) Version/9.0 Safari/602.1.1 osmeta/9.3.1233 Build/1233 [FBAN/FBW;FBAV/93.0.0.64.0;FBBV/62624619;FBDV/WindowsDevice;FBMD/550-227c;FBSN/Windows;FBSV/10.0.15063.413;FBSS/1;FBCR/;FBID/desktop;FBLC/en_US;FBOP/45;FBRV/0]" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0.15063.413; osmeta 9.3.1233) AppleWebKit/602.1.1 (KHTML, like Gecko) Version/9.0 Safari/602.1.1 osmeta/9.3.1233 Build/1233 [FBAN/FBW;FBAV/93.0.0.64.0;FBBV/62624619;FBDV/WindowsDevice;FBMD/550-227c;FBSN/Windows;FBSV/10.0.15063.413;FBSS/1;FBCR/;FBID/desktop;FBLC/en_US;FBOP/45;FBRV/0]") } + + it_behaves_like 'Facebook', '93.0.0.64.0', 'Windows', 'Windows NT 10.0.15063.413', :desktop +end diff --git a/spec/browsers/gecko_user_agent_spec.rb b/spec/browsers/gecko_user_agent_spec.rb index 80ed89c..d7627af 100644 --- a/spec/browsers/gecko_user_agent_spec.rb +++ b/spec/browsers/gecko_user_agent_spec.rb @@ -10,6 +10,22 @@ end end +shared_examples 'a desktop' do + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } +end + +shared_examples 'a mobile' do + it { expect(@useragent).to be_mobile } + it { expect(@useragent).not_to be_desktop } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } +end + describe 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8' do before do @useragent = UserAgent.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8) Gecko/20100101 Firefox/4.0b8') diff --git a/spec/browsers/google_home_user_agent_spec.rb b/spec/browsers/google_home_user_agent_spec.rb new file mode 100644 index 0000000..6ba685b --- /dev/null +++ b/spec/browsers/google_home_user_agent_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for "Google Home" do |version, platform, os| + it "should return 'Google Home' as its browser" do + expect(useragent.browser).to eq("Google Home") + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_speaker } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 6.0.1; Build/M-MMB29M-rzs-us-sf-bld2-19HP-08.02.AM) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.41 Safari/537.36 CrKey/1.29.104695" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 6.0.1; Build/M-MMB29M-rzs-us-sf-bld2-19HP-08.02.AM) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.41 Safari/537.36 CrKey/1.29.104695") } + + it_behaves_like 'Google Home', '1.29.104695', 'Android', 'Android 6.0.1' +end + +describe "UserAgent: Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3398.0 Safari/537.36 CrKey/1.34.119222" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3398.0 Safari/537.36 CrKey/1.34.119222") } + + it_behaves_like 'Google Home', '1.34.119222', 'X11', 'Linux aarch64' +end + +describe "UserAgent: Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.71 Safari/537.36 CrKey/1.23.85114" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.71 Safari/537.36 CrKey/1.23.85114") } + + it_behaves_like 'Google Home', '1.23.85114', 'X11', 'Linux armv7l' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 8.0; Build/OPR2.170623.027) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.147 Safari/537.36 CrKey/1.31.115279" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 8.0; Build/OPR2.170623.027) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.147 Safari/537.36 CrKey/1.31.115279") } + + it_behaves_like 'Google Home', '1.31.115279', 'Android', 'Android 8.0' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 7.0; FRD-L04 Build/HUAWEIFRD-L04; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36 CrKey" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 7.0; FRD-L04 Build/HUAWEIFRD-L04; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36 CrKey") } + + it_behaves_like 'Google Home', nil, 'Android', 'Android 7.0' +end diff --git a/spec/browsers/google_podcasts_user_agent_spec.rb b/spec/browsers/google_podcasts_user_agent_spec.rb new file mode 100644 index 0000000..3f8b274 --- /dev/null +++ b/spec/browsers/google_podcasts_user_agent_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Google Podcasts' do |version, platform, os| + it "should return 'Google Podcasts' as its browser" do + expect(useragent.browser).to eq("Google Podcasts") + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) GSA/42.0.183854831 Mobile/13G36 Safari/601.1" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) GSA/42.0.183854831 Mobile/13G36 Safari/601.1") } + + it_should_behave_like 'Google Podcasts', '42.0.183854831', 'iPhone', 'iOS 9.3.5' +end + +describe "UserAgent: Mozilla/5.0 (iPad; CPU OS 9_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) GSA/6.0.51363 Mobile/13A452 Safari/600.1.4" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (iPad; CPU OS 9_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) GSA/6.0.51363 Mobile/13A452 Safari/600.1.4") } + + it_should_behave_like 'Google Podcasts', '6.0.51363', 'iPad', 'iOS 9.0.2' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 5.0.2; LG-V496 Build/LRX22G; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.97 Safari/537.36 GSA/6.3.36.21.arm" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 5.0.2; LG-V496 Build/LRX22G; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.97 Safari/537.36 GSA/6.3.36.21.arm") } + + it_should_behave_like 'Google Podcasts', '6.3.36.21.arm', 'Android', 'Android 5.0.2' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 8.1.0; Pixel Build/OPM2.171019.029; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36 GSA/7.8.26.21.arm64" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 8.1.0; Pixel Build/OPM2.171019.029; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36 GSA/7.8.26.21.arm64") } + + it_should_behave_like 'Google Podcasts', '7.8.26.21.arm64', 'Android', 'Android 8.1.0' +end + +describe "UserAgent: GooglePodcasts/2.0.10 iPad/14.5 hw/iPad6_3" do + let!(:useragent) { UserAgent.parse("GooglePodcasts/2.0.10 iPad/14.5 hw/iPad6_3") } + + it_should_behave_like 'Google Podcasts', '2.0.10', 'iPad', 'iOS 14.5' +end + +describe "UserAgent: GooglePodcasts/2.0.10 iPhone/12.1 hw/iPhone11_2" do + let!(:useragent) { UserAgent.parse("GooglePodcasts/2.0.10 iPhone/12.1 hw/iPhone11_2") } + + it_should_behave_like 'Google Podcasts', '2.0.10', 'iPhone', 'iOS 12.1' +end + +describe "UserAgent: GooglePodcasts/2.0.9 iPod_touch/14.4.1 hw/iPod9_1" do + let!(:useragent) { UserAgent.parse("GooglePodcasts/2.0.9 iPod_touch/14.4.1 hw/iPod9_1") } + + it_should_behave_like 'Google Podcasts', '2.0.9', 'iPod touch', 'iOS 14.4.1' +end diff --git a/spec/browsers/googlebot_user_agent_spec.rb b/spec/browsers/googlebot_user_agent_spec.rb new file mode 100644 index 0000000..0d4b39f --- /dev/null +++ b/spec/browsers/googlebot_user_agent_spec.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Googlebot' do + it "returns 'Googlebot' as its browser" do + expect(useragent.browser).to eq('Googlebot') + end + + it { expect(useragent.platform).to be nil } + it { expect(useragent.os).to be nil } + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Googlebot" do + let!(:useragent) { UserAgent.parse("Googlebot") } + + it_should_behave_like 'Googlebot' +end + +describe "UserAgent: Googlebot/2.1" do + let!(:useragent) { UserAgent.parse("Googlebot/2.1") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot/2.1 (http://www.googlebot.com/bot.html)" do + let!(:useragent) { UserAgent.parse("Googlebot/2.1 (http://www.googlebot.com/bot.html)") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot/2.1 ( http://www.googlebot.com/bot.html)" do + let!(:useragent) { UserAgent.parse("Googlebot/2.1 ( http://www.googlebot.com/bot.html)") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot/2.1 (+http://www.googlebot.com/bot.html)" do + let!(:useragent) { UserAgent.parse("Googlebot/2.1 (+http://www.googlebot.com/bot.html)") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot/2.1 (+http://www.google.com/bot.html)" do + let!(:useragent) { UserAgent.parse("Googlebot/2.1 (+http://www.google.com/bot.html)") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Mozilla/5.0 (compatible; Googlebot/2.1;++http://www.google.com/bot.html)" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (compatible; Googlebot/2.1;++http://www.google.com/bot.html)") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Mozilla/5.0 (compatible; Googlebot/2.1; http://www.google.com/bot.html)" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (compatible; Googlebot/2.1; http://www.google.com/bot.html)") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/91.0.4472.90 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/91.0.4472.90 Safari/537.36") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot-Audio" do + let!(:useragent) { UserAgent.parse("Googlebot-Audio") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot-Image/1.0" do + let!(:useragent) { UserAgent.parse("Googlebot-Image/1.0") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot-News" do + let!(:useragent) { UserAgent.parse("Googlebot-News") } + + it_behaves_like 'Googlebot' +end + +describe "UserAgent: Googlebot-Video/1.0" do + let!(:useragent) { UserAgent.parse("Googlebot-Video/1.0") } + + it_behaves_like 'Googlebot' +end diff --git a/spec/browsers/himalaya_user_agent_spec.rb b/spec/browsers/himalaya_user_agent_spec.rb new file mode 100644 index 0000000..c664efb --- /dev/null +++ b/spec/browsers/himalaya_user_agent_spec.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Himalaya' do |version, platform, os| + it "returns 'Himalaya' as its browser" do + expect(useragent.browser).to eq('Himalaya') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Himalaya/2.4.82 Android/29 (EVR-L29)" do + let(:useragent) { UserAgent.parse("Himalaya/2.4.82 Android/29 (EVR-L29)") } + + it_behaves_like 'Himalaya', '2.4.82', 'Android', 'Android 10' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 10; SM-A115M Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/90.0.4430.82 Mobile Safari/537.36 Himalaya/2.4.70" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 10; SM-A115M Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/90.0.4430.82 Mobile Safari/537.36 Himalaya/2.4.70") } + + it_behaves_like 'Himalaya', '2.4.70', 'Android', 'Android 10' +end + +describe "UserAgent: Himalaya/1 CFNetwork/1236 Darwin/20.4.0" do + let(:useragent) { UserAgent.parse("Himalaya/1 CFNetwork/1236 Darwin/20.4.0") } + + it_behaves_like 'Himalaya', '1', 'iOS', 'iOS 14.5' +end + +describe "UserAgent: Himalaya/2.4.80 (iPhone; iOS 14.4.2; Scale/2.00; CFNetwork; iPhone10,1)" do + let(:useragent) { UserAgent.parse("Himalaya/2.4.80 (iPhone; iOS 14.4.2; Scale/2.00; CFNetwork; iPhone10,1)") } + + it_behaves_like 'Himalaya', '2.4.80', 'iPhone', 'iOS 14.4.2' +end + +describe "UserAgent: Himalaya/2.2.10 (iPad; iOS 12.0.1; Scale/2.00; CFNetwork; iPad6,11)" do + let(:useragent) { UserAgent.parse("Himalaya/2.2.10 (iPad; iOS 12.0.1; Scale/2.00; CFNetwork; iPad6,11)") } + + it_behaves_like 'Himalaya', '2.2.10', 'iPad', 'iOS 12.0.1' +end + +describe "UserAgent: Himalaya/2.2.15 (iPod touch; iOS 11.4; Scale/2.00; CFNetwork; iPod7,1)" do + let(:useragent) { UserAgent.parse("Himalaya/2.2.15 (iPod touch; iOS 11.4; Scale/2.00; CFNetwork; iPod7,1)") } + + it_behaves_like 'Himalaya', '2.2.15', 'iPod touch', 'iOS 11.4' +end diff --git a/spec/browsers/icatcher_user_agent_spec.rb b/spec/browsers/icatcher_user_agent_spec.rb new file mode 100644 index 0000000..9bd13cb --- /dev/null +++ b/spec/browsers/icatcher_user_agent_spec.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'iCatcher!' do |version, platform, os| + it "returns 'iCatcher!' as its browser" do + expect(useragent.browser).to eq('iCatcher!') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: iCatcher!/6.7.5 (iPhone; iOS 14.5.1; Scale/2.0)" do + let(:useragent) { UserAgent.parse("iCatcher!/6.7.5 (iPhone; iOS 14.5.1; Scale/2.0)") } + + it_behaves_like 'iCatcher!', '6.7.5', 'iPhone', 'iOS 14.5.1' +end + +describe "UserAgent: iCatcher!/3.0.7 (iPad; iOS 11.0; Scale/2.0)" do + let(:useragent) { UserAgent.parse("iCatcher!/3.0.7 (iPad; iOS 11.0; Scale/2.0)") } + + it_behaves_like 'iCatcher!', '3.0.7', 'iPad', 'iOS 11.0' +end + +describe "UserAgent: iCatcher!/3.5.1 (iPod touch; iOS 11.3; Scale/2.0)" do + let(:useragent) { UserAgent.parse("iCatcher!/3.5.1 (iPod touch; iOS 11.3; Scale/2.0)") } + + it_behaves_like 'iCatcher!', '3.5.1', 'iPod touch', 'iOS 11.3' +end + +describe "UserAgent: iCatcher! 1.8.4 (iPhone; iPhone OS 4.2.1; en_US)" do + let(:useragent) { UserAgent.parse("iCatcher! 1.8.4 (iPhone; iPhone OS 4.2.1; en_US)") } + + it_behaves_like 'iCatcher!', '1.8.4', 'iPhone', 'iOS 4.2.1' +end + +describe "UserAgent: iCatcher! 1.9.8.5 (iPod touch; iPhone OS 6.1.2; en_US)" do + let(:useragent) { UserAgent.parse("iCatcher! 1.9.8.5 (iPod touch; iPhone OS 6.1.2; en_US)") } + + it_behaves_like 'iCatcher!', '1.9.8.5', 'iPod touch', 'iOS 6.1.2' +end + +describe "UserAgent: icatcher/1.10 CFNetwork/758.5.3 Darwin/15.6.0" do + let(:useragent) { UserAgent.parse("icatcher/1.10 CFNetwork/758.5.3 Darwin/15.6.0") } + + it_behaves_like 'iCatcher!', '1.10', 'iOS', 'iOS 9.3.3' +end + +describe "UserAgent: iCatcher! podcast app/2.2.5" do + let(:useragent) { UserAgent.parse("iCatcher! podcast app/2.2.5") } + + it_behaves_like 'iCatcher!', '2.2.5', 'iOS', 'iOS' +end + +describe "UserAgent: iCatcher! Podcast Player/2.7.3" do + let(:useragent) { UserAgent.parse("iCatcher! Podcast Player/2.7.3") } + + it_behaves_like 'iCatcher!', '2.7.3', 'iOS', 'iOS' +end diff --git a/spec/browsers/iheart_radio_user_agent_spec.rb b/spec/browsers/iheart_radio_user_agent_spec.rb new file mode 100644 index 0000000..7fd48dc --- /dev/null +++ b/spec/browsers/iheart_radio_user_agent_spec.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'iHeartRadio' do |version, platform, os| + it "returns 'iHeartRadio' as its browser" do + expect(useragent.browser).to eq('iHeartRadio') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: iHeartRadio/1 CFNetwork/1098.6 Darwin/19.0.0" do + let!(:useragent) { UserAgent.parse("iHeartRadio/1 CFNetwork/1098.6 Darwin/19.0.0") } + + it_should_behave_like 'iHeartRadio', '1', 'iOS', 'iOS 13.0' +end + +describe "UserAgent: iHeartRadio/2020040104 CFNetwork/1121.2.2 Darwin/19.3.0" do + let!(:useragent) { UserAgent.parse("iHeartRadio/2020040104 CFNetwork/1121.2.2 Darwin/19.3.0") } + + it_should_behave_like 'iHeartRadio', '2020040104', 'iOS', 'iOS 13.3.1' +end + +describe "UserAgent: iHeartRadio/10.2.1 (iPhone; iOS 13.4; iPhone9,3)" do + let!(:useragent) { UserAgent.parse("iHeartRadio/10.2.1 (iPhone; iOS 13.4; iPhone9,3)") } + + it_should_behave_like 'iHeartRadio', '10.2.1', 'iPhone', 'iOS 13.4' +end + +describe "UserAgent: iHeartRadio/10.1.1 (iPad; iOS 14.2; iPad7,11)" do + let!(:useragent) { UserAgent.parse("iHeartRadio/10.1.1 (iPad; iOS 14.2; iPad7,11)") } + + it_should_behave_like 'iHeartRadio', '10.1.1', 'iPad', 'iOS 14.2' +end + +describe "UserAgent: iHeartRadio/10.1.1 (iPod touch; iOS 13.3.1; iPod9,1)" do + let!(:useragent) { UserAgent.parse("iHeartRadio/10.1.1 (iPod touch; iOS 13.3.1; iPod9,1)") } + + it_should_behave_like 'iHeartRadio', '10.1.1', 'iPod touch', 'iOS 13.3.1' +end + +describe "UserAgent: iHeartRadio/1.12.1 (Android Sdk 23)" do + let!(:useragent) { UserAgent.parse("iHeartRadio/1.12.1 (Android Sdk 23)") } + + it_should_behave_like 'iHeartRadio', '1.12.1', 'Android', 'Android 6.0' +end + +describe "UserAgent: iHeartRadio/1.0.0 (Android 10; SM-A505FN Build/QP1A.190711.020)" do + let!(:useragent) { UserAgent.parse("iHeartRadio/1.0.0 (Android 10; SM-A505FN Build/QP1A.190711.020)") } + + it_should_behave_like 'iHeartRadio', '1.0.0', 'Android', 'Android 10' +end + +describe "UserAgent: iHeartRadio/10.2.0 (Android 6.0.1; Nexus 7 Build/MMB30S)" do + let!(:useragent) { UserAgent.parse("iHeartRadio/10.2.0 (Android 6.0.1; Nexus 7 Build/MMB30S)") } + + it_should_behave_like 'iHeartRadio', '10.2.0', 'Android', 'Android 6.0.1' +end diff --git a/spec/browsers/internet_explorer_user_agent_spec.rb b/spec/browsers/internet_explorer_user_agent_spec.rb index 34b1ae7..5c88572 100644 --- a/spec/browsers/internet_explorer_user_agent_spec.rb +++ b/spec/browsers/internet_explorer_user_agent_spec.rb @@ -8,6 +8,18 @@ it "should return 'Windows' as its platform" do expect(@useragent.platform).to eq("Windows") end + + if type == :desktop + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + else + it { expect(@useragent).not_to be_desktop } + it { expect(@useragent).to be_mobile } + end + + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } end describe "UserAgent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko" do diff --git a/spec/browsers/iron_user_agent_spec.rb b/spec/browsers/iron_user_agent_spec.rb index 8f2f57f..80fd0e5 100644 --- a/spec/browsers/iron_user_agent_spec.rb +++ b/spec/browsers/iron_user_agent_spec.rb @@ -10,6 +10,14 @@ end end +shared_examples 'a desktop' do + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } +end + # http://www.useragentstring.com/Iron22.0.2150.0_id_19368.php describe "UserAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1250.0 Iron/22.0.2150.0 Safari/537.4'" do before do diff --git a/spec/browsers/itunes_user_agent_spec.rb b/spec/browsers/itunes_user_agent_spec.rb index 5bf78fa..0d03283 100644 --- a/spec/browsers/itunes_user_agent_spec.rb +++ b/spec/browsers/itunes_user_agent_spec.rb @@ -8,6 +8,12 @@ it "should return nil as its security" do expect(@useragent.security).to be_nil end + + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } end shared_examples "iTunes runs on" do |platform, os| diff --git a/spec/browsers/luminary_user_agent_spec.rb b/spec/browsers/luminary_user_agent_spec.rb new file mode 100644 index 0000000..12f883f --- /dev/null +++ b/spec/browsers/luminary_user_agent_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Luminary' do |version, platform, os| + it "returns 'Luminary' as its browser" do + expect(useragent.browser).to eq('Luminary') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Luminary/33.0 (Android 9; SM-G950F; samsung dreamlte; en)" do + let(:useragent) { UserAgent.parse("Luminary/33.0 (Android 9; SM-G950F; samsung dreamlte; en)") } + + it_behaves_like 'Luminary', '33.0', 'Android', 'Android 9' +end + +describe "UserAgent: Luminary/1.0.10 build 1377/Android SDK 28" do + let(:useragent) { UserAgent.parse("Luminary/1.0.10 build 1377/Android SDK 28") } + + it_behaves_like 'Luminary', '1.0.10', 'Android', 'Android 9' +end + +describe "UserAgent: Luminary/39.0 build 252/iOS 14.6" do + let(:useragent) { UserAgent.parse("Luminary/39.0 build 252/iOS 14.6") } + + it_behaves_like 'Luminary', '39.0', 'iOS', 'iOS 14.6' +end + +describe "UserAgent: Luminary/252 CFNetwork/1240.0.4 Darwin/20.5.0" do + let(:useragent) { UserAgent.parse("Luminary/252 CFNetwork/1240.0.4 Darwin/20.5.0") } + + it_behaves_like 'Luminary', '252', 'iOS', 'iOS 14.6' +end + +describe "UserAgent: Luminary/0.0.243 build 3319" do + let(:useragent) { UserAgent.parse("Luminary/0.0.243 build 3319") } + + it_behaves_like 'Luminary', '0.0.243', nil, nil +end diff --git a/spec/browsers/npr_one_user_agent_spec.rb b/spec/browsers/npr_one_user_agent_spec.rb new file mode 100644 index 0000000..415a0de --- /dev/null +++ b/spec/browsers/npr_one_user_agent_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'NPR One' do |version, platform, os| + it "returns 'NPR One' as its browser" do + expect(useragent.browser).to eq('NPR One') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: NPROneAndroid" do + let(:useragent) { UserAgent.parse("NPROneAndroid") } + + it_behaves_like 'NPR One', nil, 'Android', 'Android' +end + +describe "UserAgent: NPR%20One/316 CFNetwork/1240.0.4 Darwin/20.5.0" do + let(:useragent) { UserAgent.parse("NPR%20One/316 CFNetwork/1240.0.4 Darwin/20.5.0") } + + it_behaves_like 'NPR One', '316', 'iOS', 'iOS 14.6' +end + +describe "UserAgent: Dalvik/2.1.0 (Linux; U; Android 10; GM1917 Build/QKQ1.190716.003) nprone_android/1.9.9.3/OSv:10" do + let(:useragent) { UserAgent.parse("Dalvik/2.1.0 (Linux; U; Android 10; GM1917 Build/QKQ1.190716.003) nprone_android/1.9.9.3/OSv:10") } + + it_behaves_like 'NPR One', '1.9.9.3', 'Android', 'Android 10' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 10; Chromecast Build/QTS2.200918.033; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.181 Mobile Safari/537.36 NPR%20One/1.1.0%20%28593%29" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 10; Chromecast Build/QTS2.200918.033; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.181 Mobile Safari/537.36 NPR%20One/1.1.0%20%28593%29") } + + it_behaves_like 'NPR One', '1.1.0', 'Android', 'Android 10' +end diff --git a/spec/browsers/ok_http_user_agent_spec.rb b/spec/browsers/ok_http_user_agent_spec.rb new file mode 100644 index 0000000..daf8e7d --- /dev/null +++ b/spec/browsers/ok_http_user_agent_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'OkHttp' do |version, platform, os, type| + it "returns 'OkHttp' as its browser" do + expect(useragent.browser).to eq('OkHttp') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + else + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: okhttp/3.8.1" do + let(:useragent) { UserAgent.parse("okhttp/3.8.1") } + + it_behaves_like 'OkHttp', '3.8.1', nil, nil, nil +end + +describe "UserAgent: okhttp/3.10.0 BMID/E67925BB27" do + let!(:useragent) { UserAgent.parse("okhttp/3.10.0 BMID/E67925BB27") } + + it_behaves_like 'OkHttp', '3.10.0', nil, nil, nil +end + +describe "UserAgent: okhttp/3.8.1 Dalvik/2.1.0 (Linux; U; Android 7.1.1; vivo X20A Build/NMF26X) baiduboxapp/10.1.0.11 (Baidu; P1 7.1.1)" do + let!(:useragent) { UserAgent.parse("okhttp/3.8.1 Dalvik/2.1.0 (Linux; U; Android 7.1.1; vivo X20A Build/NMF26X) baiduboxapp/10.1.0.11 (Baidu; P1 7.1.1)") } + + it_behaves_like 'OkHttp', '3.8.1', 'Android', 'Android 7.1.1', :mobile +end + +describe "UserAgent: okhttp/2.7.5 nyt-android/6.19.3 ,okhttp/2.7.5 nyt-android/6.19.3" do + let!(:useragent) { UserAgent.parse("okhttp/2.7.5 nyt-android/6.19.3 ,okhttp/2.7.5 nyt-android/6.19.3") } + + it_behaves_like 'OkHttp', '2.7.5', 'Android', nil, :mobile +end + +describe "UserAgent: NRC Audio/1.0.14 (nl.nrc.audio; build:19; Android 11; Sdk:30; Manufacturer:samsung; Model: SM-A515F) OkHttp/4.9.0" do + let!(:useragent) { UserAgent.parse("NRC Audio/1.0.14 (nl.nrc.audio; build:19; Android 11; Sdk:30; Manufacturer:samsung; Model: SM-A515F) OkHttp/4.9.0") } + + it_behaves_like 'OkHttp', '4.9.0', 'Android', 'Android 11', :mobile +end diff --git a/spec/browsers/opera_user_agent_spec.rb b/spec/browsers/opera_user_agent_spec.rb index d1c763d..ba45d88 100644 --- a/spec/browsers/opera_user_agent_spec.rb +++ b/spec/browsers/opera_user_agent_spec.rb @@ -8,6 +8,21 @@ it "should return a Version object for version" do expect(@useragent.version).to be_a(UserAgent::Version) end + + if type == :desktop + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + elsif type == :mobile + it { expect(@useragent).to be_mobile } + it { expect(@useragent).not_to be_desktop } + else + it { expect(@useragent).not_to be_mobile } + it { expect(@useragent).not_to be_desktop } + end + + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } end # http://www.useragentstring.com/Opera12.14_id_19612.php diff --git a/spec/browsers/other_user_agent_spec.rb b/spec/browsers/other_user_agent_spec.rb index dae7a58..5f3ea9f 100644 --- a/spec/browsers/other_user_agent_spec.rb +++ b/spec/browsers/other_user_agent_spec.rb @@ -23,6 +23,9 @@ it { expect(@useragent).not_to be_mobile } it { expect(@useragent).not_to be_bot } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_desktop } + it { expect(useragent).not_to be_web_browser } end describe "UserAgent: ''" do diff --git a/spec/browsers/overcast_user_agent_spec.rb b/spec/browsers/overcast_user_agent_spec.rb new file mode 100644 index 0000000..a3f448d --- /dev/null +++ b/spec/browsers/overcast_user_agent_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Overcast' do |version, platform, os, type| + it "returns 'Overcast' as its browser" do + expect(useragent.browser).to eq('Overcast') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_bot } + elsif type == :bot + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Overcast/3.0 (+http://overcast.fm/; iOS podcast app) BMID/E6793162B9" do + let!(:useragent) { UserAgent.parse("Overcast/3.0 (+http://overcast.fm/; iOS podcast app) BMID/E6793162B9") } + + it_behaves_like 'Overcast', '3.0', 'iOS', nil, :mobile +end + +describe "UserAgent: Overcast (+http://overcast.fm/; Apple Watch podcast app)" do + let!(:useragent) { UserAgent.parse("Overcast (+http://overcast.fm/; Apple Watch podcast app)") } + + it_behaves_like 'Overcast', '', 'Apple Watch', nil, :mobile +end + +describe "UserAgent: Overcast/857 CFNetwork/1209 Darwin/20.3.0" do + let!(:useragent) { UserAgent.parse("Overcast/857 CFNetwork/1209 Darwin/20.3.0") } + + it_behaves_like 'Overcast', '857', 'iOS', 'iOS 14.4.x', :mobile +end + +describe "UserAgent: Overcast/1.0 Podcast Sync (+http://overcast.fm/)" do + let!(:useragent) { UserAgent.parse("Overcast/1.0 Podcast Sync (+http://overcast.fm/)") } + + it_behaves_like 'Overcast', '1.0', nil, nil, :bot +end diff --git a/spec/browsers/pandora_rss_crawler_user_agent_spec.rb b/spec/browsers/pandora_rss_crawler_user_agent_spec.rb new file mode 100644 index 0000000..ce5b6c0 --- /dev/null +++ b/spec/browsers/pandora_rss_crawler_user_agent_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'PandoraRSSCrawler' do |version| + it "should return 'Pandora' as its browser" do + expect(useragent.browser).to eq('Pandora') + end + + it "should return '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it { expect(useragent.platform).to be nil } + it { expect(useragent.os).to be nil } + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "PandoraRSSCrawler/1.0 (podcastpartnerships@pandora.com)" do + let!(:useragent) { UserAgent.parse("PandoraRSSCrawler/1.0 (podcastpartnerships@pandora.com)") } + + it_should_behave_like 'PandoraRSSCrawler', '1.0' +end diff --git a/spec/browsers/pandora_user_agent_spec.rb b/spec/browsers/pandora_user_agent_spec.rb new file mode 100644 index 0000000..dcae919 --- /dev/null +++ b/spec/browsers/pandora_user_agent_spec.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Pandora' do |version, platform, os, type| + it "should return 'Pandora' as its browser" do + expect(useragent.browser).to eq('Pandora') + end + + it "should return '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "should return '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "should return '#{os}' as its os" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + elsif type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "Mozilla/5.0 (iPad; CPU OS 10_3_4 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G61 Pandora/1812.1" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (iPad; CPU OS 10_3_4 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G61 Pandora/1812.1") } + + it_should_behave_like 'Pandora', '1812.1', 'iPad', 'iOS 10.3.4', :mobile +end + +describe "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89 Pandora/1901.1.1" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89 Pandora/1901.1.1") } + + it_should_behave_like 'Pandora', '1901.1.1', 'iPhone', 'iOS 10.3.2', :mobile +end + +describe "Mozilla/5.0 (iPod touch; CPU iPhone OS 11_2_5 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Mobile/15D60 Pandora/1908.1" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (iPod touch; CPU iPhone OS 11_2_5 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Mobile/15D60 Pandora/1908.1") } + + it_should_behave_like 'Pandora', '1908.1', 'iPod touch', 'iOS 11.2.5', :mobile +end + +describe "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.128 Electron/4.2.10 Safari/537.36 PandoraApp/15.0.3" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.128 Electron/4.2.10 Safari/537.36 PandoraApp/15.0.3") } + + it_should_behave_like 'Pandora', '15.0.3', 'Macintosh', 'OS X 10.10.5', :desktop +end + +describe "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.128 Electron/4.2.10 Safari/537.36 PandoraApp/15.0.2" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.128 Electron/4.2.10 Safari/537.36 PandoraApp/15.0.2") } + + it_should_behave_like 'Pandora', '15.0.2', 'Windows', 'Windows 10', :desktop +end + +describe "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) -0 Chrome/69.0.3497.128 Electron/4.1.4 Safari/537.36 PandoraDesktopApp/1.8.4" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) -0 Chrome/69.0.3497.128 Electron/4.1.4 Safari/537.36 PandoraDesktopApp/1.8.4") } + + it_should_behave_like 'Pandora', '1.8.4', 'Macintosh', 'OS X 10.10.5', :desktop +end + +describe "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.106 Electron/4.0.6 Safari/537.36 PandoraDesktopApp/1.8.2" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.106 Electron/4.0.6 Safari/537.36 PandoraDesktopApp/1.8.2") } + + it_should_behave_like 'Pandora', '1.8.2', 'Windows', 'Windows 10', :desktop +end + +describe "Pandora Audio/2102.1 (Linux;Android 9.1) ExoPlayerLib/2.9.6" do + let!(:useragent) { UserAgent.parse("Pandora Audio/2102.1 (Linux;Android 9.1) ExoPlayerLib/2.9.6") } + + it_should_behave_like 'Pandora', '2102.1', 'Android', 'Android 9.1', :mobile +end + +describe "Pandora/1811.1 Android/7.1.1 kelly (ExoPlayerLib1.5.14.1)" do + let!(:useragent) { UserAgent.parse("Pandora/1811.1 Android/7.1.1 kelly (ExoPlayerLib1.5.14.1)") } + + it_should_behave_like 'Pandora', '1811.1', 'Android', 'Android 7.1.1', :mobile +end + +describe "Pandora/2107 CFNetwork/1125.2 Darwin/19.4.0" do + let!(:useragent) { UserAgent.parse("Pandora/2107 CFNetwork/1125.2 Darwin/19.4.0") } + + it_should_behave_like 'Pandora', '2107', 'iOS', 'iOS 13.4.x', :mobile +end diff --git a/spec/browsers/playstation_user_agent_spec.rb b/spec/browsers/playstation_user_agent_spec.rb index df310fa..83102e6 100644 --- a/spec/browsers/playstation_user_agent_spec.rb +++ b/spec/browsers/playstation_user_agent_spec.rb @@ -12,6 +12,8 @@ it 'returns false for mobile?' do expect(@useragent.mobile?).to be false end + + it { expect(useragent).not_to be_web_browser } end describe "UserAgent: Mozilla/5.0 (PLAYSTATION 3 4.75) AppleWebKit/531.22.8 (KHTML, like Gecko)" do diff --git a/spec/browsers/pocket_casts_user_agent_spec.rb b/spec/browsers/pocket_casts_user_agent_spec.rb new file mode 100644 index 0000000..c9f4dba --- /dev/null +++ b/spec/browsers/pocket_casts_user_agent_spec.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Pocket Casts' do |version, platform, os, type| + it "returns 'Pocket Casts' as its browser" do + expect(useragent.browser).to eq('Pocket Casts') + end + + it "should return '#{version}' as its version" do + expect(useragent.version).to eql(version) + end + + it "should return '#{platform}' as its platform" do + expect(useragent.platform).to eql(platform) + end + + it "should return '#{os}' as its operating system" do + expect(useragent.os).to eql(os) + end + + if type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + elsif type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_bot } + elsif type == :bot + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + else + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Pocket Casts BMID/E678F58F21" do + let!(:useragent) { UserAgent.parse("Pocket Casts BMID/E678F58F21") } + + it_behaves_like 'Pocket Casts', nil, nil, nil, nil +end + +describe "UserAgent: PocketCasts/1.0 (Pocket Casts Feed Parser; +http://pocketcasts.com/)" do + let!(:useragent) { UserAgent.parse("PocketCasts/1.0 (Pocket Casts Feed Parser; +http://pocketcasts.com/)") } + + it_behaves_like 'Pocket Casts', '1.0', nil, nil, :bot +end + +describe "UserAgent: Shifty Jelly Pocket Casts, Android v4.5.3" do + let!(:useragent) { UserAgent.parse("Shifty Jelly Pocket Casts, Android v4.5.3") } + + it_behaves_like 'Pocket Casts', '4.5.3', 'Android', nil, :mobile +end + +describe "UserAgent: Shifty Jelly Pocket Casts, iOS v4.3" do + let!(:useragent) { UserAgent.parse("Shifty Jelly Pocket Casts, iOS v4.3") } + + it_behaves_like 'Pocket Casts', '4.3', 'iOS', nil, :mobile +end + +describe "UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Pocket Casts/1.1 Pocket Casts/1.1" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Pocket Casts/1.1 Pocket Casts/1.1") } + + it_behaves_like 'Pocket Casts', '1.1', 'Windows', 'Windows 10', :desktop +end + +describe "UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Pocketcast/2.1.0 Chrome/58.0.3029.110 Molecule/2.1.0 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Pocketcast/2.1.0 Chrome/58.0.3029.110 Molecule/2.1.0 Safari/537.36") } + + it_behaves_like 'Pocket Casts', '2.1.0', 'Macintosh', 'OS X 10.14.4', :desktop +end + +describe "UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Pocketcasts/3.0.11 Chrome/58.0.3029.110 Molecule/3.0.11 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Pocketcasts/3.0.11 Chrome/58.0.3029.110 Molecule/3.0.11 Safari/537.36") } + + it_behaves_like 'Pocket Casts', '3.0.11', 'Windows', 'Windows 10', :desktop +end + +describe "UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) PocketCasts/1.0.0 Chrome/59.0.3071.115 Electron/1.8.3 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) PocketCasts/1.0.0 Chrome/59.0.3071.115 Electron/1.8.3 Safari/537.36") } + + it_behaves_like 'Pocket Casts', '1.0.0', 'Windows', 'Windows 10', :desktop +end diff --git a/spec/browsers/pod_2_watch_spec.rb b/spec/browsers/pod_2_watch_spec.rb new file mode 100644 index 0000000..a940d36 --- /dev/null +++ b/spec/browsers/pod_2_watch_spec.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +require 'user_agent' + +describe UserAgent::Browsers::Pod2Watch do + let(:user_agent) { UserAgent.parse(ua_string) } + + shared_examples 'a Pod2Watch browser on watchOS' do |os_version = nil, version = nil| + it { expect(user_agent.browser).to eql 'Pod2Watch' } + it { expect(user_agent).not_to be_bot } + it { expect(user_agent).to be_mobile } + it { expect(user_agent.os).to eql ['watchOS', os_version].compact.join(' ') } + it { expect(user_agent.platform).to eql 'Apple Watch' } + it { expect(useragent).not_to be_web_browser } + + if version + it { expect(user_agent.version.to_s).to eql version } + else + it { expect(user_agent.version).to be_nil } + end + end + + context 'with "Pod2Watch"' do + let(:ua_string) { 'Pod2Watch' } + + it_behaves_like 'a Pod2Watch browser on watchOS', nil, nil + end + + context 'with "Pod2Watch WatchKit Extension/2.0 (com.hollingsware.Pod2Watch.watchkitapp.watchkitextension; build:9; watchOS 4.0.0) Alamofire/4.5.1"' do + let(:ua_string) { 'Pod2Watch WatchKit Extension/2.0 (com.hollingsware.Pod2Watch.watchkitapp.watchkitextension; build:9; watchOS 4.0.0) Alamofire/4.5.1' } + + it_behaves_like 'a Pod2Watch browser on watchOS', '4.0.0', '2.0' + end + + context 'with a watchOS product but no version' do + let(:ua_string) { 'Pod2Watch%20WatchKit%20Extension fancy/2.1 (build:9; watchOS) Alamofire/4.5.1' } + + it_behaves_like 'a Pod2Watch browser on watchOS', nil, '2.1' + end + + context 'with "Pod2Watch%20WatchKit%20Extension/14 CFNetwork/889.7 Darwin/17.2.0"' do + let(:ua_string) { 'Pod2Watch%20WatchKit%20Extension/14 CFNetwork/889.7 Darwin/17.2.0' } + + it_behaves_like 'a Pod2Watch browser on watchOS', '4.1', '14' + end + + context 'with an unmappable Darwin version' do + let(:ua_string) { 'Pod2Watch%20WatchKit%20Extension/14 CFNetwork/889.7 Darwin/0.1.2' } + + it_behaves_like 'a Pod2Watch browser on watchOS', nil, '14' + end + + context 'with a version on a subsequent product' do + let(:ua_string) { 'Pod2Watch%20WatchKit%20Extension CFNetwork/889.7 Darwin/18.0.0' } + + it_behaves_like 'a Pod2Watch browser on watchOS', '5.0.x', '889.7' + end +end diff --git a/spec/browsers/pod_mn_user_agent_spec.rb b/spec/browsers/pod_mn_user_agent_spec.rb new file mode 100644 index 0000000..454db20 --- /dev/null +++ b/spec/browsers/pod_mn_user_agent_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'PodMN' do |version, platform, os| + it "returns 'PodMN' as its browser" do + expect(useragent.browser).to eq('PodMN') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: PodMN/Android 1.3.1 (Android 11; SM-G970U Build/RP1A.200720.012)" do + let(:useragent) { UserAgent.parse("PodMN/Android 1.3.1 (Android 11; SM-G970U Build/RP1A.200720.012)") } + + it_should_behave_like 'PodMN', '1.3.1', 'Android', 'Android 11' +end + +describe "UserAgent: PodMN/1.2.0 (Linux;Android 9) ExoPlayerLib/2.9.6" do + let(:useragent) { UserAgent.parse("PodMN/1.2.0 (Linux;Android 9) ExoPlayerLib/2.9.6") } + + it_should_behave_like 'PodMN', '1.2.0', 'Android', 'Android 9' +end + +describe "UserAgent: PodMN/iOS 1.1.8 (iPhone 8/14.6)" do + let(:useragent) { UserAgent.parse("PodMN/iOS 1.1.8 (iPhone 8/14.6)") } + + it_should_behave_like 'PodMN', '1.1.8', 'iPhone', 'iOS 14.6' +end + +describe 'UserAgent: PodMN/iOS 1.1.8 (iPad Pro 9.7"/14.4.2)' do + let(:useragent) { UserAgent.parse('PodMN/iOS 1.1.8 (iPad Pro 9.7"/14.4.2)') } + + it_should_behave_like 'PodMN', '1.1.8', 'iPad', 'iOS 14.4.2' +end + +describe "UserAgent: PodMN/1 CFNetwork/1121.2.2 Darwin/19.3.0" do + let(:useragent) { UserAgent.parse("PodMN/1 CFNetwork/1121.2.2 Darwin/19.3.0") } + + it_should_behave_like 'PodMN', '1', 'iOS', 'iOS 13.3.1' +end diff --git a/spec/browsers/podbean_user_agent_spec.rb b/spec/browsers/podbean_user_agent_spec.rb new file mode 100644 index 0000000..6ef92de --- /dev/null +++ b/spec/browsers/podbean_user_agent_spec.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Podbean' do |version, platform, os| + it "returns 'Podbean' as its browser" do + expect(useragent.browser).to eq('Podbean') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Podbean/Android App 8.5.1 (http://podbean.com),a3d7ec202761774354efde899ad29a6a" do + let(:useragent) { UserAgent.parse("Podbean/Android App 8.5.1 (http://podbean.com),a3d7ec202761774354efde899ad29a6a") } + + it_behaves_like 'Podbean', '8.5.1', 'Android', nil +end + +describe "UserAgent: Podbean/Android App (http://podbean.com) ,099c49b02ed4a2d7da8a9bbb11a47" do + let(:useragent) { UserAgent.parse("Podbean/Android App (http://podbean.com) ,099c49b02ed4a2d7da8a9bbb11a47") } + + it_behaves_like 'Podbean', nil, 'Android', nil +end + +describe "UserAgent: Podbean/Android App 5.7.1 (http://podbean.com) ,8f16fbdcbb38da97ec2bea119b3890fe/5.7.1 (Linux;Android 7.0) ExoPlayerLib/2.6.0" do + let(:useragent) { UserAgent.parse("Podbean/Android App 5.7.1 (http://podbean.com) ,8f16fbdcbb38da97ec2bea119b3890fe/5.7.1 (Linux;Android 7.0) ExoPlayerLib/2.6.0") } + + it_behaves_like 'Podbean', '5.7.1', 'Android', 'Android 7.0' +end + +describe "UserAgent: Podbean/iOS (http://podbean.com) 5.3.9 - 4726c87b825e77fda656723a2d6eb484" do + let(:useragent) { UserAgent.parse("Podbean/iOS (http://podbean.com) 5.3.9 - 4726c87b825e77fda656723a2d6eb484") } + + it_behaves_like 'Podbean', '5.3.9', 'iOS', nil +end + +describe "UserAgent: Podbean/iOS (http://podbean.com) 5.0 - 8f16fbdc25e77fdd4a2d6723a2d6eb484" do + let(:useragent) { UserAgent.parse("Podbean/iOS (http://podbean.com) 5.0 - 8f16fbdc25e77fdd4a2d6723a2d6eb484") } + + it_behaves_like 'Podbean', '5.0', 'iOS', nil +end + +describe "UserAgent: Podbean/1374 CFNetwork/978.0.7 Darwin/18.7.0" do + let(:useragent) { UserAgent.parse("Podbean/1374 CFNetwork/978.0.7 Darwin/18.7.0") } + + it_behaves_like 'Podbean', '1374', 'iOS', 'iOS 12.4.x' +end diff --git a/spec/browsers/podcast_addict_user_agent_spec.rb b/spec/browsers/podcast_addict_user_agent_spec.rb index b4e4794..02b0208 100644 --- a/spec/browsers/podcast_addict_user_agent_spec.rb +++ b/spec/browsers/podcast_addict_user_agent_spec.rb @@ -17,9 +17,11 @@ expect(@useragent.security).to eq(:strong) end - it 'is a mobile user agent' do - expect(@useragent.mobile?).to be true - end + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } end describe "UserAgent: Podcast Addict - Dalvik/1.6.0 (Linux; U; Android 4.4.2; LG-D631 Build/KOT49I.D63110b)" do diff --git a/spec/browsers/podcast_republic_user_agent_spec.rb b/spec/browsers/podcast_republic_user_agent_spec.rb new file mode 100644 index 0000000..10934e5 --- /dev/null +++ b/spec/browsers/podcast_republic_user_agent_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Podcast Republic' do |version, os| + it "returns 'Podcast Republic' as its browser" do + expect(useragent.browser).to eq('Podcast Republic') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'Android' as its platform" do + expect(useragent.platform).to eq('Android') + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: PodcastRepublic/18.0 (Linux; U; Android 11;blueline/RQ2A.210505.002)" do + let!(:useragent) { UserAgent.parse("PodcastRepublic/18.0 (Linux; U; Android 11;blueline/RQ2A.210505.002)") } + + it_should_behave_like 'Podcast Republic', '18.0', 'Android 11' +end + +describe "UserAgent: PodcastRepublic/18.0 (Linux; U; Android 9;J8210/55.0.A.11.25)" do + let!(:useragent) { UserAgent.parse("PodcastRepublic/18.0 (Linux; U; Android 9;J8210/55.0.A.11.25)") } + + it_should_behave_like 'Podcast Republic', '18.0', 'Android 9' +end diff --git a/spec/browsers/podimo_user_agent_spec.rb b/spec/browsers/podimo_user_agent_spec.rb new file mode 100644 index 0000000..88c3502 --- /dev/null +++ b/spec/browsers/podimo_user_agent_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Podimo' do |version, platform, os| + it "returns 'Podimo' as its browser" do + expect(useragent.browser).to eq('Podimo') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Podimo/1.39.4 build 290/Android 30" do + let(:useragent) { UserAgent.parse("Podimo/1.39.4 build 290/Android 30") } + + it_should_behave_like 'Podimo', '1.39.4', 'Android', 'Android 11' +end + +describe "UserAgent: Podimo/1.39.4 build 316/iOS 14.6" do + let(:useragent) { UserAgent.parse("Podimo/1.39.4 build 316/iOS 14.6") } + + it_should_behave_like 'Podimo', '1.39.4', 'iOS', 'iOS 14.6' +end + +describe "UserAgent: Podimo/49 CFNetwork/978.0.7 Darwin/18.7.0" do + let(:useragent) { UserAgent.parse("Podimo/49 CFNetwork/978.0.7 Darwin/18.7.0") } + + it_should_behave_like 'Podimo', '49', 'iOS', 'iOS 12.4.x' +end diff --git a/spec/browsers/podkicker_user_agent_spec.rb b/spec/browsers/podkicker_user_agent_spec.rb new file mode 100644 index 0000000..70e89a8 --- /dev/null +++ b/spec/browsers/podkicker_user_agent_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Podkicker' do |version| + it "returns 'Podkicker' as its browser" do + expect(useragent.browser).to eq('Podkicker') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'Android' as its platform" do + expect(useragent.platform).to eq('Android') + end + + it "returns 'Android' as its os" do + expect(useragent.os).to eq('Android') + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Podkicker Pro/3.1.19.RC-GP-Pro(2028)" do + let(:useragent) { UserAgent.parse("Podkicker Pro/3.1.19.RC-GP-Pro(2028)") } + + it_behaves_like 'Podkicker', '3.1.19.RC-GP-Pro(2028)' +end + +describe "UserAgent: Podkicker/2.2.10" do + let(:useragent) { UserAgent.parse("Podkicker/2.2.10") } + + it_behaves_like 'Podkicker', '2.2.10' +end + +describe "UserAgent: Podkicker Classic/1.2.9" do + let(:useragent) { UserAgent.parse("Podkicker Classic/1.2.9") } + + it_behaves_like 'Podkicker', '1.2.9' +end diff --git a/spec/browsers/podverse_user_agent_spec.rb b/spec/browsers/podverse_user_agent_spec.rb new file mode 100644 index 0000000..b569003 --- /dev/null +++ b/spec/browsers/podverse_user_agent_spec.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Podverse' do |version, platform, os| + it "returns 'Podverse' as its browser" do + expect(useragent.browser).to eq('Podverse') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Podverse/F-Droid Android Mobile App/" do + let(:useragent) { UserAgent.parse("Podverse/F-Droid Android Mobile App/") } + + it_should_behave_like 'Podverse', nil, 'Android', 'Android' +end + +describe "UserAgent: Podverse/Android Mobile App/Mozilla/5.0 (Linux; Android 10; LYA-L29 Build/HUAWEILYA-L29; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/90.0.4430.91 Mobile Safari/537.36" do + let(:useragent) { UserAgent.parse("Podverse/Android Mobile App/Mozilla/5.0 (Linux; Android 10; LYA-L29 Build/HUAWEILYA-L29; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/90.0.4430.91 Mobile Safari/537.36") } + + it_should_behave_like 'Podverse', nil, 'Android', 'Android 10' +end + +describe "UserAgent: Podverse/7 CFNetwork/902.2 Darwin/17.7.0" do + let(:useragent) { UserAgent.parse("Podverse/7 CFNetwork/902.2 Darwin/17.7.0") } + + it_should_behave_like 'Podverse', '7', 'iOS', 'iOS 11.4.1' +end + +describe "UserAgent: Podverse/iOS Mobile App/Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89" do + let(:useragent) { UserAgent.parse("Podverse/iOS Mobile App/Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89") } + + it_should_behave_like 'Podverse', nil, 'iPhone', 'iOS 10.3.2' +end + +describe "UserAgent: Podverse/iOS Mobile App/Mozilla/5.0 (iPad; CPU OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" do + let(:useragent) { UserAgent.parse("Podverse/iOS Mobile App/Mozilla/5.0 (iPad; CPU OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148") } + + it_should_behave_like 'Podverse', nil, 'iPad', 'iOS 14.2' +end + +describe "UserAgent: Podverse/Feed Parser" do + let(:useragent) { UserAgent.parse("Podverse/Feed Parser") } + + it_should_behave_like 'Podverse', nil, nil, nil +end diff --git a/spec/browsers/radio_public_crawler_user_agent_spec.rb b/spec/browsers/radio_public_crawler_user_agent_spec.rb new file mode 100644 index 0000000..276093c --- /dev/null +++ b/spec/browsers/radio_public_crawler_user_agent_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'RadioPublicCrawler' do + it "returns 'RadioPublic' as its browser" do + expect(useragent.browser).to eq('RadioPublic') + end + + it { expect(useragent.platform).to be_nil } + it { expect(useragent.os).to be_nil } + + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: RadioPublic-Web/e0d2cd1" do + let(:useragent) { UserAgent.parse("RadioPublic-Web/e0d2cd1") } + + it_behaves_like 'RadioPublicCrawler' +end diff --git a/spec/browsers/radio_public_user_agent_spec.rb b/spec/browsers/radio_public_user_agent_spec.rb new file mode 100644 index 0000000..1f81340 --- /dev/null +++ b/spec/browsers/radio_public_user_agent_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'RadioPublic' do |version, platform, os| + it "returns 'RadioPublic' as its browser" do + expect(useragent.browser).to eq('RadioPublic') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: RadioPublic/android-2.2" do + let(:useragent) { UserAgent.parse("RadioPublic/android-2.2") } + + it_should_behave_like 'RadioPublic', '2.2', 'Android', 'Android' +end + +describe "UserAgent: RadioPublic/android-2.2 ,Mozilla/5.0 (Linux; Android 7.0; 5086D Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Mobile Safari/537.36" do + let(:useragent) { UserAgent.parse("RadioPublic/android-2.2 ,Mozilla/5.0 (Linux; Android 7.0; 5086D Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Mobile Safari/537.36") } + + it_should_behave_like 'RadioPublic', '2.2', 'Android', 'Android 7.0' +end + +describe "UserAgent: RadioPublic Android 1.0.26" do + let(:useragent) { UserAgent.parse("RadioPublic Android 1.0.26") } + + it_should_behave_like 'RadioPublic', '1.0.26', 'Android', 'Android' +end + +describe "UserAgent: RadioPublic/iOS-2.0" do + let(:useragent) { UserAgent.parse("RadioPublic/iOS-2.0") } + + it_should_behave_like 'RadioPublic', '2.0', 'iOS', 'iOS' +end + +describe "UserAgent: RadioPublic iOS 2.0.0" do + let(:useragent) { UserAgent.parse("RadioPublic iOS 2.0.0") } + + it_should_behave_like 'RadioPublic', '2.0.0', 'iOS', 'iOS' +end + +describe "UserAgent: RadioPublic/1 CFNetwork/808.2.16 Darwin/16.3.0" do + let(:useragent) { UserAgent.parse("RadioPublic/1 CFNetwork/808.2.16 Darwin/16.3.0") } + + it_should_behave_like 'RadioPublic', '1', 'iOS', 'iOS 10.2.x' +end + +describe "UserAgent: RadioPublic/1.0 (com.radiopublic.app; build:50; iOS 10.0.0) Alamofire/4.0.0" do + let(:useragent) { UserAgent.parse("RadioPublic/1.0 (com.radiopublic.app; build:50; iOS 10.0.0) Alamofire/4.0.0") } + + it_should_behave_like 'RadioPublic', '1.0', 'iOS', 'iOS 10.0.0' +end diff --git a/spec/browsers/samsung_user_agent_spec.rb b/spec/browsers/samsung_user_agent_spec.rb new file mode 100644 index 0000000..e4a9b79 --- /dev/null +++ b/spec/browsers/samsung_user_agent_spec.rb @@ -0,0 +1,61 @@ +require 'user_agent' + +shared_examples 'SamsungBrowser' do |version, platform, os| + it "returns 'SamsungBrowser' as its browser" do + expect(useragent.browser).to eq('Samsung Internet Browser') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns #{platform} as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns #{os} as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/11.1 Chrome/75.0.3770.143 Mobile Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 11; SAMSUNG SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/11.1 Chrome/75.0.3770.143 Mobile Safari/537.36") } + + it_behaves_like 'SamsungBrowser', '11.1', 'Android', 'Android 11' +end + +describe "UserAgent: Dalvik/2.1.0 (Linux; U; Android 10; SM-N975U Build/QP1A.190711.020) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36" do + let(:useragent) { UserAgent.parse("Dalvik/2.1.0 (Linux; U; Android 10; SM-N975U Build/QP1A.190711.020) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36") } + + it_behaves_like 'SamsungBrowser', '4.0', 'Android', 'Android 10' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 10; 9032Z) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/13.2 Chrome/83.0.4103.106 Mobile Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 10; 9032Z) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/13.2 Chrome/83.0.4103.106 Mobile Safari/537.36") } + + it_behaves_like 'SamsungBrowser', '13.2', 'Android', 'Android 10' +end + +describe "UserAgent: Firefox/5.0 (Linux; Android 5.0.1; SAMSUNG GT-I9505 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.1 Chrome/34.0.1847.76 Mobile Safari/537.36" do + let(:useragent) { UserAgent.parse("Firefox/5.0 (Linux; Android 5.0.1; SAMSUNG GT-I9505 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.1 Chrome/34.0.1847.76 Mobile Safari/537.36") } + + it_behaves_like 'SamsungBrowser', '2.1', 'Android', 'Android 5.0.1' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 10.0; SAMSUNG SM-G960U Build/QP1A.190711.020) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/5.2 Chrome/51.0.2704.106 Mobile VR Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 10.0; SAMSUNG SM-G960U Build/QP1A.190711.020) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/5.2 Chrome/51.0.2704.106 Mobile VR Safari/537.36") } + + it_behaves_like 'SamsungBrowser', '5.2', 'Android', 'Android 10.0' +end + +describe "UserAgent: Mozilla/5.0 (Linux; Android 4.4.4; SAMSUNG SM-G318H/G318HJVS0AQC2 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.0 Chrome/34.0.1847.76 Mobile Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Linux; Android 4.4.4; SAMSUNG SM-G318H/G318HJVS0AQC2 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.0 Chrome/34.0.1847.76 Mobile Safari/537.36") } + + it_behaves_like 'SamsungBrowser', '2.0', 'Android', 'Android 4.4.4' +end diff --git a/spec/browsers/sonos_user_agent_spec.rb b/spec/browsers/sonos_user_agent_spec.rb new file mode 100644 index 0000000..990f0f6 --- /dev/null +++ b/spec/browsers/sonos_user_agent_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Sonos' do |version| + it "returns 'Sonos' as its browser" do + expect(useragent.browser).to eq('Sonos') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns 'Sonos' as its platform" do + expect(useragent.platform).to eq('Sonos') + end + + it { expect(useragent.os).to be_nil } + it { expect(useragent).to be_speaker } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Linux UPnP/1.0 Sonos/44.2-53100-mainline_integ (ZPS120)" do + let!(:useragent) { UserAgent.parse("Linux UPnP/1.0 Sonos/44.2-53100-mainline_integ (ZP120)") } + + it_behaves_like 'Sonos', '44.2-53100-mainline_integ' +end + +describe "UserAgent: Linux UPnP/1.0 Sonos/44.2-54250 (ZP90)" do + let!(:useragent) { UserAgent.parse("Linux UPnP/1.0 Sonos/44.2-54250 (ZP90)") } + + it_behaves_like 'Sonos', '44.2-54250' +end + +describe "UserAgent: Linux UPnP/1.0 Sonos/48.2-57300-mcs9_dev_integ (ZPS11)" do + let!(:useragent) { UserAgent.parse("Linux UPnP/1.0 Sonos/48.2-57300-mcs9_dev_integ (ZPS11)") } + + it_behaves_like 'Sonos', '48.2-57300-mcs9_dev_integ' +end + +describe "UserAgent: Linux UPnP/1.0 Sonos/65.1-15280-mainline_integ_alt_release (ZPS16)" do + let!(:useragent) { UserAgent.parse("Linux UPnP/1.0 Sonos/65.1-15280-mainline_integ_alt_release (ZPS16)") } + + it_behaves_like 'Sonos', '65.1-15280-mainline_integ_alt_release' +end diff --git a/spec/browsers/sound_on_user_agent_spec.rb b/spec/browsers/sound_on_user_agent_spec.rb new file mode 100644 index 0000000..d0fe0e0 --- /dev/null +++ b/spec/browsers/sound_on_user_agent_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'SoundOn' do |version, platform, os| + it "returns 'SoundOn' as its browser" do + expect(useragent.browser).to eq('SoundOn') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: SoundOn/3.7.1 (Linux;Android)" do + let(:useragent) { UserAgent.parse("SoundOn/3.7.1 (Linux;Android)") } + + it_should_behave_like 'SoundOn', '3.7.1', 'Android', 'Android' +end + +describe "UserAgent: SoundOn/1.9.11 (Linux;Android 10) ExoPlayerLib/2.9.4" do + let(:useragent) { UserAgent.parse("SoundOn/1.9.11 (Linux;Android 10) ExoPlayerLib/2.9.4") } + + it_should_behave_like 'SoundOn', '1.9.11', 'Android', 'Android 10' +end + +describe "UserAgent: SoundOn/1.0 (com.amphiware.sound; build:1; iOS 12.3.1) Alamofire/4.8.2" do + let(:useragent) { UserAgent.parse("SoundOn/1.0 (com.amphiware.sound; build:1; iOS 12.3.1) Alamofire/4.8.2") } + + it_should_behave_like 'SoundOn', '1.0', 'iOS', 'iOS 12.3.1' +end + +describe "UserAgent: SoundOn/1.7.0 (com.soundon; build:3; iOS 12.4.2) Alamofire/4.8.2" do + let(:useragent) { UserAgent.parse("SoundOn/1.7.0 (com.soundon; build:3; iOS 12.4.2) Alamofire/4.8.2") } + + it_should_behave_like 'SoundOn', '1.7.0', 'iOS', 'iOS 12.4.2' +end + +describe "UserAgent: SoundOn/2.4.1 (iOS)" do + let(:useragent) { UserAgent.parse("SoundOn/2.4.1 (iOS)") } + + it_should_behave_like 'SoundOn', '2.4.1', 'iOS', 'iOS' +end + +describe "UserAgent: SoundOn/1 CFNetwork/1128.0.1 Darwin/19.6.0" do + let(:useragent) { UserAgent.parse("SoundOn/1 CFNetwork/1128.0.1 Darwin/19.6.0") } + + it_should_behave_like 'SoundOn', '1', 'iOS', 'iOS 13.6.x' +end + +describe "UserAgent: SoundOn/1.8.2" do + let(:useragent) { UserAgent.parse("SoundOn/1.8.2") } + + it_should_behave_like 'SoundOn', '1.8.2', nil, nil +end diff --git a/spec/browsers/spotify_user_agent_spec.rb b/spec/browsers/spotify_user_agent_spec.rb new file mode 100644 index 0000000..372910c --- /dev/null +++ b/spec/browsers/spotify_user_agent_spec.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Spotify' do |version, platform, os, type| + it "returns 'Spotify' as its browser" do + expect(useragent.browser).to eq('Spotify') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + elsif type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Spotify/0.1.118.48 Android/29 (Pixel 4 XL)" do + let!(:useragent) { UserAgent.parse("Spotify/0.1.118.48 Android/29 (Pixel 4 XL)") } + + it_behaves_like 'Spotify', '0.1.118.48', 'Android', 'Android 10', :mobile +end + +describe "UserAgent: Spotify/1.10.0 iOS/12.3.1 (Stations iPhone11,2)" do + let!(:useragent) { UserAgent.parse("Spotify/1.10.0 iOS/12.3.1 (Stations iPhone11,2)") } + + it_behaves_like 'Spotify', '1.10.0', 'iPhone', 'iOS 12.3.1', :mobile +end + +describe "UserAgent: Spotify/8.4.62 iOS/12.5.1 (iPod7,1)" do + let!(:useragent) { UserAgent.parse("Spotify/8.4.62 iOS/12.5.1 (iPod7,1)") } + + it_behaves_like 'Spotify', '8.4.62', 'iPod touch', 'iOS 12.5.1', :mobile +end + +describe "UserAgent: Spotify/8.4.75 iOS/14.3 (iPad7,11)" do + let!(:useragent) { UserAgent.parse("Spotify/8.4.75 iOS/14.3 (iPad7,11)") } + + it_behaves_like 'Spotify', '8.4.75', 'iPad', 'iOS 14.3', :mobile +end + +describe "UserAgent: Spotify/107700336 OSX/0 (MacBookAir7,2)" do + let!(:useragent) { UserAgent.parse("Spotify/107700336 OSX/0 (MacBookAir7,2)") } + + it_behaves_like 'Spotify', '107700336', 'Macintosh', nil, :desktop +end + +describe "UserAgent: Spotify/107700338 Linux/0 (PC desktop)" do + let!(:useragent) { UserAgent.parse("Spotify/107700338 Linux/0 (PC desktop)") } + + it_behaves_like 'Spotify', '107700338', 'Linux', nil, :desktop +end + +describe "UserAgent: Spotify/107700338 Win32/0 (PC laptop)" do + let!(:useragent) { UserAgent.parse("Spotify/107700338 Win32/0 (PC laptop)") } + + it_behaves_like 'Spotify', '107700338', 'Windows', nil, :desktop +end + +describe "UserAgent: Spotify-Lite/0.13.30.53 Android/28 (SM-A750GN)" do + let!(:useragent) { UserAgent.parse("Spotify-Lite/0.13.30.53 Android/28 (SM-A750GN)") } + + it_behaves_like 'Spotify', '0.13.30.53', 'Android', 'Android 9', :mobile +end + +describe "UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Spotify/1.1.45.621 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Spotify/1.1.45.621 Safari/537.36") } + + it_behaves_like 'Spotify', '1.1.45.621', 'Macintosh', 'OS X 10.11.0', :desktop +end + +describe "UserAgent: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Spotify/1.1.31.703 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Spotify/1.1.31.703 Safari/537.36") } + + it_behaves_like 'Spotify', '1.1.31.703', 'Windows', 'Windows 10', :desktop +end + +describe "UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Spotify/1.1.10.546 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Spotify/1.1.10.546 Safari/537.36") } + + it_behaves_like 'Spotify', '1.1.10.546', 'X11', 'Linux x86_64', :desktop +end + +describe "UserAgent: Spotify/114700684 Win32/Windows 10 (10.0.19042; x64)" do + let!(:useragent) { UserAgent.parse("Spotify/114700684 Win32/Windows 10 (10.0.19042; x64)") } + + it_behaves_like 'Spotify', '114700684', 'Windows', 'x64', :desktop +end + +describe "UserAgent: Spotify/1.0" do + let!(:useragent) { UserAgent.parse("Spotify/1.0") } + + it_behaves_like 'Spotify', '1.0', nil, nil, nil +end diff --git a/spec/browsers/spreaker_user_agent_spec.rb b/spec/browsers/spreaker_user_agent_spec.rb new file mode 100644 index 0000000..b15ea5c --- /dev/null +++ b/spec/browsers/spreaker_user_agent_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Spreaker' do |version, platform, os| + it "returns 'Spreaker' as its browser" do + expect(useragent.browser).to eq('Spreaker') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Spreaker for Android 4.17.0 release:2021-05-05 device:phone (samsung SM-G965U; Android 10; en_US)" do + let(:useragent) { UserAgent.parse("Spreaker for Android 4.17.0 release:2021-05-05 device:phone (samsung SM-G965U; Android 10; en_US)") } + + it_behaves_like 'Spreaker', '4.17.0', 'Android', 'Android 10' +end + +describe "UserAgent: Spreaker Android" do + let(:useragent) { UserAgent.parse("Spreaker Android") } + + it_behaves_like 'Spreaker', nil, 'Android', 'Android' +end + +describe "UserAgent: Spreaker 7.26.1 rv:1337 (iPhone10,3; iOS 14.4.2; en_US)" do + let(:useragent) { UserAgent.parse("Spreaker 7.26.1 rv:1337 (iPhone10,3; iOS 14.4.2; en_US)") } + + it_behaves_like 'Spreaker', '7.26.1', 'iPhone', 'iOS 14.4.2' +end + +describe "UserAgent: Spreaker 6.8.0 rv:1168 (iPad2,4; iPhone OS 9.3.5; en_GB) SPKAudioPlayer" do + let(:useragent) { UserAgent.parse("Spreaker 6.8.0 rv:1168 (iPad2,4; iPhone OS 9.3.5; en_GB) SPKAudioPlayer") } + + it_behaves_like 'Spreaker', '6.8.0', 'iPad', 'iOS 9.3.5' +end + +describe "UserAgent: Spreaker 7.9.1 rv:1263 (iPod7,1; iOS 11.0.3; en_US) SPKAudioPlayer" do + let(:useragent) { UserAgent.parse("Spreaker 7.9.1 rv:1263 (iPod7,1; iOS 11.0.3; en_US) SPKAudioPlayer") } + + it_behaves_like 'Spreaker', '7.9.1', 'iPod touch', 'iOS 11.0.3' +end + +describe "UserAgent: Spreaker 7.9.1 rv:1263 (iPod7,1) SPKAudioPlayer" do + let(:useragent) { UserAgent.parse("Spreaker 7.9.1 rv:1263 (iPod7,1) SPKAudioPlayer") } + + it_behaves_like 'Spreaker', '7.9.1', 'iPod touch', 'iOS' +end + +describe "UserAgent: Spreaker File Downloader" do + let(:useragent) { UserAgent.parse("Spreaker File Downloader") } + + it_behaves_like 'Spreaker', nil, nil, nil +end diff --git a/spec/browsers/stagefright_user_agent_spec.rb b/spec/browsers/stagefright_user_agent_spec.rb new file mode 100644 index 0000000..f61ab28 --- /dev/null +++ b/spec/browsers/stagefright_user_agent_spec.rb @@ -0,0 +1,235 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Android platform' do + it "returns 'Android' as its platform" do + expect(useragent.platform).to eq('Android') + end + + it { expect(useragent).not_to be_web_browser } +end + +shared_examples 'Stagefright' do + it "returns 'Stagefright' as its browser" do + expect(useragent.browser).to eq('Stagefright') + end + + it_behaves_like 'Android platform' +end + +shared_examples 'Stagefright/Beyonce' do + it "returns 'Stagefright/Beyonce' as its browser" do + expect(useragent.browser).to eq('Stagefright/Beyonce') + end + + it_behaves_like 'Android platform' +end + +shared_examples 'NexPlayer' do + it "returns 'NexPlayer' as its browser" do + expect(useragent.browser).to eq('NexPlayer') + end + + it_behaves_like 'Android platform' +end + +shared_examples 'LG Player' do + it "returns 'LG Player' as its browser" do + expect(useragent.browser).to eq('LG Player') + end + + it_behaves_like 'Android platform' +end + +describe "UserAgent: stagefright/1.2 (Linux;Android 5.0.1)" do + let!(:useragent) { UserAgent.parse("stagefright/1.2 (Linux;Android 5.0.1)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 5.0.1' as its operating system" do + expect(useragent.os).to eq('Android 5.0.1') + end +end + +describe "UserAgent: SonyD5803 Build/23.0.1.A.5.77 stagefright/1.2 (Linux;Android 4.4.4)" do + let!(:useragent) { UserAgent.parse("SonyD5803 Build/23.0.1.A.5.77 stagefright/1.2 (Linux;Android 4.4.4)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 4.4.4' as its operating system" do + expect(useragent.os).to eq('Android 4.4.4') + end +end + +describe "UserAgent: Samsung SAMSUNG-SGH-I747 stagefright/1.2 (Linux;Android 4.4.2)" do + let!(:useragent) { UserAgent.parse("Samsung SAMSUNG-SGH-I747 stagefright/1.2 (Linux;Android 4.4.2)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 4.4.2' as its operating system" do + expect(useragent.os).to eq('Android 4.4.2') + end +end + +describe "UserAgent: Samsung SM-G900T stagefright/Beyonce/1.1.9 (Linux;Android 5.1.1)" do + let!(:useragent) { UserAgent.parse("Samsung SM-G900T stagefright/Beyonce/1.1.9 (Linux;Android 5.1.1)") } + + it_behaves_like 'Stagefright/Beyonce' + + it "returns '1.1.9' as its version" do + expect(useragent.version).to eq('1.1.9') + end + + it "returns 'Android 5.1.1' as its operating system" do + expect(useragent.os).to eq('Android 5.1.1') + end +end + +describe "UserAgent: AlcatelOneTouch-Alcatel_5044R-SVN/02; stagefright/1.2 (Linux;Android 7.0)" do + let!(:useragent) { UserAgent.parse("AlcatelOneTouch-Alcatel_5044R-SVN/02; stagefright/1.2 (Linux;Android 7.0)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 7.0' as its operating system" do + expect(useragent.os).to eq('Android 7.0') + end +end + +describe "UserAgent: BLADE L111-stagefright/1.2 (Linux;Android 5.1)" do + let!(:useragent) { UserAgent.parse("BLADE L111-stagefright/1.2 (Linux;Android 5.1)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 5.1' as its operating system" do + expect(useragent.os).to eq('Android 5.1') + end +end + +describe "UserAgent: Fire OS/5.1.1 stagefright/1.2 (Linux;Android 5.1.1) ,Dalvik/2.1.0 (Linux; U; Android 5.1.1; KFFOWI Build/LMY47O)" do + let!(:useragent) { UserAgent.parse("Fire OS/5.1.1 stagefright/1.2 (Linux;Android 5.1.1) ,Dalvik/2.1.0 (Linux; U; Android 5.1.1; KFFOWI Build/LMY47O)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 5.1.1' as its operating system" do + expect(useragent.os).to eq('Android 5.1.1') + end +end + +describe "UserAgent: Fire OS/6.0 stagefright/1.2 (Linux;Android 7.1.2)" do + let!(:useragent) { UserAgent.parse("Fire OS/6.0 stagefright/1.2 (Linux;Android 7.1.2)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 7.1.2' as its operating system" do + expect(useragent.os).to eq('Android 7.1.2') + end +end + +describe "UserAgent: stagefright/1.2 (Linux;Android 5.0 Huawei HUAWEI GRA-L09 GRA-L09V100R001C150B134)" do + let!(:useragent) { UserAgent.parse("stagefright/1.2 (Linux;Android 5.0 Huawei HUAWEI GRA-L09 GRA-L09V100R001C150B134)") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 5.0' as its operating system" do + expect(useragent.os).to eq('Android 5.0') + end +end + +describe "UserAgent: stagefright/1.2 (Linux;Android 4.0.3) Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10" do + let!(:useragent) { UserAgent.parse("stagefright/1.2 (Linux;Android 4.0.3) Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10") } + + it_behaves_like 'Stagefright' + + it "returns '1.2' as its version" do + expect(useragent.version).to eq('1.2') + end + + it "returns 'Android 4.0.3' as its operating system" do + expect(useragent.os).to eq('Android 4.0.3') + end +end + +describe "UserAgent: LG-E615f/LG-E615f-V10p-SEP-02-2013 Player/NexPlayer 4.0 for Android (stagefright alternative) ,Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36" do + let!(:useragent) { UserAgent.parse("LG-E615f/LG-E615f-V10p-SEP-02-2013 Player/NexPlayer 4.0 for Android (stagefright alternative) ,Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36") } + + it_behaves_like 'NexPlayer' + + it "returns '4.0' as its version" do + expect(useragent.version).to eq('4.0') + end +end + +describe "UserAgent: LG-D802/Desperate Rom LP UX4 V4 Player/LG Player 1.0 for Android 5.0.2 (stagefright alternative)" do + let!(:useragent) { UserAgent.parse("LG-D802/Desperate Rom LP UX4 V4 Player/LG Player 1.0 for Android 5.0.2 (stagefright alternative)") } + + it_behaves_like 'LG Player' + + it "returns '1.0' as its version" do + expect(useragent.version).to eq('1.0') + end + + it "returns 'Android 5.0.2' as its operating system" do + expect(useragent.os).to eq('Android 5.0.2') + end +end + +describe "UserAgent: LG-H873/V15c Player/LG Player 1.0 for Android 7.0 (stagefright alternative)" do + let!(:useragent) { UserAgent.parse("LG-H873/V15c Player/LG Player 1.0 for Android 7.0 (stagefright alternative)") } + + it_behaves_like 'LG Player' + + it "returns '1.0' as its version" do + expect(useragent.version).to eq('1.0') + end + + it "returns 'Android 7.0' as its operating system" do + expect(useragent.os).to eq('Android 7.0') + end +end + +describe "UserAgent: LG-H955/V15c Player/LG Player 1.0 for Android 5.1.1 (stagefright alternative) BMID/E67AB269FB" do + let!(:useragent) { UserAgent.parse("LG-H955/V15c Player/LG Player 1.0 for Android 5.1.1 (stagefright alternative) BMID/E67AB269FB") } + + it_behaves_like 'LG Player' + + it "returns '1.0' as its version" do + expect(useragent.version).to eq('1.0') + end + + it "returns 'Android 5.1.1' as its operating system" do + expect(useragent.os).to eq('Android 5.1.1') + end +end diff --git a/spec/browsers/stitcher_bot_user_agent_spec.rb b/spec/browsers/stitcher_bot_user_agent_spec.rb new file mode 100644 index 0000000..a06e978 --- /dev/null +++ b/spec/browsers/stitcher_bot_user_agent_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples_for 'Stitcherbot' do + it "returns 'Stitcher' as its browser" do + expect(useragent.browser).to eq('Stitcher') + end + + it { expect(useragent.platform).to be nil } + it { expect(useragent.os).to be nil } + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: stitcherbot (http://www.stitcher.com)" do + let!(:useragent) { UserAgent.parse("stitcherbot (http://www.stitcher.com)") } + + it_should_behave_like 'Stitcherbot' +end + +describe "UserAgent: StitcherBot (MP3 Search Bot for Stitcher Personalized Radio Service)" do + let!(:useragent) { UserAgent.parse("StitcherBot (MP3 Search Bot for Stitcher Personalized Radio Service)") } + + it_should_behave_like 'Stitcherbot' +end diff --git a/spec/browsers/stitcher_user_agent_spec.rb b/spec/browsers/stitcher_user_agent_spec.rb new file mode 100644 index 0000000..5b5dc3e --- /dev/null +++ b/spec/browsers/stitcher_user_agent_spec.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Stitcher' do |version, platform, os, type| + it "returns 'Stitcher' as its browser" do + expect(useragent.browser).to eq('Stitcher') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + elsif type == :desktop + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: Stitcher/iOS BMID/E675DDB007" do + let!(:useragent) { UserAgent.parse("Stitcher/iOS BMID/E675DDB007") } + + it_behaves_like 'Stitcher', nil, 'iOS', nil, :mobile +end + +describe "UserAgent: Stitcher/Android BMID/E675CE27E9" do + let!(:useragent) { UserAgent.parse("Stitcher/Android BMID/E675CE27E9") } + + it_behaves_like 'Stitcher', nil, 'Android', nil, :mobile +end + +describe "UserAgent: Stitcher/17434 CFNetwork/609.1.4 Darwin/13.0.0" do + let!(:useragent) { UserAgent.parse("Stitcher/17434 CFNetwork/609.1.4 Darwin/13.0.0") } + + it_behaves_like 'Stitcher', '17434', 'iOS', 'iOS 6.0.x', :mobile +end + +describe "UserAgent: StitcherX/109 CFNetwork/1128.0.1 Darwin/19.6.0" do + let!(:useragent) { UserAgent.parse("StitcherX/109 CFNetwork/1128.0.1 Darwin/19.6.0") } + + it_behaves_like 'Stitcher', '109', 'iOS', 'iOS 13.6.x', :mobile +end + +describe "UserAgent: stitcherx/52 CFNetwork/1121.2.1 Darwin/19.3.0" do + let!(:useragent) { UserAgent.parse("stitcherx/52 CFNetwork/1121.2.1 Darwin/19.3.0") } + + it_behaves_like 'Stitcher', '52', 'iOS', 'iOS 13.3.1', :mobile +end + +describe "UserAgent: Stitcher Demo/4.8.0 (Linux;Android 11) ExoPlayerLib/2.10.7" do + let!(:useragent) { UserAgent.parse("Stitcher Demo/4.8.0 (Linux;Android 11) ExoPlayerLib/2.10.7") } + + it_behaves_like 'Stitcher', '4.8.0', 'Android', 'Android 11', :mobile +end + +describe "UserAgent: Stitcher X/1.2 (Linux;Android 9) ExoPlayerLib/2.10.7" do + let!(:useragent) { UserAgent.parse("Stitcher X/1.2 (Linux;Android 9) ExoPlayerLib/2.10.7") } + + it_behaves_like 'Stitcher', '1.2', 'Android', 'Android 9', :mobile +end + +describe "UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) StitcherRadio/1.1.5 Chrome/58.0.3029.110 Molecule/1.1.5 Safari/537.36" do + let!(:useragent) { UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) StitcherRadio/1.1.5 Chrome/58.0.3029.110 Molecule/1.1.5 Safari/537.36") } + + it_behaves_like 'Stitcher', '1.1.5', 'Macintosh', 'OS X 10.13.4', :desktop +end + +describe "UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 10.0; Trident/4.0) Stitcher/iOS" do + let!(:useragent) { UserAgent.parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 10.0; Trident/4.0) Stitcher/iOS") } + + it_behaves_like 'Stitcher', nil, 'iOS', nil, :mobile +end + +describe "UserAgent: Stitcher/iOS,Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; InfoPath.2)" do + let!(:useragent) { UserAgent.parse("Stitcher/iOS,Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; InfoPath.2)") } + + it_behaves_like 'Stitcher', nil, 'iOS', nil, :mobile +end + +describe "UserAgent: StitcherTV/1 CFNetwork/1121.1.2 Darwin/19.2.0 (x86_64)" do + let!(:useragent) { UserAgent.parse("StitcherTV/1 CFNetwork/1121.1.2 Darwin/19.2.0 (x86_64)") } + + it_behaves_like 'Stitcher', '1', 'Macintosh', 'macOS 10.15.2', :desktop +end diff --git a/spec/browsers/the_podcast_app_user_agent_spec.rb b/spec/browsers/the_podcast_app_user_agent_spec.rb new file mode 100644 index 0000000..0faca9c --- /dev/null +++ b/spec/browsers/the_podcast_app_user_agent_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'ThePodcastApp' do |version, platform, os| + it "returns 'ThePodcastApp' as its browser" do + expect(useragent.browser).to eq('ThePodcastApp') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: ThePodcastApp/5.6.1 (iPhone; iOS 14.6; ) player (build 4958; +https://podcast.app/)" do + let(:useragent) { UserAgent.parse("ThePodcastApp/5.6.1 (iPhone; iOS 14.6; ) player (build 4958; +https://podcast.app/)") } + + it_behaves_like 'ThePodcastApp', '5.6.1', 'iPhone', 'iOS 14.6' +end + +describe "UserAgent: ThePodcastApp/3.44.1 (iPad; iOS 13.2.2; ) stream (build 4007; +https://podcast.app/)" do + let(:useragent) { UserAgent.parse("ThePodcastApp/3.44.1 (iPad; iOS 13.2.2; ) stream (build 4007; +https://podcast.app/)") } + + it_behaves_like 'ThePodcastApp', '3.44.1', 'iPad', 'iOS 13.2.2' +end + +describe "UserAgent: ThePodcastApp/3.45.0 (iPod touch; iOS 13.3.1; ) listenLater (build 4102; +https://podcast.app/)" do + let(:useragent) { UserAgent.parse("ThePodcastApp/3.45.0 (iPod touch; iOS 13.3.1; ) listenLater (build 4102; +https://podcast.app/)") } + + it_behaves_like 'ThePodcastApp', '3.45.0', 'iPod touch', 'iOS 13.3.1' +end diff --git a/spec/browsers/tune_in_user_agent_spec.rb b/spec/browsers/tune_in_user_agent_spec.rb new file mode 100644 index 0000000..60ab78b --- /dev/null +++ b/spec/browsers/tune_in_user_agent_spec.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'TuneIn' do |version, platform, os, type| + it "returns 'TuneIn' as its browser" do + expect(useragent.browser).to eq('TuneIn') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + if type == :mobile + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + else + it { expect(useragent).to be_desktop } + it { expect(useragent).not_to be_mobile } + end + + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +describe "UserAgent: TuneIn Radio/26.8.1 (Linux;Android 8.0.0) ExoPlayerLib/2.12.2" do + let(:useragent) { UserAgent.parse("TuneIn Radio/26.8.1 (Linux;Android 8.0.0) ExoPlayerLib/2.12.2") } + + it_behaves_like 'TuneIn', '26.8.1', 'Android', 'Android 8.0.0', :mobile +end + +describe "UserAgent: TuneIn Radio Pro/26.2.1 (Linux;Android 9) ExoPlayerLib/2.12.2" do + let(:useragent) { UserAgent.parse("TuneIn Radio Pro/26.2.1 (Linux;Android 9) ExoPlayerLib/2.12.2") } + + it_behaves_like 'TuneIn', '26.2.1', 'Android', 'Android 9', :mobile +end + +describe "UserAgent: TuneIn Radio Pro/17.8.1 (Android 24; SM-T813; Java)" do + let(:useragent) { UserAgent.parse("TuneIn Radio Pro/17.8.1 (Android 24; SM-T813; Java)") } + + it_behaves_like 'TuneIn', '17.8.1', 'Android', 'Android 7.0', :mobile +end + +describe "UserAgent: TuneIn Radio/20.4.0; iPhone13,1; iOS/14.4.2" do + let(:useragent) { UserAgent.parse("TuneIn Radio/20.4.0; iPhone13,1; iOS/14.4.2") } + + it_behaves_like 'TuneIn', '20.4.0', 'iPhone', 'iOS 14.4.2', :mobile +end + +describe "UserAgent: TuneIn Radio Pro/20.5.0; iPhone13,1; iOS/14.6" do + let(:useragent) { UserAgent.parse("TuneIn Radio Pro/20.5.0; iPhone13,1; iOS/14.6") } + + it_behaves_like 'TuneIn', '20.5.0', 'iPhone', 'iOS 14.6', :mobile +end + +describe "UserAgent: TuneIn Radio Pro/20.4.0; iPad8,7; iOS/14.4.2" do + let(:useragent) { UserAgent.parse("TuneIn Radio Pro/20.4.0; iPad8,7; iOS/14.4.2") } + + it_behaves_like 'TuneIn', '20.4.0', 'iPad', 'iOS 14.4.2', :mobile +end + +describe "UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) TuneIn/1.6.0 Chrome/69.0.3497.128 Electron/4.1.4 Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) TuneIn/1.6.0 Chrome/69.0.3497.128 Electron/4.1.4 Safari/537.36") } + + it_behaves_like 'TuneIn', '1.6.0', 'Macintosh', 'OS X 10.10.3', :desktop +end + +describe "UserAgent: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) TuneIn/1.16.0 Chrome/69.0.3497.128 Electron/4.2.8 Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) TuneIn/1.16.0 Chrome/69.0.3497.128 Electron/4.2.8 Safari/537.36") } + + it_behaves_like 'TuneIn', '1.16.0', 'Windows', 'Windows 10', :desktop +end + +describe "UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) tunein/1.0.0 Chrome/69.0.3497.128 Electron/4.1.3 Safari/537.36" do + let(:useragent) { UserAgent.parse("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) tunein/1.0.0 Chrome/69.0.3497.128 Electron/4.1.3 Safari/537.36") } + + it_behaves_like 'TuneIn', '1.0.0', 'X11', 'Linux x86_64', :desktop +end + +describe "UserAgent: TuneIn%20Radio%20Enterprise/1 CFNetwork/808.2.16 Darwin/16.3.0" do + let(:useragent) { UserAgent.parse("TuneIn%20Radio%20Enterprise/1 CFNetwork/808.2.16 Darwin/16.3.0") } + + it_behaves_like 'TuneIn', '1', 'iOS', 'iOS 10.2.x', :mobile +end + +describe "UserAgent: TuneIn%20Radio%20Pro/055708c CFNetwork/894 Darwin/17.4.0" do + let(:useragent) { UserAgent.parse("TuneIn%20Radio%20Pro/055708c CFNetwork/894 Darwin/17.4.0") } + + it_behaves_like 'TuneIn', '055708c', 'iOS', 'iOS 11.2.5', :mobile +end + +describe "UserAgent: TuneIn%20Radio%20Pro/11.4; iPhone11,8; iOS/13.3.1" do + let(:useragent) { UserAgent.parse("TuneIn%20Radio%20Pro/11.4; iPhone11,8; iOS/13.3.1") } + + it_behaves_like 'TuneIn', '11.4', 'iPhone', 'iOS 13.3.1', :mobile +end + +describe "UserAgent: TuneIn%20Radio%20Pro/12.5; iPod7,1; iOS/10.2" do + let(:useragent) { UserAgent.parse("TuneIn%20Radio%20Pro/12.5; iPod7,1; iOS/10.2") } + + it_behaves_like 'TuneIn', '12.5', 'iPod touch', 'iOS 10.2', :mobile +end + +describe "UserAgent: TuneIn%20Radio/1002 CFNetwork/887 Darwin/17.0.0" do + let(:useragent) { UserAgent.parse("TuneIn%20Radio/1002 CFNetwork/887 Darwin/17.0.0") } + + it_behaves_like 'TuneIn', '1002', 'iOS', 'iOS 11.0.x', :mobile +end + +describe "UserAgent: TuneIn%20Radio/11.4; iPad5,3; iOS/11.4" do + let(:useragent) { UserAgent.parse("TuneIn%20Radio/11.4; iPad5,3; iOS/11.4") } + + it_behaves_like 'TuneIn', '11.4', 'iPad', 'iOS 11.4', :mobile +end diff --git a/spec/browsers/vivaldi_user_agent_spec.rb b/spec/browsers/vivaldi_user_agent_spec.rb index 597d78b..f36fc22 100644 --- a/spec/browsers/vivaldi_user_agent_spec.rb +++ b/spec/browsers/vivaldi_user_agent_spec.rb @@ -4,6 +4,12 @@ it "should return 'Vivaldi' as its browser" do expect(@useragent.browser).to eq("Vivaldi") end + + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } end describe "UserAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 Vivaldi/1.2.490.43'" do diff --git a/spec/browsers/webkit_user_agent_spec.rb b/spec/browsers/webkit_user_agent_spec.rb index 9c4b13b..d43c7a2 100644 --- a/spec/browsers/webkit_user_agent_spec.rb +++ b/spec/browsers/webkit_user_agent_spec.rb @@ -10,6 +10,22 @@ end end +shared_examples 'a desktop' do + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } +end + +shared_examples 'a mobile' do + it { expect(@useragent).to be_mobile } + it { expect(@useragent).not_to be_desktop } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).to be_web_browser } +end + describe "UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16" do before do @useragent = UserAgent.parse("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16") diff --git a/spec/browsers/wechat_browser_user_agent_spec.rb b/spec/browsers/wechat_browser_user_agent_spec.rb index 4b867f1..cffcb41 100644 --- a/spec/browsers/wechat_browser_user_agent_spec.rb +++ b/spec/browsers/wechat_browser_user_agent_spec.rb @@ -20,6 +20,8 @@ it "should return 'iOS 9.3.1' as its os" do expect(@useragent.os).to eq("iOS 9.3.1") end + + it { expect(useragent).to be_web_browser } end describe "UserAgent: 'Mozilla/5.0 (Linux; Android 4.4.4; MI 4LTE Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036215 Safari/537.36 MicroMessenger/6.3.16.49_r03ae324.780 NetType/WIFI Language/zh_CN'" do diff --git a/spec/browsers/windows_media_player_user_agent_spec.rb b/spec/browsers/windows_media_player_user_agent_spec.rb index 5338153..3dc03ad 100644 --- a/spec/browsers/windows_media_player_user_agent_spec.rb +++ b/spec/browsers/windows_media_player_user_agent_spec.rb @@ -1,5 +1,21 @@ require 'user_agent' +shared_examples 'a desktop' do + it { expect(@useragent).to be_desktop } + it { expect(@useragent).not_to be_mobile } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +shared_examples 'a mobile' do + it { expect(@useragent).to be_mobile } + it { expect(@useragent).not_to be_desktop } + it { expect(@useragent).not_to be_speaker } + it { expect(@useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + shared_examples "Windows Media Player" do it "should return 'Windows Media Player' as its browser" do expect(@useragent.browser).to eq("Windows Media Player") diff --git a/spec/browsers/wondery_user_agent_spec.rb b/spec/browsers/wondery_user_agent_spec.rb new file mode 100644 index 0000000..b5b3df2 --- /dev/null +++ b/spec/browsers/wondery_user_agent_spec.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +require 'user_agent' + +shared_examples 'Wondery' do |version, platform, os| + it "returns 'Wondery' as its browser" do + expect(useragent.browser).to eq('Wondery') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it "returns '#{platform}' as its platform" do + expect(useragent.platform).to eq(platform) + end + + it "returns '#{os}' as its operating system" do + expect(useragent.os).to eq(os) + end + + it { expect(useragent).to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent).not_to be_bot } + it { expect(useragent).not_to be_web_browser } +end + +shared_examples 'Wondery Crawler' do |version| + it "returns 'Wondery Crawler' as its browser" do + expect(useragent.browser).to eq('Wondery Crawler') + end + + it "returns '#{version}' as its version" do + expect(useragent.version).to eq(version) + end + + it { expect(useragent).to be_bot } + it { expect(useragent).not_to be_mobile } + it { expect(useragent).not_to be_desktop } + it { expect(useragent).not_to be_speaker } + it { expect(useragent.os).to be_nil } + it { expect(useragent.platform).to be_nil } +end + +describe "UserAgent: wondery/android/v1.8.2/2314" do + let(:useragent) { UserAgent.parse("wondery/android/v1.8.2/2314") } + + it_behaves_like 'Wondery', '1.8.2', 'Android', nil +end + +describe "UserAgent: Wondery/1660 CFNetwork/1183 Darwin/20.0.0" do + let(:useragent) { UserAgent.parse("Wondery/1660 CFNetwork/1183 Darwin/20.0.0") } + + it_behaves_like 'Wondery', '1660', 'iOS', 'iOS 14.0.x' +end + +describe "UserAgent: wondery/ios/v1.8.2/48" do + let(:useragent) { UserAgent.parse("wondery/ios/v1.8.2/48") } + + it_behaves_like 'Wondery', '1.8.2', 'iOS', nil +end + +describe "UserAgent: wondery/ios/v1.4.2/1 ,AppleCoreMedia/1.0.0.17G64 (iPhone; U; CPU OS 13_6 like Mac OS X; en_us)" do + let(:useragent) { UserAgent.parse("wondery/ios/v1.4.2/1 ,AppleCoreMedia/1.0.0.17G64 (iPhone; U; CPU OS 13_6 like Mac OS X; en_us)") } + + it_behaves_like 'Wondery', '1.4.2', 'iPhone', 'iOS 13.6' +end + +describe 'UserAgent: wondery/develop' do + let(:useragent) { UserAgent.parse('wondery/develop') } + + it_behaves_like 'Wondery Crawler', 'develop' +end + +describe 'UserAgent: wondery/development' do + let(:useragent) { UserAgent.parse('wondery/development') } + + it_behaves_like 'Wondery Crawler', 'development' +end + +describe 'UserAgent: wondery/prod' do + let(:useragent) { UserAgent.parse('wondery/prod') } + + it_behaves_like 'Wondery Crawler', 'prod' +end + +describe 'UserAgent: wondery/production' do + let(:useragent) { UserAgent.parse('wondery/production') } + + it_behaves_like 'Wondery Crawler', 'production' +end + +describe 'UserAgent: wondery/staging' do + let(:useragent) { UserAgent.parse('wondery/staging') } + + it_behaves_like 'Wondery Crawler', 'staging' +end + +describe 'UserAgent: wondery/stage' do + let(:useragent) { UserAgent.parse('wondery/stage') } + + it_behaves_like 'Wondery Crawler', 'stage' +end + +describe 'UserAgent: wondery/not_crawler' do + let(:useragent) { UserAgent.parse('wondery/not_crawler') } + + it { expect(useragent.browser).not_to eq('Wondery Crawler') } + it { expect(useragent).not_to be_bot } +end