Skip to content

Conversation

@jperezish
Copy link

Well here's my first one. I can't sort out a cleaner way to set up the average grade unit test.

Copy link
Member

Choose a reason for hiding this comment

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

If you wanted to clean these assignments up, you could:

assignment1 = double("assignment 1", {:grade= => nil, :grade => 95})

Copy link
Member

Choose a reason for hiding this comment

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

On a more fundamental level, you were right on when you said that you felt this was a tad messy. You're having to set up many things beforehand to setup a test.

describe "should provide an average grade for the class" do
  it "should provide an average grade" do
    assignment_doubles = [
      double(grade:95),
      double(grade:50),
      double(grade:85)
    ]
    subject.stub(:assignments, assignment_doubles)
    subject.average_grade.should eq(75)
  end
end

Copy link
Author

Choose a reason for hiding this comment

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

So subject.stub(:assignments, assignment_doubles) takes the place of the instance variable @assignments?

Copy link
Member

Choose a reason for hiding this comment

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

That's the design. You will need to access 'assignments' instead of '@assignments' for this to work.

@jwo
Copy link
Member

jwo commented Jan 2, 2014

Excellent job! Your specs and cukes both read well, yay!

My comments are advanced and mostly stylistic --- let me know what you think!

@jperezish
Copy link
Author

This is exactly what I was missing. Quick relevant feedback! I spend time looking through the Ruby Docs for appropriate methods but having someone provide some input on code I've already been thinking about is a more meaningful way to go about it. Thanks for the feedback Jesse! When I change this should I resubmit or just make the changes? I'm going to do the other levels on this one so I'm going to refactor it before I do. Should I make the changes and just submit a pull request with the Tiger level features?

@jwo
Copy link
Member

jwo commented Jan 2, 2014

This is exactly what I was missing. Quick relevant feedback! I spend time looking through the Ruby Docs for appropriate methods but having someone provide some input on code I've already been thinking about is a more meaningful way to go about it.

Thanks! That's so awesome --- are you OK if I use that in a testimonial?

When I change this should I resubmit or just make the changes?

This pull request will stay open -- so if you make changes and push to your github repo, this pull will stay open and automatically update itself. You'll need to notify me of the changes in a comment on the pull -- just a simple "ping @jwo updated pull" will work.

@jperezish
Copy link
Author

Thanks! That's so awesome --- are you OK if I use that in a testimonial?

Of course. Go for it. Would you mind linking back to my blog in the testimonial? Actually can you wait until next week as I've changed the look and I have a new article I'm posting on Tuesday. It's at perezish.com

@jwo
Copy link
Member

jwo commented Jan 2, 2014

Sure, I absolutely will link to you. Do you have a photo you'd like me to use?

@jperezish
Copy link
Author

@jwo
Copy link
Member

jwo commented Jan 2, 2014

Awesome 🤘

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