<commit_before>require 'spec_helper'

describe Rainman::Driver::Runner, :pending => true do
  before do
    @handler = mock("Handler")
    @handler.stub(:hello).and_return(:hello)
    @handler.class.stub(:validations).and_return(Rainman::Driver::Validations.dup)
  end

  let(:handler)     { @handler }
  let(:name)        { :name }
  let(:validations) { @handler.class.validations }
  subject           { Driver::Runner.new(name, handler) }

  context "Accessors" do
    its(:name)        { should eql(name) }
    its(:handler)     { should eql(handler) }
    its(:validations) { should eql(validations) }
  end


  describe "#execute" do
    it "should validate globally" do
      validations[:global].should_receive(:validate!).with(1)
      subject.execute(:hello, 1)
    end

    it "should validate locally" do
      validations.merge!(name => Option.new(name))
      validations[:global].should_receive(:validate!).with(1)
      validations[name].should_receive(:validate!)
      subject.execute(:hello, 1)
    end
  end

  describe "#method_missing" do
    it "should delegate to the handler" do
      args = { :arg => 1 }
      handler.should_receive(:hello).with(args).once
      subject.hello(args)
    end

    it { expect { subject.missing }.to raise_error(NoMethodError) }
  end
end
<commit_msg>add runner spec<commit_after>require 'spec_helper'

describe Rainman::Driver::Runner do
  before do
    @handler = mock("Handler")
    @handler.stub(:hello).and_return(:hello)
    @handler.class.stub(:handler_name).and_return(:name)
    @handler.class.stub(:validations).and_return({ :global => Rainman::Option.new(:global), :validate => :me })
  end

  let(:handler)     { @handler }
  let(:name)        { :name }
  let(:validations) { @handler.class.validations }
  subject           { Rainman::Driver::Runner.new(handler) }

  context "Accessors" do
    its(:name)        { should eql(name) }
    its(:handler)     { should eql(handler) }
    its(:validations) { should eql(validations) }
  end


  describe "#execute" do
    it "should validate globally" do
      validations[:global].should_receive(:validate!).with(1)
      subject.execute(:hello, 1)
    end

    it "should validate locally" do
      validations.merge!(name => Rainman::Option.new(name))
      validations[:global].should_receive(:validate!).with(1)
      validations[name].should_receive(:validate!)
      subject.execute(:hello, 1)
    end
  end

  describe "#method_missing" do
    it "should delegate to the handler" do
      args = { :arg => 1 }
      handler.should_receive(:hello).with(args).once
      subject.hello(args)
    end

    it { expect { subject.missing }.to raise_error(NoMethodError) }
  end
end

{'fraction_non_alphanumeric': 0.13925925925925925, 'fraction_numerical': 0.003703703703703704, 'mean_word_length': 3.370550161812298, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '6520862', 'n_tokens_mistral': 858, 'n_tokens_neox': 825, 'n_words': 172}