Sha256: 685d64a88a2a30088a109941453b66b3c611f9deca0b798ba9aa9be3031b39b4

Contents?: true

Size: 607 Bytes

Versions: 3

Compression:

Stored size: 607 Bytes

Contents

require 'active_mocker/loaded_mocks'

RSpec.configure do |config|

  def mock_class(class_name)
    return class_name.constantize if defined?(Rails) && !self.class.metadata[:active_mocker]
    ActiveMocker::LoadedMocks.class_name_to_mock.select { |name, mock| name == class_name }.values.first
  end

  config.before(:each) do
    if self.class.metadata[:active_mocker]
      ActiveMocker::LoadedMocks.class_name_to_mock.each { |class_name, mock| stub_const(class_name, mock) }
    end
  end

  config.after(:all) do
    ActiveMocker::LoadedMocks.clear_all if self.class.metadata[:active_mocker]
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_mocker-1.6.2 lib/active_mocker/rspec_helper.rb
active_mocker-1.6.1 lib/active_mocker/rspec_helper.rb
active_mocker-1.6 lib/active_mocker/rspec_helper.rb