<commit_before>require 'spec_helper'

describe WundergroundHistory, :vcr do
  let(:wunderground) { Wunderground.new(ENV['WUNDERGROUND_KEY']) }
  let(:hr) { WundergroundHistory.new }

  describe "premature?" do

    it "returns true when no data yet available from wunderground" do
      hr.time = Time.zone.parse('January 1, 3000 00:00:00 -04:00')
      hr.response = wunderground.history_for(hr.time, 'knyc')
      expect(hr).to be_premature
    end

    it "returns false when data was available at time of creation" do
      hr.time = Time.zone.parse('January 1, 2000 00:00:00 -04:00')
      hr.response = wunderground.history_for(hr.time, 'knyc')
      expect(hr).to_not be_premature
    end
  end

  describe "rate_limited?", :vcr do
    before(:each) do
    end

    it "returns true when rate limited" do
      hr.time = Time.zone.parse('January 1, 2000 00:00:00 -04:00')
      hr.response = wunderground.history_for(hr.time, 'knyc')
      expect(hr).to be_rate_limited
    end

    it "returns false when not rate limited" do
      hr.time = Time.zone.parse('January 1, 2000 00:00:00 -04:00')
      hr.response = wunderground.history_for(hr.time, 'knyc')
      expect(hr).to_not be_rate_limited
    end
  end

  describe "populate_observations!" do
  end

  describe ".new_from_api" do
    it "raises errors if data requested prematurely", :vcr do
      wunderground = Wunderground.new(ENV["WUNDERGROUND_KEY"])
      time = Time.zone.parse('January 22, 2016 12:00:00 -04:00')
      premature_response = wunderground.history_for(time, 10001)
      expect {
        WundergroundHistory.new_from_api(time, premature_response)
      }.to raise_error(WundergroundHistory::Premature)
    end

    it "raises errors if rate limited", :vcr do
      wunderground = Wunderground.new(ENV["WUNDERGROUND_KEY"])
      time = Time.zone.parse('March 1, 2015 00:00:00 -04:00')
      rate_limited_response = wunderground.history_for(time, 10001)
      expect {
        WundergroundHistory.new_from_api(time, rate_limited_response)
      }.to raise_error(WundergroundHistory::RateLimited)
    end<commit_msg>Remove unneeded :vcr tags and rename hr to wh<commit_after>require 'spec_helper'

describe WundergroundHistory, :vcr do
  let(:wunderground) { Wunderground.new(ENV['WUNDERGROUND_KEY']) }
  let(:wh) { WundergroundHistory.new }

  describe "premature?" do

    it "returns true when no data yet available from wunderground" do
      wh.time = Time.zone.parse('January 1, 3000 00:00:00 -04:00')
      wh.response = wunderground.history_for(wh.time, 'knyc')
      expect(wh).to be_premature
    end

    it "returns false when data was available at time of creation" do
      wh.time = Time.zone.parse('January 1, 2000 00:00:00 -04:00')
      wh.response = wunderground.history_for(wh.time, 'knyc')
      expect(wh).to_not be_premature
    end
  end

  describe "rate_limited?" do
    before(:each) do
    end

    it "returns true when rate limited" do
      wh.time = Time.zone.parse('January 1, 2000 00:00:00 -04:00')
      wh.response = wunderground.history_for(wh.time, 'knyc')
      expect(wh).to be_rate_limited
    end

    it "returns false when not rate limited" do
      wh.time = Time.zone.parse('January 1, 2000 00:00:00 -04:00')
      wh.response = wunderground.history_for(wh.time, 'knyc')
      expect(wh).to_not be_rate_limited
    end
  end

  describe "populate_observations!" do
  end

  describe ".new_from_api" do
    it "returns a WundergroundHistory object" do
    end

    it "raises errors if data requested prematurely" do
      wunderground = Wunderground.new(ENV["WUNDERGROUND_KEY"])
      time = Time.zone.parse('January 22, 2016 12:00:00 -04:00')
      premature_response = wunderground.history_for(time, 10001)
      expect {
        WundergroundHistory.new_from_api(time, premature_response)
      }.to raise_error(WundergroundHistory::Premature)
    end

    it "raises errors if rate limited" do
      wunderground = Wunderground.new(ENV["WUNDERGROUND_KEY"])
      time = Time.zone.parse('March 1, 2015 00:00:00 -04:00')
      rate_limited_response = wunderground.history_for(time, 10001)
      expect {
        WundergroundHistory.new_from_api(time, rate_limited_response)
      }.to raise_error(WundergroundHistory::RateLimited)
    end
{'fraction_non_alphanumeric': 0.10712611345522738, 'fraction_numerical': 0.0473511486169714, 'mean_word_length': 3.4727463312368974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6600538', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1390, 'n_words': 343}