RubyGems Navigation menu

mock_proxy 0.4.1

Remember when RSpec had stub_chain? They removed it for good reasons but sometimes you just need it. Well, here it is, a proxy object. It doesn't actually mock anything for you (the name is just catchy) so you need to do that. But that actually comes with a lot of benefits: 1) It's compatable with any testing framework 2) You can use it for purposes other than testing, e.g. prototyping, code stubs 3) Flexibility in how you use it without overloading the number of methods you have to remember Here's an example usage: let(:model_proxy) do MockProxy.new(email_client: { create_email: { receive: proc {} } }) end before { allow(Model).to receive(:new).and_return model_proxy } it 'should call receive' do proc = MockProxy.get(model_proxy, 'email_client.create_email.receive') expect(proc).to receive(:call) run_system_under_test MockProxy.update(mock_proxy, 'email_client.create_email.validate!') { true } MockProxy.observe(mock_proxy, 'email_client.create_email.send') do |to| expect(to).to eq 'stop@emailing.me' end run_system_under_test2 end As you can see, the proc - which ends the proxy by calling the proc - can be used for anything. You can spy on the call count and arguments, mock methods, or just stub out code you don't want executed. Because it doesn't make any assumptions, it becomes very flexible. Simple, yet powerful, it's uses are infinite. Enjoy

Gemfile:
= Copiar al portapapeles ¡Copiado!

instalar:
=

Versiones:

  1. 0.4.6 - August 15, 2016 (12 KB)
  2. 0.4.1 - August 12, 2016 (12 KB)
  3. 0.4.0 - August 12, 2016 (12 KB)
  4. 0.3.0 - February 19, 2016 (12 KB)
  5. 0.2.3 - February 19, 2016 (12 KB)
Mostrar todas las versiones (16 total)

dependencias de Runtime (1):

activesupport >= 4.2.5.1

dependencias de Development (2):

bundler >= 1.10
rake >= 10.0

Propietarios:

Autores:

  • matrinox

SHA 256 checksum:

4a542f7ed7d67928b400560257d4e51bbe2aa98119ce98366427ae22f54d0c32

Total de descargas 57.450

Para esta versión 2.767

Licencia:

MIT

Versión de Ruby requerida: >= 0

Enlace: