Sha256: d32f4c66de5de90718f057ac7295869043cfc0bb93e2000b2b6a62058025bcad

Contents?: true

Size: 711 Bytes

Versions: 9

Compression:

Stored size: 711 Bytes

Contents

# frozen_string_literal: true

require 'minitest/autorun'
require 'legitbot'

class AppleAsGoogleTest < Minitest::Test
  def test_valid_ip
    ip = '17.58.98.60'
    match = Legitbot::Apple_as_Google.new(ip)
    assert match.valid?, msg: "#{ip} is a valid Applebot IP"
  end

  def test_invalid_ip
    ip = '127.0.0.1'
    match = Legitbot::Apple_as_Google.new(ip)
    assert match.fake?, msg: "#{ip} is a fake Applebot IP"
  end

  def test_user_agent
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
      '17.58.98.60'
    )
    assert_equal :apple_as_google, bot.detected_as
    assert bot.valid?, msg: 'A valid Applebot User-agent and IP'
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
legitbot-1.1.1 test/apple_as_google_test.rb
legitbot-1.1.0 test/apple_as_google_test.rb
legitbot-1.0.2 test/apple_as_google_test.rb
legitbot-1.0.1 test/apple_as_google_test.rb
legitbot-1.0.0 test/apple_as_google_test.rb
legitbot-0.4.3 test/apple_as_google_test.rb
legitbot-0.4.2 test/apple_as_google_test.rb
legitbot-0.4.1 test/apple_as_google_test.rb
legitbot-0.4.0 test/apple_as_google_test.rb