Sha256: dc35e0c11f69509b63042a519670a13e5a131146efd0a674d2907751980c322c

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'rspec'

RSpec.configure do |config|
  config.after(:all) do
    ActiveMocker::LoadedMocks.clear_all
  end

  config.before(:all) do
    ActiveMocker::LoadedMocks.clear_all
  end
end

$:.unshift File.expand_path('../../', __FILE__)
APP_ROOT = File.expand_path('../../', __FILE__) unless defined? APP_ROOT
require 'config/initializers/active_mocker.rb'
load 'mocks/user_mock.rb'

describe 'Should change state of mock'do

    before(:each) do
      UserMock.create

      UserMock.mock_class_method(:digest) do |token|
        token
      end
    end

    it 'should change record count and digest should be implemented' do
      expect(UserMock.count).to eq 1
      expect(UserMock.digest('token')).to eq 'token'
    end

end

describe 'should have fresh mock' do

  it 'should have record count of zero' do
    expect(UserMock.count).to eq 0
  end

  it 'should raise error when calling digest' do
    expect{UserMock.digest(nil)}.to raise_error(RuntimeError, '::digest is not Implemented for Class: UserMock')
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_mocker-1.4.2 sample_app_rails_4/spec/reload_spec.rb
active_mocker-1.4.1 sample_app_rails_4/spec/reload_spec.rb