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

may need a bit more practice and help #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mikeadeleke
Copy link

I'm wondering in RSpec if the previous tests pass before you move on to next test. That way, I can see that since Engineer and Conductor have already had their actions I do not need them again in MessageBoard. But then, I seem to get the wrong number of arguementts and don't exactly know what I should be passing in.
screenshot 2014-02-10 11 01 54

@jwo
Copy link
Member

jwo commented Feb 11, 2014

I'm wondering in RSpec if the previous tests pass before you move on to next test.

Yes, in all TDD you should go Red, Green, Refactor:

  1. Red: you write a failing test
  2. Green: you make that test pass (and all other tests)
  3. Refactor: Prune your code and improve your tests. This is where you can make it better.


it "should receive slow down from conductor" do
message_board.should_receive(:slow_down!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are not performing any actions or calling any methods.

All you are doing with this message expectation is saying that for this test to pass, the message_board should receive a call of slow_down!

The normal flow here would be to then execute some code to see if it happened.

it "should receive slow down from conductor" do
  message_board.should_receive(:slow_down!)
  conductor.see_danger_coming!
end

@mikeadeleke
Copy link
Author

Okay so I fixed that but what really gets me is that I am not really understanding the arguments error. Is there somewhere I can read up on that? I have found little by searching my error message. Same for "matches?" too.

screenshot 2014-02-10 21 04 24

@jwo
Copy link
Member

jwo commented Feb 11, 2014

You could specify the exact argument you want.

For example, if you wanted to make sure the AnswerBank received the answer 42, you could:

answer_bank.should_receive(:record_answer).with(42)

By default, it will accept "any_arguments" if you do not specifiy.

it "should receive a slow down confirmation from the engineer" do
message_board.should_receive(:confirm_slow_down!)
engineer.should(:slow_down!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a valid specification?

It COULD be, if you write it. That is, if you created a customer matcher... But you didn't, so you got an error about a "matcher"

@mikeadeleke
Copy link
Author

Hmmm. Okay, how do my tests look? Am I on the right track?

@jwo
Copy link
Member

jwo commented Feb 12, 2014

Yep, you're on the right track!

@mikeadeleke
Copy link
Author

Sorry I am dong so many at one time but wanted to go over some core concepts before I got started with my MVP.

I'm looking into "any args" and am only getting more confused. Do you suggest any resources or am I over-thinking this?

@jwo
Copy link
Member

jwo commented Feb 17, 2014

IMHO you are way over-thinking this.

But, if you want to see the documentation: https://www.relishapp.com/rspec/rspec-mocks/docs/message-expectations/expect-message-using-should-receive#expect-a-message-with-an-argument

@mikeadeleke
Copy link
Author

Hmm. How am I over-thinking this?

@jwo
Copy link
Member

jwo commented Feb 18, 2014

because any_args simply doesn't matter

On Mon, Feb 17, 2014 at 10:55 PM, Mike Adeleke [email protected]
wrote:

Hmm. How am I over-thinking this?

Reply to this email directly or view it on GitHub:
#10 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants