Sha256: d8a5658a2467dea5d004f5c6c979c3cec48cfc65cdc641ab5a7d7d7079f8e431

Contents?: true

Size: 1.03 KB

Versions: 15

Compression:

Stored size: 1.03 KB

Contents

require "webmock/minitest"

module SupportsResourceLocking
  def self.included(base)
    base.class_eval do
      let(:collection_name) { subject.collection_name }

      def test_responds_to_locked
        assert_respond_to subject, :locked?
      end

      def test_responds_to_lock
        assert_respond_to subject, :lock!
      end

      def test_lock_makes_request
        skip if RUBY_VERSION < "1.9"

        subject.id = "tst-12345"

        stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/lock_resource?account_id=").to_return(:status => 200, :body => "{}", :headers => {})

        subject.lock!
      end

      def test_responds_to_unlock
        assert_respond_to subject, :unlock!
      end

      def test_unlock_makes_request
        skip if RUBY_VERSION < "1.9"

        subject.id = "tst-12345"

        stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/unlock_resource?account_id=").to_return(:status => 200, :body => "{}", :headers => {})

        subject.unlock!
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-brightbox-0.9.0/spec/supports_resource_locking.rb
fog-brightbox-0.9.0 spec/supports_resource_locking.rb
fog-brightbox-0.8.0 spec/supports_resource_locking.rb
fog-brightbox-0.7.2 spec/supports_resource_locking.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-brightbox-0.7.1/spec/supports_resource_locking.rb
fog-brightbox-0.7.1 spec/supports_resource_locking.rb
fog-brightbox-0.7.0 spec/supports_resource_locking.rb
fog-brightbox-0.6.1 spec/supports_resource_locking.rb
fog-brightbox-0.6.0 spec/supports_resource_locking.rb
fog-brightbox-0.5.1 spec/supports_resource_locking.rb
fog-brightbox-0.5.0 spec/supports_resource_locking.rb
fog-brightbox-0.4.1 spec/supports_resource_locking.rb
fog-brightbox-0.4.0 spec/supports_resource_locking.rb
fog-brightbox-0.3.0 spec/supports_resource_locking.rb
fog-brightbox-0.2.0 spec/supports_resource_locking.rb