Sha256: fd9255b41f488bf54e7adda25ba9f323fb403f95f0bccb5f6b1a4fd710d0f487

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe 'integration with rspec-mocks' do

  let(:mp3) { Surrogate.endow(Class.new).define(:play) { }.new }

  it 'knows that rspec-mocks is loaded' do
    Surrogate::RSpec.rspec_mocks_loaded?.should equal true
  end

  context 'when rspec-mocks is loaded' do
    it 'uses their matchers' do
      mp3.play "Emily Wells"
      mp3.should have_been_told_to(:play).with(/emily/i)
      mp3.should_not have_been_told_to(:play).with(/emily/)

      mp3.play /regex/
      mp3.should have_been_told_to(:play).with(/regex/)
      mp3.should_not have_been_told_to(:play).with(/xeger/)
    end
  end

  context 'when rspec-mocks is not loaded' do
    it 'does straight #== comparisons on each argument' do
      begin
        Surrogate::RSpec.rspec_mocks_loaded = false

        mp3.play "Emily Wells"
        mp3.should_not have_been_told_to(:play).with(/emily/i)

        mp3.play /regex/
        mp3.should have_been_told_to(:play).with(/regex/)
        mp3.should_not have_been_told_to(:play).with(/xeger/)
      rescue Exception
        Surrogate::RSpec.rspec_mocks_loaded = true
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
surrogate-0.5.5 spec/rspec/rspec_mocks_integration_spec.rb
surrogate-0.5.4 spec/rspec/rspec_mocks_integration_spec.rb
surrogate-0.5.3 spec/rspec/rspec_mocks_integration_spec.rb
surrogate-0.5.2 spec/rspec/rspec_mocks_integration_spec.rb
surrogate-0.5.1 spec/rspec/rspec_mocks_integration_spec.rb
surrogate-0.5.0 spec/rspec/rspec_mocks_integration_spec.rb
surrogate-0.4.3 spec/rspec/rspec_mocks_integration_spec.rb
surrogate-0.4.2 spec/rspec/rspec_mocks_integration_spec.rb