<commit_before>require 'spec_helper'

describe Rystrix::Status do
  describe '#initialize' do
    it 'should be zero all' do
      status = Rystrix::Status.new
      expect(status.success).to eq(0)
      expect(status.failure).to eq(0)
      expect(status.rejection).to eq(0)
      expect(status.timeout).to eq(0)
    end
  end

  describe '#increment' do
    context 'with success increment' do
      it 'should be increased only success' do
        status = Rystrix::Status.new
        status.increment :success
        expect(status.success).to eq(1)
        expect(status.failure).to eq(0)
        expect(status.rejection).to eq(0)
        expect(status.timeout).to eq(0)
      end

      it 'should be increased normally if #increment is called in parallel' do
        status = Rystrix::Status.new
        threads = 1000.times.map do
          Thread.start do
            status.increment :success
          end
        end
        threads.each(&:join)
        expect(status.success).to eq(1000)
      end
    end
  end
end
<commit_msg>Add a test case for Status#increment<commit_after>require 'spec_helper'

describe Rystrix::Status do
  describe '#initialize' do
    it 'should be zero all' do
      status = Rystrix::Status.new
      expect(status.success).to eq(0)
      expect(status.failure).to eq(0)
      expect(status.rejection).to eq(0)
      expect(status.timeout).to eq(0)
    end
  end

  describe '#increment' do
    context 'with success increment' do
      it 'should be increased only success' do
        status = Rystrix::Status.new
        status.increment :success
        expect(status.success).to eq(1)
        expect(status.failure).to eq(0)
        expect(status.rejection).to eq(0)
        expect(status.timeout).to eq(0)
      end

      it 'should be increased normally if #increment is called in parallel' do
        status = Rystrix::Status.new
        threads = 1000.times.map do
          Thread.start do
            status.increment :success
          end
        end
        threads.each(&:join)
        expect(status.success).to eq(1000)
      end
    end

    context 'with all increment' do
      it 'should be increased all' do
        status = Rystrix::Status.new
        status.increment :success
        status.increment :failure
        status.increment :rejection
        status.increment :timeout
        expect(status.success).to eq(1)
        expect(status.failure).to eq(1)
        expect(status.rejection).to eq(1)
        expect(status.timeout).to eq(1)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09585798816568047, 'fraction_numerical': 0.014201183431952662, 'mean_word_length': 2.268041237113402, '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': '5080593', 'n_tokens_mistral': 764, 'n_tokens_neox': 742, 'n_words': 204}