<commit_before>require_relative "../../../spec_helper"

describe "Rack::Woothee::Result" do
  include Rack::Test::Methods

  let(:app) do
    dummy_app = ->(env) { [200, {}, "Hello World"] }
    Rack::Woothee.new(dummy_app)
  end
  let(:ua) { "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25" }
  let(:woothee_result) { ::Woothee.parse(ua) }
  let(:mappings) do
    {
      device_type:     :category,
      os:              :os,
      os_version:      :os_version,
      browser:         :name,
      browser_version: :version,
      browser_vendor:  :vendor,
    }
  end

  it "assigns woothee parse result to env['rack.woothee']" do
    header "User-Agent", ua
    get "/"

    mappings.each do |method, original|
      last_request.public_send(method).must_equal woothee_result[original]
    end
  end
end<commit_msg>Fix spec description<commit_after>require_relative "../../../spec_helper"

describe "Rack::Woothee::Result" do
  include Rack::Test::Methods

  let(:app) do
    dummy_app = ->(env) { [200, {}, "Hello World"] }
    Rack::Woothee.new(dummy_app)
  end
  let(:ua) { "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25" }
  let(:woothee_result) { ::Woothee.parse(ua) }
  let(:mappings) do
    {
      device_type:     :category,
      os:              :os,
      os_version:      :os_version,
      browser:         :name,
      browser_version: :version,
      browser_vendor:  :vendor,
    }
  end

  it "returns proper woothee results" do
    header "User-Agent", ua
    get "/"

    mappings.each do |method, original|
      last_request.public_send(method).must_equal woothee_result[original]
    end
  end
end
{'fraction_non_alphanumeric': 0.13722222222222222, 'fraction_numerical': 0.027777777777777776, 'mean_word_length': 2.815677966101695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5698470', 'n_tokens_mistral': 686, 'n_tokens_neox': 638, 'n_words': 143}