<commit_before>require 'spec_helper'

describe Honeybadger::Api::Notice do

  describe "initializing a new comment" do
    before :all do
      @notice = FactoryGirl.build :notice
    end

    it "should have a identifier" do
      expect(@notice.id).to eql("5a24f938-a578-427d-a92b-d2f134d4af67")
    end

    it "should have a fault identifier" do
      expect(@notice.fault_id).to eql(2)
    end

    it "should have a message" do
      expect(@notice.message).to eql("This is a runtime error")
    end

    it "should have an environment" do
      expect(@notice.environment).to eql("production")
    end

    it "should have an environment_name" do
      expect(@notice.environment_name).to eql("production")
    end

    it "should have cookies" do
      expect(@notice.cookies).to eql({:cookie => "monster"})
    end

    it "should have a request" do
      expect(@notice.request.empty?).to be_falsey
    end

    it "should have a created_at" do
      expect(@notice.created_at).to eql(DateTime.parse("2012-01-01T00:01:00Z"))
    end
  end

  describe "all" do
    before :each do
      @project_id = 1
      @fault_id = 2
      @path = "projects/#{@project_id}/faults/#{@fault_id}/notices"
      @handler = Proc.new { |response| Notice.new(response) }
      Honeybadger::Api::Notice.expects(:handler).returns(@handler)
    end

    it "should find all of the notices" do
      Honeybadger::Api::Request.expects(:all).with(@path, @handler).once<commit_msg>Add spec to cover adding web environment attribute to notices resource.<commit_after>require 'spec_helper'

describe Honeybadger::Api::Notice do

  describe "initializing a new comment" do
    before :all do
      @notice = FactoryGirl.build :notice
    end

    it "should have a identifier" do
      expect(@notice.id).to eql("5a24f938-a578-427d-a92b-d2f134d4af67")
    end

    it "should have a fault identifier" do
      expect(@notice.fault_id).to eql(2)
    end

    it "should have a message" do
      expect(@notice.message).to eql("This is a runtime error")
    end

    it "should have an environment" do
      expect(@notice.environment).to eql("production")
    end

    it "should have an environment_name" do
      expect(@notice.environment_name).to eql("production")
    end

    it "should have cookies" do
      expect(@notice.cookies).to eql({:cookie => "monster"})
    end

    it "should have a web environment" do
      web_environment = {
        :REMOTE_ADDR => "127.0.0.1",
        :REQUEST_METHOD => "POST"
      }
      expect(@notice.web_environment).to eql(web_environment)
    end

    it "should have a request" do
      expect(@notice.request.empty?).to be_falsey
    end

    it "should have a created_at" do
      expect(@notice.created_at).to eql(DateTime.parse("2012-01-01T00:01:00Z"))
    end
  end

  describe "all" do
    before :each do
      @project_id = 1
      @fault_id = 2
      @path = "projects/#{@project_id}/faults/#{@fault_id}/notices"
      @handler = Proc.new { |response| Notice.new(response) }
      Honeybadger::Api::Notice.expects(:handler).returns(@handler)
    end

    it "should find all of the notices" do
      Honeybadger::Api::Request.expects(:all).with(@path, @handler).once
{'fraction_non_alphanumeric': 0.11946350592638802, 'fraction_numerical': 0.025577043044291953, 'mean_word_length': 3.018796992481203, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '6158448', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1011, 'n_words': 272}