<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Texas::Build::Base do

  def fake_options
    options = OpenStruct.new({
      :work_dir => "/tmp/test_project",
      :contents_dir => "contents",
      :contents_template => "contents"
      })
  end

  def fake_build
    Texas::Build::Base.new(fake_options)
  end
  
  def test_build
    @test_build ||= get_runner_instance
  end

  def get_runner_instance
    run_scenario "basic" do |runner|
      return runner.task_instance
    end
  end

  class FoobarTask
    class << self
      attr_accessor :foo
    end

    def initialize(*args)
    end

    def run
      self.class.foo = :bar
    end
  end

  describe "#run_build_task" do
    it "should instantiate the given class and call the run method" do
      FoobarTask.foo.nil?.should == true
      test_build.run_build_task FoobarTask
      FoobarTask.foo.should == :bar
    end
  end

  describe "#ran_templates" do
    it "returns the templates" do
      filenames = test_build.ran_templates.map(&:filename)
      basenames = filenames.map { |f| f.gsub(test_build.__path__+'/', '') }
      basenames.size.should > 0
      basenames.include?("unused_template.tex.erb").should == false
    end
  end

  describe "#__path__" do
    it "should return the build path" do
      build = fake_build
      build.__path__.should == "#{fake_options.work_dir}/tmp/build"
    end
  end
  
  describe "#store" do
    it "should return a object that can store values" do
      build = fake_build
      store = build.store
      store.test_value.should == nil
      store.test_value = 42
      store.test_value.should == 42<commit_msg>Fix typo<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Texas::Build::Base do

  def fake_options
    options = OpenStruct.new({
      :work_dir => "/tmp/test_project",
      :contents_dir => "contents",
      :contents_template => "contents"
      })
  end

  def fake_build
    Texas::Build::Base.new(fake_options)
  end
  
  def test_build
    @test_build ||= get_runner_instance
  end

  def get_runner_instance
    run_scenario "basic" do |runner|
      return runner.task_instance
    end
  end

  class FoobarTask
    class << self
      attr_accessor :foo
    end

    def initialize(*args)
    end

    def run
      self.class.foo = :bar
    end
  end

  describe "#run_build_task" do
    it "should instantiate the given class and call the run method" do
      FoobarTask.foo.nil?.should == true
      test_build.run_build_task FoobarTask
      FoobarTask.foo.should == :bar
    end
  end

  describe "#ran_templates" do
    it "returns the templates" do
      filenames = test_build.ran_templates.map(&:filename)
      basenames = filenames.map { |f| f.gsub(test_build.__path__+'/', '') }
      basenames.size.should > 0
      basenames.include?("unused_template.tex.erb").should == false
    end
  end

  describe "#__path__" do
    it "should return the build path" do
      build = fake_build
      build.__path__.should == "#{fake_options.work_dir}/tmp/build"
    end
  end
  
  describe "#store" do
    it "should return an object that can store values" do
      build = fake_build
      store = build.store
      store.test_value.should == nil
      store.test_value = 42
      store.test_value.should == 42
{'fraction_non_alphanumeric': 0.10149253731343283, 'fraction_numerical': 0.0029850746268656717, 'mean_word_length': 2.706858407079646, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5298855', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1060, 'n_words': 268}