Sha256: 8c98ec808e7399c462a78823add7fcd3e7e7160f3853828c51eb4b18595ec73d

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

shared_examples_for 'a handle' do
  describe "#ref" do
    it "calls UV.ref" do
      UV.should_receive(:ref).with(pointer)

      subject.ref
    end
  end

  describe "#unref" do
    it "calls UV.unref" do
      UV.should_receive(:unref).with(pointer)

      subject.unref
    end
  end

  describe "#close" do
    it "requires a block" do
      expect { subject.close }.to raise_error(ArgumentError)
    end

    it "calls UV.close" do
      UV.should_receive(:close).once.with(pointer, subject.method(:on_close))
      subject.close {}
    end
  end

  describe "#active?" do
    it "is true for positive integers" do
      UV.should_receive(:is_active).with(pointer).and_return(2)
      subject.active?.should be_true
    end

    it "is false for integers less than 1" do
      UV.should_receive(:is_active).with(pointer).and_return(0)
      subject.active?.should be_false
    end
  end

  describe "#closing?" do
    it "is true for positive integers" do
      UV.should_receive(:is_closing).with(pointer).and_return(1)
      subject.closing?.should be_true
    end

    it "is false for integers less than 1" do
      UV.should_receive(:is_closing).with(pointer).and_return(-1)
      subject.closing?.should be_false
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uvrb-0.2.0 spec/shared_examples/handle.rb
uvrb-0.1.4 spec/shared_examples/handle.rb
uvrb-0.1.3 spec/shared_examples/handle.rb
uvrb-0.1.2 spec/shared_examples/handle.rb
uvrb-0.1.1 spec/shared_examples/handle.rb
uvrb-0.1.0 spec/shared_examples/handle.rb