Created MessageBoard class and tests#2
Open
AnnieH wants to merge 2 commits intoRubyoffRails:masterfrom
Open
Conversation
Member
Yeah,
As far as rspec deprecating mock, I think that's booooo 👎 but it's their project. to use it: so, if you wanted a user that you'll call "Mary" that has a name and email, you could: A possible use: require 'rspec'
class User
def self.deliquent_process!
deliquent_users.each do |user|
user.send_deliquent_notice
end
end
end
describe 'emails deliquent invoices' do
let(:mary) { double(:mary, {name: 'Mary Johnson', email: 'mary9425@hotmail.com'}) }
it 'will email mary' do
User.stub('deliquent_users') { [mary] }
mary.should_receive(:send_deliquent_notice)
User.deliquent_process!
end
endIf you run this, it'll pass. but, it'll pass all the same if you replace the mary with: it's because it's a throwaway holder. We just care that the "thing" representing a user gets called. help? |
Member
|
The code you submitted on the assignment looks great -- no improvement needed! |
Author
|
Ah, thanks for that explanation and the example. Very helpful! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Question:
I have the latest version of RSpec installed and when I ran tests, it gave me the warning
Other sources said 'mock' was just an alias for 'double' anyways but I couldn't figure out how to use 'double' correctly. I suspect it has a slightly different function than mock as well. Can you give any guidance on that?