<commit_before>require File.expand_path("#{File.dirname(__FILE__)}/../../helper")

describe SendgridToolkit::Common do

  before do
    class FakeClass < SendgridToolkit::AbstractSendgridClient
      include SendgridToolkit::Common
    end
    @fake_class = FakeClass.new
  end

  it "creates a module_name method that returns the class name downcased" do
    @fake_class.module_name.should == "fakeclass"
  end

  it "does not choke if response does not have a 'message' field" do
    FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI}/fakeclass\.delete\.json\?.*email=.+|, :body => '{}')
    lambda {
      @fake_class.delete :email => "<EMAIL>"
    }.should_not raise_error
  end

  # this will only really test it on a computer that's on on utc.
  describe 'retrieve_with_timestamps' do
    it 'should parse the created date in utc' do
      FakeWeb.register_uri(:post, %r|https://sendgrid\.com/api/fakeclass\.get\.json\?.*date=1|, :body => '[{"created":"2013-11-25 13:00:00"}]')
      fake_class = @fake_class.retrieve_with_timestamps
      fake_class[0]['created'].utc.iso8601.should == "2013-11-25T13:00:00Z"
    end
  end

end<commit_msg>Update specs from prior pull request to work with generic sendgrid URI as implemented before merge.<commit_after>require File.expand_path("#{File.dirname(__FILE__)}/../../helper")

describe SendgridToolkit::Common do

  before do
    class FakeClass < SendgridToolkit::AbstractSendgridClient
      include SendgridToolkit::Common
    end
    @fake_class = FakeClass.new
  end

  it "creates a module_name method that returns the class name downcased" do
    @fake_class.module_name.should == "fakeclass"
  end

  it "does not choke if response does not have a 'message' field" do
    FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI}/fakeclass\.delete\.json\?.*email=.+|, :body => '{}')
    lambda {
      @fake_class.delete :email => "<EMAIL>"
    }.should_not raise_error
  end

  # this will only really test it on a computer that's on on utc.
  describe 'retrieve_with_timestamps' do
    it 'should parse the created date in utc' do
      FakeWeb.register_uri(:post, %r|https://#{REGEX_ESCAPED_BASE_URI}/fakeclass\.get\.json\?.*date=1|, :body => '[{"created":"2013-11-25 13:00:00"}]')
      fake_class = @fake_class.retrieve_with_timestamps
      fake_class[0]['created'].utc.iso8601.should == "2013-11-25T13:00:00Z"
    end
  end

end
{'fraction_non_alphanumeric': 0.13297431648715824, 'fraction_numerical': 0.028169014084507043, 'mean_word_length': 3.9285714285714284, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 4, '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': '7307525', 'n_tokens_mistral': 871, 'n_tokens_neox': 798, 'n_words': 196}