<commit_before>require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'notifier')
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'result')
require File.join(File.dirname(__FILE__), 'helpers')

describe "running the notifier" do 
 
  before(:each) do 
  end
 
  it "should complain if no logger has been specified" do 
    lambda {
      n = Flapjack::Notifier.new
    }.should raise_error(RuntimeError)
  end
  
  it "should have a blank recipients list if none specified" do 
    n = Flapjack::Notifier.new(:logger => MockLogger.new)
    n.recipients.should_not be_nil
    n.recipients.size.should == 0
  end

  it "should warn if no notifiers have been specified" do 
    n = Flapjack::Notifier.new(:logger => MockLogger.new)
    n.log.messages.last.should =~ /no notifiers/
  end

  it "should log when adding a new notifier" do
    mock_notifier = mock("MockFlapjack::Notifier")
    n = Flapjack::Notifier.new(:logger => MockLogger.new, 
                     :notifiers => [mock_notifier])
    n.log.messages.last.should =~ /using the (.+) notifier/
  end

  it "should call notify on each notifier when notifying" do 
    mock_notifier = mock("MockFlapjack::Notifier")
    mock_notifier.should_receive(:notify)

    n = Flapjack::Notifier.new(:logger => MockLogger.new, 
                     :notifiers => [mock_notifier],
                     :recipients => [OpenStruct.new({:name => "<NAME>"})])
    n.notify!(Flapjack::Result.new(:id => 'mock result'))
  end

  it "should log notification on each notifier" do 
    mock_notifier = mock("MockFlapjack::Notifier")
    mock_notifier.stub!(:notify)

    n = Flapjack::Notifier.new(:logger => MockLogger.new, 
                     :notifiers => [mock_notifier],
                     :recipients => [OpenStruct.new({:name => "<NAME>"})])
    n.notify!(Flapjack::Result.new(:id => '12345'))
    n.log.messages.last.should =~ /12345/
    n.log.messages.last.should =~ /<NAME>/
  end
end


def puts(*args) ; end
<commit_msg>use the notify! interface correctly<commit_after>require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'notifier')
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'result')
require File.join(File.dirname(__FILE__), 'helpers')

describe "running the notifier" do 
 
  before(:each) do 
  end
 
  it "should complain if no logger has been specified" do 
    lambda {
      n = Flapjack::Notifier.new
    }.should raise_error(RuntimeError)
  end
  
  it "should have a blank recipients list if none specified" do 
    n = Flapjack::Notifier.new(:logger => MockLogger.new)
    n.recipients.should_not be_nil
    n.recipients.size.should == 0
  end

  it "should warn if no notifiers have been specified" do 
    n = Flapjack::Notifier.new(:logger => MockLogger.new)
    n.log.messages.last.should =~ /no notifiers/
  end

  it "should log when adding a new notifier" do
    mock_notifier = mock("MockFlapjack::Notifier")
    n = Flapjack::Notifier.new(:logger => MockLogger.new, 
                     :notifiers => [mock_notifier])
    n.log.messages.last.should =~ /using the (.+) notifier/
  end

  it "should call notify on each notifier when notifying" do 
    mock_notifier = mock("MockFlapjack::Notifier")
    mock_notifier.should_receive(:notify)

    n = Flapjack::Notifier.new(:logger => MockLogger.new, 
                     :notifiers => [mock_notifier],
                     :recipients => [OpenStruct.new({:name => "<NAME>"})])
    n.notify!(Flapjack::Result.new(:id => 'mock result'), nil)
  end

  it "should log notification on each notifier" do 
    mock_notifier = mock("MockFlapjack::Notifier")
    mock_notifier.stub!(:notify)

    n = Flapjack::Notifier.new(:logger => MockLogger.new, 
                     :notifiers => [mock_notifier],
                     :recipients => [OpenStruct.new({:name => "<NAME>"})])
    n.notify!(Flapjack::Result.new(:id => '12345'), nil)
    n.log.messages.last.should =~ /12345/
    n.log.messages.last.should =~ /<NAME>/
  end
end


def puts(*args) ; end

{'fraction_non_alphanumeric': 0.1436696340257171, 'fraction_numerical': 0.005440158259149357, 'mean_word_length': 3.123343527013252, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, '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': '3586488', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1279, 'n_words': 304}