Re: [rspec-users] how to avoid tests removing data that my migrations put in?

2008-11-05 Thread Greg Hauptmann
how to I get a model statement to run within "test.rb" by the way? For example to get the following to run: RecurringType.create(:name => "TYPE_BASIC") If I just stick this in I get: extract-- Macintosh-2:myequity greg$ rake spec (in /Users/greg/source/m

Re: [rspec-users] Fwd: spec_server not working...

2008-11-05 Thread Glenn Ford
This is the same error that I get also. I'd love to get this working, Glenn On Oct 31, 2008, at 5:04 PM, Nick Hoffman wrote: On 2008-10-31, at 17:52, Matt Darby wrote: Same thing unfortunately. It also happens when I add --drb to spec/ spec.opts and run autotest/autospec as well. G'day Mat

Re: [rspec-users] rake features and cucumber feature/name not producing same result

2008-11-05 Thread Mikel Lindsaar
On Thu, Nov 6, 2008 at 2:53 AM, Joseph Wilk <[EMAIL PROTECTED]>wrote: > I'm getting expected: "1" >> got: "0" >> on a simple should change(Model, :count).by(1) >> >> It follows the specific model around as well. If I change order of the >> fit table or not (the fit table h

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Mark Wilden
On Wed, Nov 5, 2008 at 1:32 PM, Stephen Eley <[EMAIL PROTECTED]> wrote: > > It's not sufficient for that scenario, however, because that meteor > would probably take out your nearby external backup drive as well. That's a good point, which is why I didn't boast about my 1 TB Time Capsule. :) I

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Stephen Eley
On Wed, Nov 5, 2008 at 4:11 PM, Mark Wilden <[EMAIL PROTECTED]> wrote: > > Time Machine is especially cool because it backs up hourly. > > My criterion has always been, if a meteor annihilates my computer, how long > would it take to get back to work? No meteors yet, but better safe than > sorry.

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Mark Wilden
On Wed, Nov 5, 2008 at 12:39 PM, Stephen Eley <[EMAIL PROTECTED]> wrote: > > My point is that it did not take me days to recover from all this > screwiness. I was using Time Machine. I booted from the Leopard DVD, > said "Make it Wednesday again," and let it recopy my whole hard drive. > Time M

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
> This expectation: >@cart.should_receive(:amount=).with(50) > is what you really want, because it's ensuring that Order#amount= is > being called with the correct value. > > So, just remove the "should eql(50)" expectation, and you're all set! > -Nick You are perfectly right Nick, I had just

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:23, Fernando Perez wrote: Hmmm, I don't have this problem as I am using ruby-forum.com to browse threads, it is x100 times more readable with basic color highlighting. I'll do my best to include quotes for people who use regular mail clients. So here is my controller code: -

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Mark Wilden
On Wed, Nov 5, 2008 at 12:26 PM, Nick Hoffman <[EMAIL PROTECTED]> wrote: > On 2008-11-05, at 15:10, Mark Wilden wrote: > >> What I can't figure out is this: >> >> >> 1.day >> => 1 day >> >> >> 1.day.class >> => Fixnum >> >> I've no idea why 1.day.class returns Fixnum though.. > Yeah, I'd looked a

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Stephen Eley
On Wed, Nov 5, 2008 at 12:23 PM, Courtenay <[EMAIL PROTECTED]> wrote: > > Not sure if this is a python troll or not.. however, our biggest > problem was the development environment, not production. I hosed my development environment once. I did pair programming with a VIM junkie, and foolishly le

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:23, Fernando Perez wrote: This throws the error: expected 50, got 0 (using .eql?) This is because you told @cart to return 0 when #amount is called on it: @cart = mock_model(Order, :id => 1, :amount => 0, :tax => 0) I think maybe you're confusing what the arguments to #m

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:10, Mark Wilden wrote: What I can't figure out is this: >> 1.day => 1 day >> 1.day.class => Fixnum Is 1.day an ActiveSupport::Duration or a Fixnum? ///ark It's an ActiveSupport::Duration : 48 def days 49 ActiveSupport::Duration.new(self * 24.hours,

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
> Please make sure, when you ask a question, that you quote enough of > the thread so that the readers can understand what you're asking. Hmmm, I don't have this problem as I am using ruby-forum.com to browse threads, it is x100 times more readable with basic color highlighting. I'll do my best t

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:02, Ben Mabey wrote: Hey Nick, It is generally a bad idea to stub/mock a method on the object you are verifying the behaviour of. I would recommend a state-based approach of testing this method as opposed to the interaction-based one you are pursuing. The reason being

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 2:08 PM, Fernando Perez <[EMAIL PROTECTED]> wrote: >> @cart.should_receive(:amount=).with(50) >> >> amount and amount= are two different methods :) > > Thanks Dave! > > So now if I test for: @cart.amount.should eql(50) > > Why do I get this error: expected 50, got 0 (using .e

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 14:55, Fernando Perez wrote: And I get the following error message: -- Mock 'Order_1' received unexpected message :amount= with (50) -- Well I know that @cart.amount will be set to 50, but why is RSpec complaining about that? If I put @cart.should_receive(:amount).with(50), r

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Mark Wilden
On Wed, Nov 5, 2008 at 11:42 AM, David Chelimsky <[EMAIL PROTECTED]>wrote: > Looks like you can't stub anything on a Fixnum because of the way > RSpec's mocking works. > > >> require 'spec/mocks' > => true > >> 1.stub!(:foo) > TypeError: no virtual class for Fixnum > What I can't figure out is t

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
> @cart.should_receive(:amount=).with(50) > > amount and amount= are two different methods :) Thanks Dave! So now if I test for: @cart.amount.should eql(50) Why do I get this error: expected 50, got 0 (using .eql?) I have to add that the @cart is not saved in DB after its amount attribute is

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Ben Mabey
Nick Hoffman wrote: I had a look around for how to stub Time.now , #from_now , etc, and came across this, which was useful: http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/ Unfortunately, my situation is slightly different, and causes that solution to not be a

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 14:42, David Chelimsky wrote: The problem is there is no Singleton Class for 1, probably an efficiency in Ruby since 1 is, itself, a Singleton. All of these frameworks try to manipulate methods on the object's singleton class. So no mocking/stubbing on Fixnums. Apparently. Not

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 1:55 PM, Fernando Perez <[EMAIL PROTECTED]> wrote: > In have the following code: > > def index > @items = Item.find_for_payment(session[:order_id], @site.id) > @cart.amount = @items.sum { |item| item.price.to_i * > item.quantity.to_i } > end > > @cart is set by a before_fil

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
To make RSpec happy, I tried to test for the following: -- @cart.amount.should eql(50) -- And now I get: -- FAILED expected 50, got 0 (using .eql?) -- So is @cart.amount being set to 50 or not in the spec? When I test manually it works fine. -- Posted via http://www.ruby-forum.com/. __

[rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
In have the following code: def index @items = Item.find_for_payment(session[:order_id], @site.id) @cart.amount = @items.sum { |item| item.price.to_i * item.quantity.to_i } end @cart is set by a before_filter called find_cart which I stub. find_for_payment is stubbed too. In my spec I simply

Re: [rspec-users] how to avoid tests removing data that my migrations put in?

2008-11-05 Thread Pat Maddox
"Mark Wilden" <[EMAIL PROTECTED]> writes: > I'll just point out one more disadvantage of assuming the contents of the > test database are > correct (without 'rake db:test:prepare'). If you interrupt a test with Ctrl-C > (especially when > running autospec), it's possible for the transaction not

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 12:51 PM, Nick Hoffman <[EMAIL PROTECTED]> wrote: > I had a look around for how to stub Time.now , #from_now , etc, and came > across this, which was useful: > http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/ > > Unfortunately, my situation is

Re: [rspec-users] how to avoid tests removing data that my migrations put in?

2008-11-05 Thread Mark Wilden
I'll just point out one more disadvantage of assuming the contents of the test database are correct (without 'rake db:test:prepare'). If you interrupt a test with Ctrl-C (especially when running autospec), it's possible for the transaction not to get rolled back. An uncommitted transaction should g

Re: [rspec-users] how to avoid tests removing data that my migrations put in?

2008-11-05 Thread Pat Maddox
"Greg Hauptmann" <[EMAIL PROTECTED]> writes: > so is the concept to build up all seed data creation in one > place/method, & then for the rake spec case run this in via the "test" > environment.rb file? That sounds good. I typically put it in spec_helper.rb so all test-related stuff is in one pl

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Rick DeNatale
My 2 cents http://talklikeaduck.denhaven2.com/articles/2008/11/05/the-rspec-caboo-se-brouhaha -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/list

[rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
I had a look around for how to stub Time.now , #from_now , etc, and came across this, which was useful: http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/ Unfortunately, my situation is slightly different, and causes that solution to not be applicable. This is wh

Re: [rspec-users] Mulitbrowser selenium ruby

2008-11-05 Thread Togetherne Togetherne
Joseph Wilk wrote: > We run Integration tests across multi browsers simultaneously using > Selenium Grid. Perhaps you could use that (I believe it comes with ant > tasks that do some of the magic). Thanks Joseph i looked at selenium grid and it seems to be the answer to all my problems!! thank y

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Courtenay
On Wed, Nov 5, 2008 at 2:58 AM, Alex Satrapa <[EMAIL PROTECTED]> wrote: > On 05/11/2008, at 01:37 , Steven Baker wrote: > >> Big difference between "haven't been able to" and "wouldn't learn the >> tools". Ashley's post below sums it up best. This is a problem that's seen >> regularly when workin

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Ashley Moran
On 5 Nov 2008, at 14:28, Fernando Perez wrote: Hmmm, could you make a helper module and mix that into all three controllers? Then there'd be just one place to change it. Can you be more descriptive? Well I was just thinking out loud really. Something like module SubscriptionStuff def s

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Fernando Perez
> You're allowed to disagree :) > > Does what we're saying make sense to you? > Yes, my model classes were starting to get hard to read with method calling other methods calling other methods. Yes, we can change ;-) -- Posted via http://www.ruby-forum.com/. _

Re: [rspec-users] rake features and cucumber feature/name not producing same result

2008-11-05 Thread Joseph Wilk
I'm getting expected: "1" got: "0" on a simple should change(Model, :count).by(1) It follows the specific model around as well. If I change order of the fit table or not (the fit table has 20 rows of different models all being exercised the same way, they are part

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Andrew Premdas
Thanks David Just to confirm "up front" was not in any way meant to imply that the design is fixed or should not be refactored, or even will not need refactoring. Clarifying my point, 2) Use your tests/specs/stories/features combined with your experience to ensure you design an initial api that

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread MaurĂ­cio Linhares
I feel the same as Andrew, generalizing all calls to the model methods is bad, as you're making the simple (and common) complicated just to have the uncommon as possible. If you're making a big change as changing a method name and adding a new parameter, you're doing something new, it isn't the sa

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 9:42 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > Okay, I wanted to get some external point of views on an idea. Thanks > for your input. You're allowed to disagree :) Does what we're saying make sense to you? ___ rspec-users m

Re: [rspec-users] rake features and cucumber feature/name not producing same result

2008-11-05 Thread Mikel Lindsaar
On Wed, Nov 5, 2008 at 7:10 PM, Matt Wynne <[EMAIL PROTECTED]> wrote: > On 5 Nov 2008, at 03:58, Mikel Lindsaar wrote: > > If I run rake features or cucumber features/* I get one failing FIT >> scenario in one of my features. >> If I then run that feature that contains the FIT table with the faili

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Fernando Perez
Okay, I wanted to get some external point of views on an idea. Thanks for your input. -- 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] Design Pattern proposal for better Rails development

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 9:12 AM, Andrew Premdas <[EMAIL PROTECTED]> wrote: > What you are suggesting here changing your api to make it easier to refactor > your api. Your trying to do this by > > 1) Generalising the descriptivness of the api > 2) Reducing the number of calls to your api > > Both of

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Joseph Wilk
Fernando Perez wrote: I don't think this is a problem. Pat Don't you find it painful to go through each controller and/or each controller spec to correct the name of the method that has just changed? So you don't mind having to change in many different places should_receive(:find_if_p

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Andrew Premdas
What you are suggesting here changing your api to make it easier to refactor your api. Your trying to do this by 1) Generalising the descriptivness of the api 2) Reducing the number of calls to your api Both of these are not particularly good ideas 1) Generalising your api, reduces it descriptiv

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 8:53 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: >> I don't think this is a problem. >> >> Pat > > Don't you find it painful to go through each controller and/or each > controller spec to correct the name of the method that has just changed? > > So you don't mind having to

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 8:42 AM, Pat Maddox <[EMAIL PROTECTED]> wrote: > Fernando Perez <[EMAIL PROTECTED]> writes: > >>> Hmmm, could you make a helper module and mix that into all three >>> controllers? Then there'd be just one place to change it. >>> >> Can you be more descriptive? >> >> Let's sa

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Fernando Perez
> I don't think this is a problem. > > Pat Don't you find it painful to go through each controller and/or each controller spec to correct the name of the method that has just changed? So you don't mind having to change in many different places should_receive(:find_if_purchased) to should_rece

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Pat Maddox
Fernando Perez <[EMAIL PROTECTED]> writes: >> Hmmm, could you make a helper module and mix that into all three >> controllers? Then there'd be just one place to change it. >> > Can you be more descriptive? > > Let's say I have: > > def show > Subscription.find_if_purchased > ... > end > > de

Re: [rspec-users] how to stub the :current_user and any methods associated with it

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 8:22 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > Thanks for the clarification. And from now on I will quote previous > emails. Sorry man, but I'm laughing my ass off over this. Readers of this email will have no idea what I clarified for you because you *didn't quote th

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Pau Cor
Alex Satrapa wrote: > I can't understand why people who are serious about production > environment stability would install multiple applications in the same > environment. It's not healthy. One very nice way to do this is to run each app with its own user, then have a ~/.gems directory. Then you

Re: [rspec-users] how to stub the :current_user and any methods associated with it

2008-11-05 Thread Fernando Perez
Thanks for the clarification. And from now on I will quote previous emails. -- 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] Design Pattern proposal for better Rails development

2008-11-05 Thread Fernando Perez
> Hmmm, could you make a helper module and mix that into all three > controllers? Then there'd be just one place to change it. > Can you be more descriptive? Let's say I have: def show Subscription.find_if_purchased ... end def update Subscription.find_if_purchased ... end Now if I c

Re: [rspec-users] how to stub the :current_user and any methods associated with it

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 8:06 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > Actually, in a before(:each) block, the stubbing works. So why doesn't > it work with a before(:all)? Please, please, please quote the information from the previous email to which you are referring. I'll respond to your fi

Re: [rspec-users] how to stub the :current_user and any methods associated with it

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 8:05 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > I'm also having problems stubbing current_user. > > I cannot put > controller.stub!(:current_user).and_return(@current_user) > in a before(:all) block. The stubbing doesn't happen. Stubs and mocks get cleared out after ea

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Ashley Moran
On 5 Nov 2008, at 13:17, Fernando Perez wrote: Let's say I have a class method: Product.find_if_purchased(product_id, user_id) Let's say it is called in 3 different controllers. Hmmm, could you make a helper module and mix that into all three controllers? Then there'd be just one place to

Re: [rspec-users] how to stub the :current_user and any methods associated with it

2008-11-05 Thread Fernando Perez
Actually, in a before(:each) block, the stubbing works. So why doesn't it work with a before(:all)? -- 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] how to stub the :current_user and any methods associated with it

2008-11-05 Thread Fernando Perez
I'm also having problems stubbing current_user. I cannot put controller.stub!(:current_user).and_return(@current_user) in a before(:all) block. The stubbing doesn't happen. However if I put it in the it "should..." block, then it works. Why is that? -- Posted via http://www.ruby-forum.com/. _

Re: [rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 7:17 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > The biggest problems I have when developing (beside stupid typos) are: > 1) The name of a method which I often change to a supposedly more > descriptive name, which I will eventually change to an even more > supposedly des

[rspec-users] Design Pattern proposal for better Rails development

2008-11-05 Thread Fernando Perez
The biggest problems I have when developing (beside stupid typos) are: 1) The name of a method which I often change to a supposedly more descriptive name, which I will eventually change to an even more supposedly descriptive name 2) The arguments a method takes Let's say I have a class method: Pr

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Fernando Perez
> I'm learning Django at the moment, which is kinda like a Python-on- > Rails wannabe. Just to clear things out. Django is absolutely not a Python-on-Rails wannabe. See Rubies and Snakes conference for disambiguation. -- Posted via http://www.ruby-forum.com/.

Re: [rspec-users] no such file "spec/rake/spectask" even when rspec is install

2008-11-05 Thread David Chelimsky
On Wed, Nov 5, 2008 at 6:07 AM, Rob Lacey <[EMAIL PROTECTED]> wrote: > Hi there, > > I wonder if anyone can help, I've recently moved a project over from using > an old version of the rspec and rspec-rails plugins to using the gems. This > worked seamlessly for both myself and another colleague. Bu

[rspec-users] no such file "spec/rake/spectask" even when rspec is install

2008-11-05 Thread Rob Lacey
Hi there, I wonder if anyone can help, I've recently moved a project over from using an old version of the rspec and rspec-rails plugins to using the gems. This worked seamlessly for both myself and another colleague. But another colleague is now getting this problem. no such file "spec/rake

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Alex Satrapa
On 05/11/2008, at 01:37 , Steven Baker wrote: Big difference between "haven't been able to" and "wouldn't learn the tools". Ashley's post below sums it up best. This is a problem that's seen regularly when working with new ideas. How many times have you seen Agile blamed when a project f

Re: [rspec-users] Caboosers drop RSpec

2008-11-05 Thread Luis Lavena
On Tue, Nov 4, 2008 at 8:09 PM, Dr Nic <[EMAIL PROTECTED]> wrote: > On Nov 5, 1:55 am, "Luis Lavena" <[EMAIL PROTECTED]> wrote: >> Given a problem I have with RSpec >> And I post to the mailing list >> When noone answer my post >> And has been N days since I posted >> Then I start whining in my blo

Re: [rspec-users] rake features and cucumber feature/name not producing same result

2008-11-05 Thread Matt Wynne
On 5 Nov 2008, at 03:58, Mikel Lindsaar wrote: Hi all. If I run rake features or cucumber features/* I get one failing FIT scenario in one of my features. If I then run that feature that contains the FIT table with the failing scenario manually, it passes. I run it again with rake featu