File: bot_fixtures_spec.rb

package info (click to toggle)
ruby-device-detector 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 3,104 kB
  • sloc: ruby: 1,224; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 739 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require_relative '../spec_helper'

describe DeviceDetector::Bot do

  fixture_dir = File.expand_path('../../fixtures/parser', __FILE__)
  fixture_files = Dir["#{fixture_dir}/bots.yml"]
  fixture_files.each do |fixture_file|

    describe File.basename(fixture_file) do

      fixtures = YAML.load_file(fixture_file)

      fixtures.each do |f|
        user_agent = f["user_agent"]
        bot = DeviceDetector::Bot.new(user_agent)

        describe user_agent do
          it "should be a bot" do
            assert bot.bot?, "isn't a bot"
          end

          it "should have the expected name" do
            assert_equal f["bot"]["name"], bot.name, "failed bot name detection"
          end
        end

      end
    end
  end
end