<commit_before>require 'test_helper'

class ActsAsShareableObjectTest < ActiveSupport::TestCase
  fixtures :cars

  test "truth" do
    assert_kind_of Module, ActsAsShareableObject
  end

  test "twitter summary card type" do
    car = cars(:pagani)

    car.stubs(:twitter_card).returns("summary")

    assert_equal car.social_meta_properties[:twitter][:card], "summary"
  end

  test "twitter summary card image" do
    car = cars(:pagani)

    car.stubs(:twitter_image).returns(car.image)

    assert_equal car.social_meta_properties[:twitter][:image], car.image
  end

  test "twitter card site" do
    car = cars(:pagani)

    car.stubs(:twitter_site).returns(car.company_twitter_handle)

    assert_equal car.social_meta_properties[:twitter][:site], car.company_twitter_handle
  end

  test "twitter photo card image src" do
    car = cars(:pagani)

    car.stubs(:twitter_image_src).returns(car.image)

    assert_equal car.social_meta_properties[:twitter][:image][:src], car.image

  end

  test "twitter photo card image details" do
    car = cars(:pagani)

    car.stubs(:twitter_image_src).returns(car.image)
    car.stubs(:twitter_image_width).returns("812")
    car.stubs(:twitter_image_height).returns("475")

    assert_equal car.social_meta_properties[:twitter][:image][:src], car.image
    assert_equal car.social_meta_properties[:twitter][:image][:width], car.twitter_image_width
    assert_equal car.social_meta_properties[:twitter][:image][:height], car.twitter_image_height
  end

  test "single custom tag" do
    car = cars(:pagani)

    class << car
      acts_as_shareable_object :og_test
    end

    car.stubs(:og_test).returns("test tag, YO")

    assert_equal car.social_meta_properties[:og_test], car.og_test
  end

  test "single nested custom tag" do
    car = cars(:pagani)

    class << car
      acts_as_shareable_object og: :nested
    end

    car.stubs(:og_nested).returns("this is nested")

    assert_equal car.social_meta_properties[:og][:nested], car.og_nested
  end

  test "multiple custom shareable tags" do
    car = cars(:pagani)

    class << car
      acts_as_shareable_object og: [:custom_property, nested: [:egg]]
    end

    car.stubs(:og_custom_property).returns("og custom property")
    car.stubs(:og_nested_egg).returns("nested egg")

    assert_equal car.social_meta_properties[:og][:custom_property], car.og_custom_property
    assert_equal car.social_meta_properties[:og][:nested][:egg], car.og_nested_egg
  end

end<commit_msg>nested property test using an array<commit_after>require 'test_helper'

class ActsAsShareableObjectTest < ActiveSupport::TestCase
  fixtures :cars

  test "truth" do
    assert_kind_of Module, ActsAsShareableObject
  end

  test "twitter summary card type" do
    car = cars(:pagani)

    car.stubs(:twitter_card).returns("summary")

    assert_equal car.social_meta_properties[:twitter][:card], "summary"
  end

  test "twitter summary card image" do
    car = cars(:pagani)

    car.stubs(:twitter_image).returns(car.image)

    assert_equal car.social_meta_properties[:twitter][:image], car.image
  end

  test "twitter card site" do
    car = cars(:pagani)

    car.stubs(:twitter_site).returns(car.company_twitter_handle)

    assert_equal car.social_meta_properties[:twitter][:site], car.company_twitter_handle
  end

  test "twitter photo card image src" do
    car = cars(:pagani)

    car.stubs(:twitter_image_src).returns(car.image)

    assert_equal car.social_meta_properties[:twitter][:image][:src], car.image

  end

  test "twitter photo card image details" do
    car = cars(:pagani)

    car.stubs(:twitter_image_src).returns(car.image)
    car.stubs(:twitter_image_width).returns("812")
    car.stubs(:twitter_image_height).returns("475")

    assert_equal car.social_meta_properties[:twitter][:image][:src], car.image
    assert_equal car.social_meta_properties[:twitter][:image][:width], car.twitter_image_width
    assert_equal car.social_meta_properties[:twitter][:image][:height], car.twitter_image_height
  end

  test "single custom tag" do
    car = cars(:pagani)

    class << car
      acts_as_shareable_object :og_test
    end

    car.stubs(:og_test).returns("test tag, YO")

    assert_equal car.social_meta_properties[:og_test], car.og_test
  end

  test "single nested custom tag" do
    car = cars(:pagani)

    class << car
      acts_as_shareable_object og: :nested
    end

    car.stubs(:og_nested).returns("this is nested")

    assert_equal car.social_meta_properties[:og][:nested], car.og_nested
  end

  test "single nested array custom tag" do
    car = cars(:pagani)

    class << car
      acts_as_shareable_object og: [:nested]
    end

    car.stubs(:og_nested).returns("this is nested")

    assert_equal car.social_meta_properties[:og][:nested], car.og_nested
  end

  test "multiple custom shareable tags" do
    car = cars(:pagani)

    class << car
      acts_as_shareable_object og: [:custom_property, nested: [:egg]]
    end

    car.stubs(:og_custom_property).returns("og custom property")
    car.stubs(:og_nested_egg).returns("nested egg")

    assert_equal car.social_meta_properties[:og][:custom_property], car.og_custom_property
    assert_equal car.social_meta_properties[:og][:nested][:egg], car.og_nested_egg
  end

end
{'fraction_non_alphanumeric': 0.11423149905123339, 'fraction_numerical': 0.0022770398481973433, 'mean_word_length': 4.445247933884297, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 3, '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': '5201084', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1658, 'n_words': 340}