<commit_before>require 'spec_helper'

describe SocialMsg do
  let(:words)       { %w{ UFO bigfoot } }
  let(:bitly_auth)  { ['test', '0<PASSWORD>'] }
  let(:news_item)   { FakeNewsItem.new }
  let(:social_msg)  { SocialMsg.new news_item }
  let(:bitly) do
    b = double('bitly')
    b.stub(:shorten).and_return(b)
    b.stub(:short_url).and_return('http://bit.ly/NGx5IN')
    b
  end

  before do
    news_item
    social_msg
    bitly
  end

  it "has a VERSION constant" do
    expect( SocialMsg::VERSION ).to_not be_empty
    expect( SocialMsg::VERSION ).to match(/^[\w\d\.\-\_\/]+$/)
  end

  context "validation when initializing" do
    it "can create a valid new instance if an obj with expected methods is passed to it" do
      expect( SocialMsg.new(news_item) ).to be_valid
    end
  
    it "does not create a new instance if an invalid obj type is passed in" do
      expect { SocialMsg.new(String.new) }.to raise_error(ArgumentError)
    end
  
    it "can create a new instance if passed a valid hash" do
      expect( 
          SocialMsg.new( name: 'bar', title: 'foo', link_url: 'http://baz.com' )
      ).to be_valid
    end
  
    it "does not create a new instance if passed a hash without expected keys" do
      expect { SocialMsg.new( foo: 'bar' ) }.to raise_error(ArgumentError)
    end

    it "does not create a new instance if passed an obj with nil values" do
      expect {
        SocialMsg.new( name: nil, title: nil, link_url: nil )
      }.to raise_error(ArgumentError)
    end
  end

  context "an instance" do
    it "can change its name" do<commit_msg>100% test coverage<commit_after>require 'spec_helper'

describe SocialMsg do
  let(:words)       { %w{ UFO bigfoot } }
  let(:bitly_auth)  { ['test', '02934uhsdfsdkjh23_32jn'] }
  let(:news_item)   { FakeNewsItem.new }
  let(:social_msg)  { SocialMsg.new news_item }
  let(:bitly) do
    b = double('bitly')
    b.stub(:shorten).and_return(b)
    b.stub(:short_url).and_return('http://bit.ly/NGx5IN')
    b
  end

  before do
    news_item
    social_msg
    bitly
  end

  it "has a VERSION constant" do
    expect( SocialMsg::VERSION ).to_not be_empty
    expect( SocialMsg::VERSION ).to match(/^[\w\d\.\-\_\/]+$/)
  end

  context "validation when initializing" do
    it "can create a valid new instance if an obj with expected methods is passed to it" do
      expect( SocialMsg.new(news_item) ).to be_valid
    end
  
    it "does not create a new instance if an invalid obj type is passed in" do
      expect { SocialMsg.new(String.new) }.to raise_error(ArgumentError)
    end
  
    it "can create a new instance if passed a valid hash" do
      expect( 
          SocialMsg.new( name: 'bar', title: 'foo', link_url: 'http://baz.com' )
      ).to be_valid
    end
  
    it "does not create a new instance if passed a hash without expected keys" do
      expect { SocialMsg.new( foo: 'bar' ) }.to raise_error(ArgumentError)
    end

    it "does not create a new instance if passed an obj with nil values" do
      expect {
        SocialMsg.new( name: nil, title: nil, link_url: nil )
      }.to raise_error(ArgumentError)
    end
  end

  context "an instance" do
    it "can set the bitly auth with a helper method" do
      social_msg.bitly_auth = 'foo'
      SocialMsg.bitly_auth.should eq 'foo'
    end

    it "can change its name" do
{'fraction_non_alphanumeric': 0.10695026962252846, 'fraction_numerical': 0.004493708807669263, 'mean_word_length': 2.7643742953776775, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '82694', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1105, 'n_words': 372}