Can you add simple argument-baesd logic to stubs?

Hi

Is there any way to do the following with stubs?

  template.should_receive(:formatted_last_login).
            with(duck_type(:last_login_date)).
            any_number_of_times.
            and_return { |user| "last-login-#{user.id}" }

If I change “should_receive” to “stub!”, Ruby complains that 0 args are
being passed in for 1 to the block. But a quick look through the RSpec
code
makes it look like stub call args are passed to the and_return block.

I can live with the above, I just don’t need it auto-verified (I’m doing
that with should have_tag)

Thanks
Ashley

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs