Sha256: 8d55fab35106a485e07d32d620a98c4bb5f5d8254fd0c8310d5090d4a631d0af

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

# encoding: utf-8
# This file is part of ruby-flores.
# Copyright (C) 2015 Jordan Sissel
# 
require "spec_init"

Counter = Class.new do
  attr_reader :value
  def initialize
    @value = 0
  end

  def incr
    @value += 1
  end

  def decr
    @value -= 1
  end
end

describe Flores::RSpec::Stress do
  subject { Counter.new }
  before do
    expect(subject.value).to(be == 0)
    subject.incr
    expect(subject.value).to(be == 1)
  end
  
  after do
    expect(subject.value).to(be == 1)
    subject.decr
    expect(subject.value).to(be == 0)
  end

  stress_it "should call all before and after hooks" do
    expect(subject.value).to(be == 1)
  end

  describe "level 1" do
    before do
      expect(subject.value).to(be == 1)
      subject.incr
      expect(subject.value).to(be == 2)
    end
    
    after do
      expect(subject.value).to(be == 2)
      subject.decr
      expect(subject.value).to(be == 1)
    end

    stress_it "should call all before and after hooks" do
      expect(subject.value).to(be == 2)
    end

    describe "level 2" do
      before do
        expect(subject.value).to(be == 2)
        subject.incr
        expect(subject.value).to(be == 3)
      end
      
      after do
        expect(subject.value).to(be == 3)
        subject.decr
        expect(subject.value).to(be == 2)
      end

      stress_it "should call all before and after hooks" do
        expect(subject.value).to(be == 3)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flores-0.0.8 spec/flores/rspec/stress_spec.rb