<commit_before>require 'spec_helper'

describe ReadingsController do
    it "creates readings" do
    tahiti = Sensor.find_or_create_by(name: "tahiti")
    tahiti.readings.clear
    daniel = create(:user)
    tahiti.user = daniel
    tahiti.save

    params = {
      sensor_name: "tahiti",
      temp: 56,
      time: "Wed Jul  2 16:07:09 EDT 2014",
      verification: 1234
    }

    post :create, reading: params, format: 'json'
    expect(tahiti.readings.count).to eq 1

    # curl -X POST -H "Content-Type: application/json" -d '{"reading": {"sensor_name": "tahiti", "temp": "56", "time": "Wed Jul  2 16:07:09 EDT 2014", "verification": "1234"}}' localhost:3000/readings.json
  end
end<commit_msg>Stub WeatherMan on readings_controller spec, to fix travis build failing due to missing api key<commit_after>require 'spec_helper'

describe ReadingsController do
  before { allow(WeatherMan).to receive(:current_outdoor_temp).and_return 65 }

  it "creates readings" do
    tahiti = Sensor.find_or_create_by(name: "tahiti")
    tahiti.readings.clear
    daniel = create(:user)
    tahiti.user = daniel
    tahiti.save

    params = {
      sensor_name: "tahiti",
      temp: 56,
      time: "Wed Jul  2 16:07:09 EDT 2014",
      verification: 1234
    }

    post :create, reading: params, format: 'json'
    expect(tahiti.readings.count).to eq 1

    # curl -X POST -H "Content-Type: application/json" -d '{"reading": {"sensor_name": "tahiti", "temp": "56", "time": "Wed Jul  2 16:07:09 EDT 2014", "verification": "<PASSWORD>"}}' localhost:3000/readings.json
  end
end
{'fraction_non_alphanumeric': 0.13104325699745548, 'fraction_numerical': 0.04834605597964377, 'mean_word_length': 3.5201149425287355, 'pattern_counts': {'":': 10, '<': 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': '1551638', 'n_tokens_mistral': 624, 'n_tokens_neox': 528, 'n_words': 147}