Re: [rspec-users] Assigning instance variable :expected and :got appear to be the same

2009-08-24 Thread David Chelimsky
On Mon, Aug 24, 2009 at 6:09 PM, jg wrote: > I have a very fairly simple spec > > it "should assign an instance variable" do >   get 'new' >   assigns[:city].should == City.new > end > > In my controller > > def new > �...@city = City.new > end > > but when I run it, I get > > 'CitiesController GET

[rspec-users] Assigning instance variable :expected and :got appear to be the same

2009-08-24 Thread jg
I have a very fairly simple spec it "should assign an instance variable" do get 'new' assigns[:city].should == City.new end In my controller def new @city = City.new end but when I run it, I get 'CitiesController GET 'new' should assign an instance variable' FAILED expected: #,

Re: [rspec-users] undefined method 'mock'

2009-08-24 Thread Jesterman81
Yeah, I'm an idiot. I was missing the whole 'it "should do something" do' line. Thanks for getting back so quick though! On Aug 23, 11:30 pm, David Chelimsky wrote: > On Sun, Aug 23, 2009 at 8:57 PM, Jesterman81 wrote: > > Greetings, > > > I am trying to use the mock method in rspec and it retu

Re: [rspec-users] Class instance variable scope with multiple spec files

2009-08-24 Thread Matt Wynne
On 24 Aug 2009, at 22:00, Gregory Hnatiuk wrote: Thanks. From a best-practices perspective, should a spec which changes something global change it back afterwards in general, or should it be the responsibility of a given spec to ensure the environment is appropriate itself before running exa

Re: [rspec-users] Class instance variable scope with multiple spec files

2009-08-24 Thread Gregory Hnatiuk
Thanks. >From a best-practices perspective, should a spec which changes something global change it back afterwards in general, or should it be the responsibility of a given spec to ensure the environment is appropriate itself before running examples (or both)? It seems like changing something glo

Re: [rspec-users] Class instance variable scope with multiple spec files

2009-08-24 Thread David Chelimsky
On Mon, Aug 24, 2009 at 2:19 PM, Gregory Hnatiuk wrote: > What is the expected/intended behavior for the scope of class instance > variables when running multiple specs? > > It appears that setting a class instance variable in one spec will > affect it in a second spec run like so: > > http://gist.

[rspec-users] Class instance variable scope with multiple spec files

2009-08-24 Thread Gregory Hnatiuk
What is the expected/intended behavior for the scope of class instance variables when running multiple specs? It appears that setting a class instance variable in one spec will affect it in a second spec run like so: http://gist.github.com/174018 running `spec spec1_spec.rb spec2_spec.rb` or `s

Re: [rspec-users] Problem Comparing Floats

2009-08-24 Thread Steve Schafer
On Mon, 24 Aug 2009 10:56:00 -0700, you wrote: >This will work (I'll go update the code now) but it still leaves the >problem I mentioned that if you are unfamiliar with the vagaries of >floating point math -- or even if you momentarily forget -- then using >== will occasionally mysteriously fail.

Re: [rspec-users] Problem Comparing Floats

2009-08-24 Thread Alex Chaffee
> What about a helpful error message when "should ==" fails on floats: > > expected 98.6, got 98.6 > > The expected and actual may appear to be the same due to Ruby's string > representation of floating point numbers. For floating point math, we > recommend using the be_close() matcher instead. > >

Re: [rspec-users] Problem Comparing Floats

2009-08-24 Thread David Chelimsky
On Mon, Aug 24, 2009 at 12:56 PM, Alex Chaffee wrote: > ...and, while I was composing that message, Brian sent me the following: > >> Rspec does provide the be_close matcher. See cheat rspec. > > @temperature.ctof(37).should be_close(98.6, 0.1) > > This will work (I'll go update the code now) but i

Re: [rspec-users] Problem Comparing Floats

2009-08-24 Thread Tom Stuart
On 24 Aug 2009, at 18:56, Alex Chaffee wrote: == will occasionally mysteriously fail. So my proposal remains: can the == matcher do be_close(x, 0.01) for floats? Arguments pro and con? The "problem" you describe is with Ruby's == operator, not with RSpec. The == matcher must agree with

Re: [rspec-users] Problem Comparing Floats

2009-08-24 Thread Alex Chaffee
...and, while I was composing that message, Brian sent me the following: > Rspec does provide the be_close matcher. See cheat rspec. @temperature.ctof(37).should be_close(98.6, 0.1) This will work (I'll go update the code now) but it still leaves the problem I mentioned that if you are unfamilia

[rspec-users] Problem Comparing Floats

2009-08-24 Thread Alex Chaffee
Check out the following gist: http://gist.github.com/173975 It's from a Test-Driven Intro To Ruby class I'm working on. Looks good, right? Not so fast. Check out this spec: it "converts body temperature" do t = @temperature.ctof(37) (t*10).round.should == 986 end Why do we