Open atkolkma opened 11 years ago
I just got the test to pass by calling fizzbuzzer on an instantiation of FizzBuzz.
Good job pushing through it! Since you used the describe FizzBuzz
style (instead of passing a string to describe), you automatically get a "subject" variable that's an instance of the class under test, so you could do this, too:
expect(subject.fizzbuzzer(9)).to eql("Fizz")
Some people don't care for the "free" instance, and it doesn't work if you need to pass config data into your constructor, but it's worth knowing about and usable in this situation.
Also worth mentioning is that eql
can be shortened to just eq
: apparently they're equivalent. I wasn't aware of the three-letter variant.
@matthew-p Exactly!
I am almost positive I am doing everything right with regards to rspec syntax. I've checked the documentation a million times. Not sure why I get an undefined method error when I run a very basic rspec test. Here is my spec file:
https://gist.github.com/atkolkma/7516896
When I run it, I get this error:
Failure/Error: expect(fizzbuzzer(9)).to eql("Fizz") NoMethodError: undefined method `fizzbuzzer' for #
./fizzbuzz_spec.rb:7:in`block (3 levels) in <top (required)>'
I'm testing the fizzbuzz.rb file from the repo that was posted for testing purposes. Also, there is no load error for fizzbuzz.rb