Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

Testing With Logan

Receive Message Chain

receive_message_chain
1
2
allow(obj).to receive_message_chain(:foo, :bar).and_return(double)
expect(obj.foo.bar).to receive(:bazz).with(/adfads/)

Yielding multiple variables

  • allow(fake_container).to receive(:attach).and_yield("stdout", "some message\n")

expect_any_instance_of

Testing Sidekiq

  • Mike Perham did a nice job documenting the testing options for workers.

    Detecting pending migrations

  • A neat little trick to see if there are pending migrations rake db:migrate:status. This must have been built into rails because I see a message every time I haven’t run a migration and I am running my test suite. It’s cool nonetheless. Source

Comments