Re: [rspec-users] rails rspec silently failing

2008-02-05 Thread Hans de Graaff
On Tue, 2008-02-05 at 23:50 -0500, Will Schenk wrote:
> This is both running the file directly or using script/spec.  If I
> leave the spec file as is, and I comment out a line
> @order.send_order_to_google_checkout in the _controller_ then it runs
> fine, i.e. it gets to the fail statement.

Since you don't include the actual controller code it's a bit hard to
help out here, but it's better form to just mock this code in your
controller spec. You can then vary the different responses from the
google checkout and see if your controller handles them correctly. 

The actual interaction with google checkout should be described with
examples in the order_spec.rb file. Right now you are testing the whole
stack and it becomes very hard to track down what is going wrong
exactly.

Kind regards,

Hans


signature.asc
Description: This is a digitally signed message part
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] rails rspec silently failing

2008-02-05 Thread Will Schenk
This is both running the file directly or using script/spec.  If I  
leave the spec file as is, and I comment out a line  
@order.send_order_to_google_checkout in the _controller_ then it runs  
fine, i.e. it gets to the fail statement.  Either way the code runs  
all the way through the action method.  But if I call a method on the  
Order, then it seems to just disappear after the controller returns.   
Something is swallowing exceptions or something like that.  It runs to  
the end though, and I know it runs to the end because I put in puts  
statements.



On Feb 5, 2008, at 7:54 PM, Corey Haines wrote:

That seems more like rspec isn't even finding it. What is the file  
name? Is it in a location that rspec is going to look for it?


-Corey

On Feb 5, 2008 4:58 PM, Will Schenk <[EMAIL PROTECTED]> wrote:
I've been beating my head against this for a couple of hours now, and
I'm a bit frustrated, so I apologize in advance.

I'm trying to use rspec to test an order processing system, which uses
google checkout.  The idea was to have a couple of orders in the
database in various stages, and hit the notifier interface to make
sure that everything transitioned to the right place.  However, I
can't get to this, because rspec seems to silently blow-up somewhere.
This code "passes":

require File.dirname(__FILE__) + '/../spec_helper'

describe OrdersController do
  integrate_views
  fixtures :orders

  it "should set the right order amount" do
prepare_order_mock

post "subscribe", {:sub_type => "1"}

fail "This should throw an error"
  end
end

It then returns: "0 examples, 0 failures".

How is such a thing possible?  This seems like a serious problem; I
would expect an exception from somewhere inside of the post, or the
fail message.  Instead everything is green.

My only hypothesis is that since I'm creating an order object and
calling a bunch of methods on it and somehow that's verbotten.  The
docs mention suggests mocking domain objects -- which seems if not
completely misguided at least seriously counter-intuitive -- and
perhaps this has something to do with it.  But silently imploding
seems more like a bug.

I should mention that the controller actually works in Real Life, but
I was trying to get a little piece of mind and work out all the
permutations in a test just to make sure.  And failing silently is
worse than no testing at all.

Taking a few deep breaths,
-w


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users



--
http://www.coreyhaines.com
The Internet's Premiere source of information about Corey Haines


Will Schenk
[EMAIL PROTECTED]
http://benchcoach.com/
http://sublimeguile.com/
http://menumap.monkeythumb.net/

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] rspec - rails put :update any examples

2008-02-05 Thread David Chelimsky
On Feb 5, 2008 6:42 PM, Corey Haines <[EMAIL PROTECTED]> wrote:
> David, I tried doing this, and I get an exception. Here's a pastie of the
> error, controller, controller_spec: http://pastie.caboo.se/148021

You've got page[:coupon_list], not just page. So what you need to mock is this:

page = mock("page")
page.should_receive(:[]).with(:coupon_list).and_return(page)
page.should_receive(:replace_html).with(:partial => "coupon_list")

That's starting to get a bit brittle, but that's what you get for
mixing all that view logic in your controllers. It's the Rails Way,
but it comes with a price if you want this level of coverage and
isolation.

FWIW,
David

>
>
>
> On Feb 5, 2008 2:02 AM, David Chelimsky <[EMAIL PROTECTED]> wrote:
>
> > it "should replace foo with bar partial" do
> >  page = mock("page")
> >  page.should_receive(:replace_html).with('foo', :partial => 'bar')
> >  controller.expect_render(:update).and_yield(page)
> >  do_post
> > end
> >
> > HTH,
> > David
> >
> > >
> > > Brian
> > >
> > >
> > > ___
> > > rspec-users mailing list
> > > rspec-users@rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/rspec-users
> > >
> > ___
> > rspec-users mailing list
> > rspec-users@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
>
>
> --
> http://www.coreyhaines.com
> The Internet's Premiere source of information about Corey Haines
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] rails rspec silently failing

2008-02-05 Thread Corey Haines
That seems more like rspec isn't even finding it. What is the file name? Is
it in a location that rspec is going to look for it?

-Corey

On Feb 5, 2008 4:58 PM, Will Schenk <[EMAIL PROTECTED]> wrote:

> I've been beating my head against this for a couple of hours now, and
> I'm a bit frustrated, so I apologize in advance.
>
> I'm trying to use rspec to test an order processing system, which uses
> google checkout.  The idea was to have a couple of orders in the
> database in various stages, and hit the notifier interface to make
> sure that everything transitioned to the right place.  However, I
> can't get to this, because rspec seems to silently blow-up somewhere.
> This code "passes":
>
> require File.dirname(__FILE__) + '/../spec_helper'
>
> describe OrdersController do
>   integrate_views
>   fixtures :orders
>
>   it "should set the right order amount" do
> prepare_order_mock
>
> post "subscribe", {:sub_type => "1"}
>
> fail "This should throw an error"
>   end
> end
>
> It then returns: "0 examples, 0 failures".
>
> How is such a thing possible?  This seems like a serious problem; I
> would expect an exception from somewhere inside of the post, or the
> fail message.  Instead everything is green.
>
> My only hypothesis is that since I'm creating an order object and
> calling a bunch of methods on it and somehow that's verbotten.  The
> docs mention suggests mocking domain objects -- which seems if not
> completely misguided at least seriously counter-intuitive -- and
> perhaps this has something to do with it.  But silently imploding
> seems more like a bug.
>
> I should mention that the controller actually works in Real Life, but
> I was trying to get a little piece of mind and work out all the
> permutations in a test just to make sure.  And failing silently is
> worse than no testing at all.
>
> Taking a few deep breaths,
> -w
>
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
http://www.coreyhaines.com
The Internet's Premiere source of information about Corey Haines
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] rspec - rails put :update any examples

2008-02-05 Thread Corey Haines
And, of course, here are my versions:

Ruby 1.8.6
Rails 2.0.2
Zentest 3.8
RSpec (I believe 1.1.2)


On Feb 5, 2008 7:42 PM, Corey Haines <[EMAIL PROTECTED]> wrote:

> David, I tried doing this, and I get an exception. Here's a pastie of the
> error, controller, controller_spec: http://pastie.caboo.se/148021
>
>
> On Feb 5, 2008 2:02 AM, David Chelimsky <[EMAIL PROTECTED]> wrote:
>
> > it "should replace foo with bar partial" do
> >  page = mock("page")
> >  page.should_receive(:replace_html).with('foo', :partial => 'bar')
> >  controller.expect_render(:update).and_yield(page)
> >  do_post
> > end
> >
> > HTH,
> > David
> >
> > >
> > > Brian
> > >
> > >
> > > ___
> > > rspec-users mailing list
> > > rspec-users@rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/rspec-users
> > >
> > ___
> > rspec-users mailing list
> > rspec-users@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
>
>
> --
> http://www.coreyhaines.com
> The Internet's Premiere source of information about Corey Haines




-- 
http://www.coreyhaines.com
The Internet's Premiere source of information about Corey Haines
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] rspec - rails put :update any examples

2008-02-05 Thread Corey Haines
David, I tried doing this, and I get an exception. Here's a pastie of the
error, controller, controller_spec: http://pastie.caboo.se/148021

On Feb 5, 2008 2:02 AM, David Chelimsky <[EMAIL PROTECTED]> wrote:

> it "should replace foo with bar partial" do
>  page = mock("page")
>  page.should_receive(:replace_html).with('foo', :partial => 'bar')
>  controller.expect_render(:update).and_yield(page)
>  do_post
> end
>
> HTH,
> David
>
> >
> > Brian
> >
> >
> > ___
> > rspec-users mailing list
> > rspec-users@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
http://www.coreyhaines.com
The Internet's Premiere source of information about Corey Haines
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] rails rspec silently failing

2008-02-05 Thread Will Schenk
I've been beating my head against this for a couple of hours now, and  
I'm a bit frustrated, so I apologize in advance.

I'm trying to use rspec to test an order processing system, which uses  
google checkout.  The idea was to have a couple of orders in the  
database in various stages, and hit the notifier interface to make  
sure that everything transitioned to the right place.  However, I  
can't get to this, because rspec seems to silently blow-up somewhere.   
This code "passes":

require File.dirname(__FILE__) + '/../spec_helper'

describe OrdersController do
   integrate_views
   fixtures :orders

   it "should set the right order amount" do
 prepare_order_mock

 post "subscribe", {:sub_type => "1"}

 fail "This should throw an error"
   end
end

It then returns: "0 examples, 0 failures".

How is such a thing possible?  This seems like a serious problem; I  
would expect an exception from somewhere inside of the post, or the  
fail message.  Instead everything is green.

My only hypothesis is that since I'm creating an order object and  
calling a bunch of methods on it and somehow that's verbotten.  The  
docs mention suggests mocking domain objects -- which seems if not  
completely misguided at least seriously counter-intuitive -- and  
perhaps this has something to do with it.  But silently imploding  
seems more like a bug.

I should mention that the controller actually works in Real Life, but  
I was trying to get a little piece of mind and work out all the  
permutations in a test just to make sure.  And failing silently is  
worse than no testing at all.

Taking a few deep breaths,
-w


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] DRb does not activate using options file

2008-02-05 Thread Edward Ocampo-gooding
On Jan 30, 2008 7:43 PM, Luis Lavena <[EMAIL PROTECTED]> wrote:
> Hello List,
>
> For a small project I've been using 'ruby script/spec -X spec' to
> execute my specs.
>
> Now that I added ZenTest on it, found that the test takes longer to
> run due the complete load of test environment.
>
> Since autotest uses 'script/spec -O spec/spec.opts' as the command, I
> decided to add --drb to spec.opts
>
> Using --drb or -X, spec_server is just ignored and environment get
> loaded locally.
>
> Trying to pinpoint the problem, it seems that using -O don't
> handle/load set --drb, but when you put all the options in the command
> line, works as expected.
>
> Couldn't find anything besides this 
> (rspec/lib/spec/runner/option_parser.rb:111)
>
> on(*OPTIONS[:drb]) {}
>
> ==
>
> Maybe I'm missing something, did anyone get it working?
>
> Thanks in advance,
> --
> Luis Lavena
> Multimedia systems
> -
> A common mistake that people make when trying to design
> something completely foolproof is to underestimate
> the ingenuity of complete fools.
> Douglas Adams
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

I'm also having this problem where --drb isn't being picked up.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] OT local version control?

2008-02-05 Thread Corey Haines
Thanks, Dan, I'll check that out.

-Corey

On Feb 5, 2008 5:19 AM, Dan North <[EMAIL PROTECTED]> wrote:

> Hi Corey.
>
> I recently discovered a rather excellent online book:
> http://hgbook.red-bean.com/
>
> It's about mercurial but it's a) largely scm-agnostic and b) really well
> written, with some useful diagrams about how changesets work in the small
> and collaboration models in the large (i.e. exactly what you were asking
> about).
>
> I also discovered a "deal-breaker" feature of mercurial that I hadn't
> realised before, which is that it tracks changes across copies and renames
> of files. Or rather, what I hadn't realised is that other SCMs don't do
> this. This was what was crippling me with subversion - I had a branch where
> I had done some quite aggressive refactoring (which means files getting
> moved and/or renamed), and subversion wouldn't merge the changes from the
> branch onto trunk.
>
>
> On 05/02/2008, Corey Haines <[EMAIL PROTECTED]> wrote:
> >
> > Thanks for the response, Luis.
> >
> > I'm going through the user manual, and it looks like I can set up a main
> > branch, make a clone, work on the clone with its own repository/revisions,
> > then merge the changes back to the main branch when I'm ready. I like the
> > idea of being able to work on several things at once. I'll let you guys know
> > how it goes.
> >
> > -Corey
> >
> >
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
http://www.coreyhaines.com
The Internet's Premiere source of information about Corey Haines
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] Spec::Runner.register_at_exit_hook in RSpec 1.1.3

2008-02-05 Thread Steve Hayes
David Chelimsky wrote:
> On Feb 4, 2008 11:15 PM, Steve Hayes <[EMAIL PROTECTED]> wrote:
>> In RSpec 1.1.3 this method is invoked from
>> Spec::Example::ExampleGroupMethods.inherited, but it no longer exists.
> 
> It most certainly does. In fact, it's new in 1.1.3, so neither the
> method nor the call existed prior. Any chance you have mixed versions
> floating around? 1.1.3 gem but older plugins?

That was probably it - apologies. I'm should see what I need to do to 
run without the gem at all.

Steve Hayes

-- 
Posted via http://www.ruby-forum.com/.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] OT local version control?

2008-02-05 Thread Dan North
Hi Corey.

I recently discovered a rather excellent online book:
http://hgbook.red-bean.com/

It's about mercurial but it's a) largely scm-agnostic and b) really well
written, with some useful diagrams about how changesets work in the small
and collaboration models in the large (i.e. exactly what you were asking
about).

I also discovered a "deal-breaker" feature of mercurial that I hadn't
realised before, which is that it tracks changes across copies and renames
of files. Or rather, what I hadn't realised is that other SCMs don't do
this. This was what was crippling me with subversion - I had a branch where
I had done some quite aggressive refactoring (which means files getting
moved and/or renamed), and subversion wouldn't merge the changes from the
branch onto trunk.

On 05/02/2008, Corey Haines <[EMAIL PROTECTED]> wrote:
>
> Thanks for the response, Luis.
>
> I'm going through the user manual, and it looks like I can set up a main
> branch, make a clone, work on the clone with its own repository/revisions,
> then merge the changes back to the main branch when I'm ready. I like the
> idea of being able to work on several things at once. I'll let you guys know
> how it goes.
>
> -Corey
>
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users