Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Best practice for mocks expectations? #82

Open
alexandru-calinoiu opened this issue Jul 24, 2013 · 3 comments
Open

Q: Best practice for mocks expectations? #82

alexandru-calinoiu opened this issue Jul 24, 2013 · 3 comments
Labels

Comments

@alexandru-calinoiu
Copy link

Hi,

I was wondering what is the best practice for mocks expectations:

Instead of:

it 'will receive create' do
    VendorSchedulable.should_receive(:create).with(:some, :other)
    CreateVendorSchedule.create(:some, :other)
end

I am wirting

before do
  VendorSchedulable.stub(:create)
  CreateVendorSchedule.create(42, 'deal-43')
end

it { expect(VendorSchedulable).to have_received(:create) }

But I don't really like it { expect

@jandudulski
Copy link

You still can write:

it 'will receive create' do
  expect(VendorSchedulable).to have_received(:create)
end

@alexandru-calinoiu
Copy link
Author

@jandudulski I guess this is an option also, can a best practice be extracted out of this scenario?

@onebree
Copy link
Contributor

onebree commented Jun 4, 2015

@Balauru Hello, I am pinging this to spark discussion. Unfortunately, I have nothing to contribute as the way I am used to testing is strictly Integration with Capybara and its DSL.

@onebree onebree changed the title Mocks expectations Q: Best practice for mocks expectations? Jun 4, 2015
@onebree onebree added question and removed thoughts labels Jun 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants