<commit_before># encoding: utf-8

require 'test/helper'

class Nanoc3::SiteTest < MiniTest::Unit::TestCase

  include Nanoc3::TestHelpers

  class TestDataSource < Nanoc3::DataSource

    identifier :test_data_source

    def code ; Nanoc3::Code.new('') ; end

  end

  class TestNewschoolDataSource < Nanoc3::DataSource

    identifier :test_newschool_data_source

    def items
      [
        Nanoc3::Item.new("Hi!",          {}, '/'),
        Nanoc3::Item.new("Hello there.", {}, '/about/')
      ]
    end

    def layouts
      [
        Nanoc3::Layout.new(
          'HEADER <%= yield %> FOOTER',
          { :filter => 'erb' },
          '/quux/'
        )
      ]
    end

    def code
      Nanoc3::Code.new("def something_random ; 'something random, yah' ; end")
    end

  end

  class TestEarlyLoadingCodeDataSource < Nanoc3::DataSource

    identifier :early_loading_code_data_source

    def items
      [
        Nanoc3::Item.new("Hi!",          {}, '/'),
        Nanoc3::Item.new("Hello there.", {}, '/about/')
      ]
    end

    def layouts
      [
        Nanoc3::Layout.new(
          'HEADER <%= yield %> FOOTER',
          { :filter => 'erb' },
          '/quux/'
        )
      ]
    end

    def code
      Nanoc3::Code.new('')
    end

  end

  def test_load_rules_with_existing_rules_file
    # Mock DSL
    dsl = mock
    dsl.expects(:compile).with('*')

    # Create site
    site = Nanoc3::Site.new({})
    site.expects(:dsl).returns(dsl)

    # Create rules file<commit_msg>removed unused mock classes from site test<commit_after># encoding: utf-8

require 'test/helper'

class Nanoc3::SiteTest < MiniTest::Unit::TestCase

  include Nanoc3::TestHelpers

  def test_load_rules_with_existing_rules_file
    # Mock DSL
    dsl = mock
    dsl.expects(:compile).with('*')

    # Create site
    site = Nanoc3::Site.new({})
    site.expects(:dsl).returns(dsl)

    # Create rules file
{'fraction_non_alphanumeric': 0.13396127681841968, 'fraction_numerical': 0.010465724751439037, 'mean_word_length': 2.3310104529616726, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 7, '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': '1423035', 'n_tokens_mistral': 666, 'n_tokens_neox': 614, 'n_words': 124}