Re: [rspec-users] lots of nil problems!

2010-03-22 Thread Phillip Koebbe
On 2010-03-20 12:17 PM, David Chelimsky wrote: 2. Setup context in before blocks, not expectations We want the example names to express the intent of each example. The before block in the "with valid id' context sets two expectations, and then each example sets one of its own. If "should_not_as

Re: [rspec-users] lots of nil problems!

2010-03-22 Thread David Chelimsky
On Mar 20, 2010, at 1:22 PM, Phillip Koebbe wrote: > Patrick, don't listen to me :) Listen to David. That's just silly. Patrick, please listen to both of us (and everyone else who contributes to this list). What Phillip wrote about the difference between mocks and stubs was dead on. I was commen

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Phillip Koebbe
On 2010-03-20 12:17 PM, David Chelimsky wrote: On Sat, Mar 20, 2010 at 10:19 AM, Phillip Koebbe wrote: I would be glad to help in this way, but it will have to be later today. And instead of using completely made-up code, I'll use some of my real-world code and tests as an example. I

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread David Chelimsky
On Sat, Mar 20, 2010 at 10:19 AM, Phillip Koebbe wrote: > >> I would be glad to help in this way, but it will have to be later today. >> And instead of using completely made-up code, I'll use some of my real-world >> code and tests as an example. I'll gist them later, unless one of the gurus >> co

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Phillip Koebbe
I would be glad to help in this way, but it will have to be later today. And instead of using completely made-up code, I'll use some of my real-world code and tests as an example. I'll gist them later, unless one of the gurus comes along and provides enlightenment for you! I was able to ge

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Phillip Koebbe
On 2010-03-20 7:02 AM, Patrick J. Collins wrote: On Sat, 20 Mar 2010, Phillip Koebbe wrote: Welcome to RSpec, Patrick. For some of us, it's pretty rocky at first. I Thank you Phillip for your great explanation... After reading what you wrote, I have a few questions: 1. From what I

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Patrick J. Collins
On Sat, 20 Mar 2010, Phillip Koebbe wrote: > Welcome to RSpec, Patrick. For some of us, it's pretty rocky at first. I Thank you Phillip for your great explanation... After reading what you wrote, I have a few questions: 1. From what I understand of what you wrote, stub_model makes a fake objec

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Tom Stuart
Hi David, On 20 Mar 2010, at 10:42, David Chelimsky wrote: > There is an alternate syntax that I'm using nearly exclusively at this > point, which is to pass a block along with the stub() and > should_receive() messages: > [...] > I've been thinking of deprecating the and_xxx methods in rspec-2. D

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Patrick J. Collins
Hi David, > I've been thinking of deprecating the and_xxx methods in rspec-2. Does > anybody think that's an awful idea? Well I can tell you that this syntax you demonstrated: > foo.stub(:bar) { "return value" } > foo.stub(:bar) { raise SomeError } > foo.stub(:bar) { yield "value" } > fo

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Phillip Koebbe
There is an alternate syntax that I'm using nearly exclusively at this point, which is to pass a block along with the stub() and should_receive() messages: foo.stub(:bar) { "return value" } foo.stub(:bar) { raise SomeError } foo.stub(:bar) { yield "value" } foo.stub(:bar) { throw :v

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Phillip Koebbe
Welcome to RSpec, Patrick. For some of us, it's pretty rocky at first. I started using it a couple of years ago with models, and understood that well enough (I think). Then I came to controllers and I just couldn't wrap my mind around it. I gave up for quite some time. When I came back to testi

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread David Chelimsky
On Sat, Mar 20, 2010 at 2:28 AM, Patrick J. Collins wrote: > 4.  You do .stub! ...  This is where I get really > confused.  From the peepcode screencast that I have watched > several times, he explained that stubbing is the same as > mocking-- except there is no expectation of what it retu

Re: [rspec-users] lots of nil problems!

2010-03-20 Thread Patrick J. Collins
Hi Nick, Thank you very much for your reply. One thing I am finding incredibly frustrating with Rspec, is that I don't even know what questions to ask-- because I find the whole thing so confusing. So forgive me, but I am going to break down your code and ask specific questions to hopefully gain

Re: [rspec-users] lots of nil problems!

2010-03-19 Thread Nick Hoffman
Hey Patrick. > I have this in my controller action: > > from_address = Setting.find_by_name("shipping_from_address").address > > and my spec fails: > > NoMethodError in 'Admin::ShippingLabelsController should render a pdf > file' > undefined method `address' for nil:NilClass > > yet in the con

Re: [rspec-users] lots of nil problems!

2010-03-19 Thread Nick Hoffman
patrick99e99 wrote: >> Patrick, please create a new thread for this, since it doesn't have >> anything to do with the current topic. > > Wow that is weird.. I replied to the previous thread in my email > client but removed the subject-- as I assumed that was what kept > things associated with thr

[rspec-users] lots of nil problems!

2010-03-19 Thread patrick99e99
Hi, I have this in my controller action: from_address = Setting.find_by_name("shipping_from_address").address and my spec fails: NoMethodError in 'Admin::ShippingLabelsController should render a pdf file' undefined method `address' for nil:NilClass yet in the console I can do: >> Setting.fin

Re: [rspec-users] lots of nil problems!

2010-03-19 Thread patrick99e99
> Patrick, please create a new thread for this, since it doesn't have > anything to do with the current topic. Wow that is weird.. I replied to the previous thread in my email client but removed the subject-- as I assumed that was what kept things associated with threads; there was no other text

Re: [rspec-users] lots of nil problems!

2010-03-19 Thread Nick Hoffman
Patrick Collins wrote: > Hi, > > I have this in my controller action: > > from_address = Setting.find_by_name("shipping_from_address").address > > and my spec fails: > > NoMethodError in 'Admin::ShippingLabelsController should render a pdf > file' > undefined method `address' for nil:NilClass

[rspec-users] lots of nil problems!

2010-03-19 Thread Patrick J. Collins
Hi, I have this in my controller action: from_address = Setting.find_by_name("shipping_from_address").address and my spec fails: NoMethodError in 'Admin::ShippingLabelsController should render a pdf file' undefined method `address' for nil:NilClass yet in the console I can do: >> Setting.fin