[rspec-users] Specs for controllers and rescue_from

2010-11-20 Thread Nick Hoffman
Hey guys. My ApplicationController rescues Mongoid::Errors::DocumentNotFound errors like this: class ApplicationController < ActionController::Base rescue_from Mongoid::Errors::DocumentNotFound, :with => :resource_not_found protected def resource_not_found(error) flash[:alert] = t(

[rspec-users] Speccing the creation of a singleton resource

2010-04-20 Thread Nick Hoffman
Hey guys. I'm writing a Rails gem that's used by controllers. The gem creates a singleton resource at run-time, along the lines of: controller_name = ...dynamically generated... ActionController::Routing::Routes.draw do |map| map.resource controller_name, :only => :show end I'm trying to f

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

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

Re: [rspec-users] stub vs stub!

2010-03-19 Thread Nick Hoffman
Pat Maddox wrote: > I've never heard of CurbFu, but according to > http://github.com/gdi/curb-fu/blob/master/lib/curb-fu.rb#L43 it defines > a stub method already. So you're hitting that one, which expects two > arguments. stub! goes to RSpec's mocking framework. > > Pat Good catch! Thanks,

[rspec-users] stub vs stub!

2010-03-19 Thread Nick Hoffman
RSpec's changelog says that in version 1.2.5: "also alias_method :stub, :stub!, so you can stub with less bang" which I've been taking advantage of a lot. However, I just ran into a situation where using #stub caused an error to occur, and changing to #stub! caused the error the disappear. Any

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-15 Thread Nick Hoffman
emdub wrote: > I think what is easiest/cleanest in the code should prevail :) I > personally like "shared_examples_for", but can easily adapt to > whatever decision is made. > > On a semi-related note. Where do I require my shared specs so > it_should_behave_like can find my shared example groups?

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-07 Thread Nick Hoffman
David Chelimsky wrote: > So this presents an interesting problem :) > > My intent some time back was to deprecate :shared => true, not > share_examples_for (which is aliased with shared_examples_for). Based > on that, the rspec.info site is correct and Pat is incorrect. However, > Pat didn't know

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-06 Thread Nick Hoffman
Pat Maddox wrote: > describe "something something", :shared => true do > ... > end > > describe "chunky bacon" do > it_should_behave_like "something something" > end BTW, is rspec.info supposed to be up-to-date? It still recommends using "shared_examples_for". http://rspec.info/documentatio

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-06 Thread Nick Hoffman
Pat Maddox wrote: > describe "something something", :shared => true do > ... > end > > describe "chunky bacon" do > it_should_behave_like "something something" > end Thanks, mate. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing li

[rspec-users] Is share_examples_for deprecated?

2010-03-06 Thread Nick Hoffman
API Dock says that "share_examples_for" is deprecated. If that's correct, what should we be using instead? http://apidock.com/rspec/Spec/Extensions/Main/share_examples_for Thanks, Nick -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing l

[rspec-users] GET a path in a controller spec

2010-01-31 Thread Nick Hoffman
One of my controller actions sends a redirect if the request URI begins with /foods/search 34 def search 35return redirect_to "/#{params[:name]}" if request.request_uri.match /^\/foods\/search/ Unfortunately, I can't figure out how to spec this. >From everything that I've read while res

Re: [rspec-users] Troubles with route_for

2010-01-23 Thread Nick Hoffman
Hey guys. I have two different paths that lead to the same controller and action: map.connect 'foods/search/:name', :controller => 'foods', :action => 'search' map.food':name', :controller => 'foods', :action => 'search' Unfortunately, the spec for the second route fails be

Re: [rspec-users] Troubles with route_for

2010-01-13 Thread Nick Hoffman
David Chelimsky wrote: > On Wed, Jan 13, 2010 at 10:20 AM, Nick Hoffman > wrote: > >> > Yes - route_to checks both sides of the translation. >> >> Great, thanks for that, David! > > > Thank Randy Harmon for this one. It was he who recognized and solve

Re: [rspec-users] Troubles with route_for

2010-01-13 Thread Nick Hoffman
David Chelimsky wrote: > On Tue, Jan 12, 2010 at 11:35 AM, Nick Hoffman > wrote: > >> By the way, does this spec: >>{:get => '/path'}.should route_to(...) >> make this spec redundant?: >>params_from(:get, '/path').should

Re: [rspec-users] Troubles with route_for

2010-01-12 Thread Nick Hoffman
By the way, does this spec: {:get => '/path'}.should route_to(...) make this spec redundant?: params_from(:get, '/path').should == {...} They read the same, but it feels like they each check one end of the route's translation. -- Posted via http://www.ruby-forum.com/. ___

Re: [rspec-users] Troubles with route_for

2010-01-12 Thread Nick Hoffman
Randy Harmon wrote: > On 1/11/10 9:22 PM, Nick Hoffman wrote: >>> Cheers, >>> David >>> >> Thanks for that, David. I updated my spec (http://codepad.org/F828X7Fg). >> For some reason though, it's still failing: http://codepad.org/s65Ckubc >&

Re: [rspec-users] Troubles with route_for

2010-01-11 Thread Nick Hoffman
David Chelimsky wrote: > I'd recommend using the route_to matcher that was added in 1.2.9 > instead. > > http://codepad.org/fLcxyA9N > http://rspec.rubyforge.org/rspec-rails/1.2.9/classes/Spec/Rails/Matchers.html#M29 > > It's more reliable, and aligns better with the rspec matchers API. > >

Re: [rspec-users] Troubles with route_for

2010-01-10 Thread Nick Hoffman
Amit Kulkarni wrote: > Nick Hoffman wrote: >> Hey guys. I'm having some trouble with a route spec. In routes.rb , I >> have: >> map.connect 'foods/search/:name', :controller => :foods, :action => >> :search >> >> foods_controller_spe

[rspec-users] Troubles with route_for

2010-01-10 Thread Nick Hoffman
Hey guys. I'm having some trouble with a route spec. In routes.rb , I have: map.connect 'foods/search/:name', :controller => :foods, :action => :search foods_controller_spec.rb has: http://codepad.org/dg3FERKw Unfortunately, that fails: http://codepad.org/lck4r1S0 After reading the rspec-rail

Re: [rspec-users] RSpec with Sinatra

2009-08-07 Thread Nick Hoffman
On Fri, Aug 7, 2009 at 9:55 AM, Nick Hoffman wrote: > Hey guys. I'm building an app in Sinatra, and am having some trouble > writing a controller spec. It seems that #get isn't known: > > NoMethodError in 'server shows the index page' > undefined method `get

[rspec-users] RSpec with Sinatra

2009-08-07 Thread Nick Hoffman
Hey guys. I'm building an app in Sinatra, and am having some trouble writing a controller spec. It seems that #get isn't known: NoMethodError in 'server shows the index page' undefined method `get' for # I've pasted the spec, spec_helper, etc here, in case it's of any help: http://pastie.org/5746

Re: [rspec-users] Rspec book review...

2009-07-23 Thread Nick Hoffman
On Thu, Jul 23, 2009 at 5:58 PM, Chris Sund wrote: > Hey everyone, > > I just thought I would provide some feedback on my experience with the > rspec book - I "just" finished it. ..snip.. > In any case, the book was great, I want to thank everyone that wrote > it, and a special thanks to Ben Mabey

Re: [rspec-users] Class method not being stubbed

2009-05-28 Thread Nick Hoffman
On Sun, May 24, 2009 at 3:25 PM, Rick DeNatale wrote: > One thing which strikes me is that if Rails naming conventions were > being followed: > >  1) the file name be lib/ad_sense_heaven_parser not lib/adsense_heaven_parser >  2) the require wouldn't be needed since it would be autoloaded. > > Per

Re: [rspec-users] spec for authenticated user

2009-05-28 Thread Nick Hoffman
> -Original Message- > From: rspec-users-boun...@rubyforge.org > [mailto:rspec-users-boun...@rubyforge.org] On Behalf Of David Chelimsky > Sent: Wednesday, May 27, 2009 5:55 PM > To: rspec-users > Subject: Re: [rspec-users] spec for authenticated user >>   before_filter :requires_user, >>

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 3:25 PM, Rick DeNatale wrote: >> However, that doesn't really matter. The call to #require shouldn't >> happen, because the method is supposed to be stubbed out. > > No that's what confused me. > > class KeywordListsController < ApplicationController > ... >   private > ...

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
>> Hi Fernando. I'm not sure what you mean by "the code never gets out of >> this require statement". > I should have said 'the interpreter never ...' Ah, I understand what you mean now. >> However, that doesn't really matter. The call to #require shouldn't >> happen, because the method is suppos

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 2:13 PM, Fernando Perez wrote: >> Hi Fernando. In this case, I don't think it's a matter of using the >> debugger. > > I suspect a problem in: require 'lib/adsense_heaven_parser', the code > maybe never gets out of this require statement. The debugger would allow > you to i

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 1:10 PM, Rick DeNatale wrote: > On Sun, May 24, 2009 at 12:25 PM, Nick Hoffman wrote: >> Hi guys. I'm setting an expectation on a class method. For some >> reason, the method isn't being stubbed, and the expectation isn'

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 12:49 PM, Fernando Perez wrote: >> I've been beating my head against this for a couple of hours. Any >> thoughts? > The easiest for you is to use the debugger and go through each line in > the controller. > > Maybe @keyword_list.save is returning false? Stub it out and see

[rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
Hi guys. I'm setting an expectation on a class method. For some reason, the method isn't being stubbed, and the expectation isn't seeing the call. In KeywordListsController#create, I call the private method #create_keywords_and_associate, which calls AdSenseHeavenParser#parse . Thus, some of my s

Re: [rspec-users] [rspec] Stubbing partials in view specs

2009-03-19 Thread Nick Hoffman
> Basically, there are two situation. > 1) I want to check if a function was called and I want to execute the > function code I don't think that's possible. Setting a method expectation (Eg: template.should_receive(:render)) automatically stubs #render. > 2) I want to check if a function was call

Re: [rspec-users] [rspec] Stubbing partials in view specs

2009-03-18 Thread Nick Hoffman
Hey there Evgeny. My response is inline. > I call a partial inside another partial. > _mother.haml contains: > render :partial => "children/child" > In mother_spec.rb file I am trying to stub the render call. > Here is a working version: > = >    template.should_receive(:render) >    

Re: [rspec-users] Testing return value of a block argument

2009-03-16 Thread Nick Hoffman
On Mon, Mar 16, 2009 at 7:00 AM, Yun Huang Yong wrote: > Hi, > > I'm using Log4r and one of its neat features is its handling of blocks such > that you can do: >  log.debug { "Something bad happened" + some_expensive_method() } > instead of: >  log.debug("Something bad happened" + some_expensive_m

Re: [rspec-users] OT: AR Default Values

2009-03-05 Thread Nick Hoffman
On Wed, Mar 4, 2009 at 2:58 PM, James Byrne wrote: > Scott Taylor wrote: > >> You could try this plugin: >> >> http://github.com/aussiegeek/active_record_defaults/tree/master >> >> Scott > > Thanks, I will try this out. Hi James. Just a quick message to let you know that I've used active_record_d

Re: [rspec-users] [RSpec][RJS] Problem with specing create.rjs in controller_spec

2009-02-26 Thread Nick Hoffman
On 26/02/2009, at 11:25 AM, David Chelimsky wrote: On Thu, Feb 26, 2009 at 10:01 AM, Evgeny Bogdanov wrote: Could somebody please explain me what I am doing wrong. I am trying to spec create.rjs file, that is returned from my controller. render_template("create.rjs") works just fine, however

Re: [rspec-users] Testing User Agent

2009-02-25 Thread Nick Hoffman
On 25/02/2009, at 9:49 PM, Suprie Leonhart wrote: On Thu, Feb 26, 2009 at 4:39 AM, Nick Hoffman wrote: Hi Suprie. AFAIK, RSpec populates the "request" object in your specs after a controller action is called. Since your "should know if it's from blackberry&quo

Re: [rspec-users] Testing User Agent

2009-02-25 Thread Nick Hoffman
On 25/02/2009, at 4:51 AM, Suprie Leonhart wrote: On Wed, Feb 25, 2009 at 4:19 PM, David Chelimsky wrote: On Wed, Feb 25, 2009 at 1:57 AM, Suprie Leonhart wrote: > hi > > i'm testing some lib i've made for detecting mobile user agent, I confused > how to test the lib i've made. > the test

Re: [rspec-users] send_file testing

2009-02-24 Thread Nick Hoffman
On 24/02/2009, at 8:03 AM, vo.x wrote: On 23 Ún, 18:41, Nick Hoffman wrote: On 22/02/2009, at 3:34 PM, vo.x wrote: Hello all, Is there some best practice how to test Rails controller action which is using send_file method? Could you help me please? Vit On 23/02/2009, at 2:43 AM

Re: [rspec-users] send_file testing

2009-02-23 Thread Nick Hoffman
On 22/02/2009, at 3:34 PM, vo.x wrote: Hello all, Is there some best practice how to test Rails controller action which is using send_file method? Could you help me please? Vit On 23/02/2009, at 2:43 AM, vo.x wrote: Just to be clear, this is how the action looks: def download log = Act

Re: [rspec-users] [RSpec] #and_raise

2009-02-18 Thread Nick Hoffman
On 16/02/2009, at 4:12 PM, David Chelimsky wrote: On Mon, Feb 16, 2009 at 1:48 PM, Nick Hoffman wrote: I often use #and_raise like so: @error_message = 'Some error' @sf.should_receive(:shift_time!).and_raise @error_message However, after trying to do this: @argument_error =

[rspec-users] [RSpec] #and_raise

2009-02-16 Thread Nick Hoffman
I often use #and_raise like so: @error_message = 'Some error' @sf.should_receive(:shift_time!).and_raise @error_message However, after trying to do this: @argument_error = mock_model ArgumentError, :message => @error_message @sf.should_receive(:shift_time!).and_raise @argument_error and th

Re: [rspec-users] Testing misc methods in ApplicationController

2009-02-13 Thread Nick Hoffman
On 13/02/2009, at 7:26 PM, Fernando Perez wrote: How do you spec protected controller methods such as before_filters and helpers that with the params and session hashes? I cannot call controller.my_method if my_method is protected. Try this: controller.andreplace("foo and bar").should eql("

Re: [rspec-users] Is #valid? automatically called?

2009-02-13 Thread Nick Hoffman
On 12/02/2009, at 2:59 PM, David Chelimsky wrote: On Feb 12, 2009, at 1:03 PM, Nick Hoffman wrote: Does RSpec automatically call #valid? on ActiveRecord models? For instance, when this example is run: it 'should reject a nil value' do @form = TimeShiftForm.new :file =&

[rspec-users] Is #valid? automatically called?

2009-02-12 Thread Nick Hoffman
Does RSpec automatically call #valid? on ActiveRecord models? For instance, when this example is run: it 'should reject a nil value' do @form = TimeShiftForm.new :file => nil puts "@form.errors.count = <<#...@form.errors.count}>>" @form.should have(1).error_on :file puts "@form.errors.c

Re: [rspec-users] [RSpec] mock_model not returning a mock

2009-02-12 Thread Nick Hoffman
Ack, that subject is completely wrong! I forgot to update it after re- writing the email. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] [RSpec] mock_model not returning a mock

2009-02-12 Thread Nick Hoffman
I'm experiencing some strange behaviour with an ActiveRecord model object. I'm trying to spec that a mocked AR object, @form, has an error on the "file" attribute. I've confirmed that there *is* an error on the "file" attribute, because I print out the error. However, the spec fails, sayi

Re: [rspec-users] Problem with refresh_specs

2009-02-12 Thread Nick Hoffman
On 31/01/2009, at 1:45 AM, jschank wrote: Hello, I recently unpacked the latest (1.1.12) rspec and rspec rails in my applicaiton. When I run my specs I get: config.gem: Unpacked gem rspec-1.1.12 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. config.gem: Unpa

Re: [rspec-users] exemplary way to show a list is sorted?

2009-02-11 Thread Nick Hoffman
On 10/02/2009, at 10:09 PM, James Byrne wrote: Zach Dennis wrote: On Tue, Feb 10, 2009 at 6:22 PM, James Byrne wrote: David Chelimsky wrote: please use "should be >=" as "should >=" will eventually be deprecated and removed. Removed? You are not seriously contemplating forcing people

Re: [rspec-users] Rspec approach to test model

2009-02-11 Thread Nick Hoffman
On 11/02/2009, at 8:51 AM, Kaleem Ullah wrote: Hi, I am quite new to Rspec. I want to use Rspec to test my existing Code. I start from Models (Unit Testing). Here i want your help on a issue. Here is model/user_spec.rb describe User do before(:each) do @user=User.new @user.id='2'

Re: [rspec-users] step definitons to check login

2009-02-09 Thread Nick Hoffman
On 17/12/2008, at 9:56 AM, James Byrne wrote: Re: authlogin Can someone familiar with this gem explain where and how the user_sessions are maintained? I have pawed through the code but it has left me rather more confused than not. The best inkling I can arrive at is that the authlogic pe

Re: [rspec-users] [RSpec] Setting a gem dep on rspec-rails

2009-02-09 Thread Nick Hoffman
On 08/02/2009, at 4:39 PM, Matt Wynne wrote: On 7 Feb 2009, at 19:02, David Chelimsky wrote: On Sat, Feb 7, 2009 at 12:27 PM, Pat Maddox wrote: On Sat, Feb 7, 2009 at 9:30 AM, Nick Hoffman wrote: With that said, I'm wondering what the accepted way to setup gem dependencies on rspe

Re: [rspec-users] How to spec within a block?

2009-02-08 Thread Nick Hoffman
On 08/02/2009, at 7:44 AM, Remi Gagnon wrote: I want to mock to Model.to_xml but not his block. How to do it? Here is what I have (sorry for the formatting) output = @detenteur.to_xml( :skip_types => false, :skip_instruct => true, :dasherize => false, :only => [:inte_no] ) do |xml_de

Re: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing)

2009-02-08 Thread Nick Hoffman
On 07/02/2009, at 10:45 PM, David Chelimsky wrote: On Sat, Feb 7, 2009 at 8:05 PM, Nick Hoffman wrote: On 07/02/2009, at 1:16 PM, David Chelimsky wrote: On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman wrote: When writing Cucumber stories and features for controllers, should you cover

Re: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing)

2009-02-07 Thread Nick Hoffman
On 07/02/2009, at 1:16 PM, David Chelimsky wrote: On Sat, Feb 7, 2009 at 9:59 AM, Nick Hoffman wrote: When writing Cucumber stories and features for controllers, should you cover every edge case? For example, should you write stories that feed bad or missing data to your controllers, or

Re: [rspec-users] [RSpec] Setting a gem dep on rspec-rails

2009-02-07 Thread Nick Hoffman
On 07/02/2009, at 12:30 PM, Nick Hoffman wrote: For a while now, I've had the following in config/environment.rb : config.gem 'haml' config.gem 'rspec', :lib => 'spec' config.gem 'rspec-rails', :lib => 'spec/rails' I just tried run

[rspec-users] [RSpec] Setting a gem dep on rspec-rails

2009-02-07 Thread Nick Hoffman
For a while now, I've had the following in config/environment.rb : config.gem 'haml' config.gem 'rspec', :lib => 'spec' config.gem 'rspec-rails', :lib => 'spec/rails' I just tried running the Rails console in production mode, and this warning occured: irb: warn: can't alias context from irb_

Re: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing)

2009-02-07 Thread Nick Hoffman
On 06/02/2009, at 10:00 PM, s.ross wrote: I did stop writing new controller specs, but we were discussing the use-case for controller specs in the new Cukified world. Supposing you write scenarios that pretty much describe your app, what could possibly go wrong that a controller spec would c

Re: [rspec-users] OK... What is ... fu ?

2009-01-30 Thread Nick Hoffman
On 30/01/2009, at 9:49 AM, James Byrne wrote: Pardon my ignorance, but exactly what does _fu mean WRT Ruby plugins, gems and such? I have run across this suffix a number of times in Ruby and Rails, always in connection with some add-on or extension. In the original context that I encountered '_

Re: [rspec-users] simple == with prettier error messages + good documentation

2009-01-29 Thread Nick Hoffman
On 29/01/2009, at 4:27 PM, aslak hellesoy wrote: On Thu, Jan 29, 2009 at 10:14 PM, David Chelimsky > wrote: On Thu, Jan 29, 2009 at 2:38 PM, Nick Hoffman wrote: I like "on_failure", as it's consistent with RSpec's output. Eg: 31 examples, 0 failures What could be don

Re: [rspec-users] simple == with prettier error messages + good documentation

2009-01-29 Thread Nick Hoffman
On 29/01/2009, at 2:18 PM, David Chelimsky wrote: On Thu, Jan 29, 2009 at 1:02 PM, aslak hellesoy > wrote: On Thu, Jan 29, 2009 at 7:25 PM, David Chelimsky wrote: > > > On Thu, Jan 29, 2009 at 12:00 PM, wrote: >> >> Hi all, >> >> I've found myself writing a thing I think is less than optimal,

Re: [rspec-users] Strange message expectation behaviour with Time.now in a find condition

2009-01-29 Thread Nick Hoffman
On 29/01/2009, at 1:41 PM, David Chelimsky wrote: On Thu, Jan 29, 2009 at 12:08 PM, tatyree wrote: Even if this is a bug, it's a pretty obscure one. It was frustrating the hell out of me until I found a workaround, so I thought I'd just post the details: Given a find like this: def self.find_

Re: [rspec-users] simple == with prettier error messages + good documentation

2009-01-29 Thread Nick Hoffman
On 29/01/2009, at 1:00 PM, r_j_h_box...@yahoo.com wrote: Hi all, I've found myself writing a thing I think is less than optimal, looking for suggestions. The context is, I'm testing a result, and as a part of that test, I might verify two or three things, which are individually relevant b

Re: [rspec-users] [ANN] The RSpec Book is now in beta

2009-01-29 Thread Nick Hoffman
On 29/01/2009, at 10:36 AM, David Chelimsky wrote: I’m pleased to announce the beta release of the Pragmatic Bookshelf’s The RSpec Book: Behaviour Driven Development with RSpec, Cucumber and Friends! It’s been a long time coming, and there’s still a lot of work to do to get to print. The b

Re: [rspec-users] [RSpec] Error when returning multiple values from a stub

2009-01-28 Thread Nick Hoffman
On 27/01/2009, at 11:03 AM, Nick Hoffman wrote: Hey guys. I've just found some odd behaviour within RSpec 1.1.12 , and would like to know whether this is a bug, or I'm doing something wrong. When I give multiple return values to a stub, like this: SubtitleFile.stub!(:new).and_r

Re: [rspec-users] [RSpec] Cloning objects and leaking state

2009-01-28 Thread Nick Hoffman
On 28/01/2009, at 12:16 PM, Pat Maddox wrote: If it doesn't automatically clone (it may, I don't know), it probably should provide a lambda syntax so you can do: default :subtitles => lambda { [] } Yeah, I just looked at the code for ARD and this is the problem. You can pass in immutable objec

Re: [rspec-users] [RSpec] Cloning objects and leaking state

2009-01-28 Thread Nick Hoffman
On 28/01/2009, at 12:12 PM, Pat Maddox wrote: On Wed, Jan 28, 2009 at 8:30 AM, Nick Hoffman wrote: On 28/01/2009, at 7:50 AM, Zach Dennis wrote: On Tue, Jan 27, 2009 at 2:48 PM, Nick Hoffman wrote: G'day folks. I've been beating my head on this one problem for a couple of

Re: [rspec-users] [RSpec] Cloning objects and leaking state

2009-01-28 Thread Nick Hoffman
On 28/01/2009, at 7:50 AM, Zach Dennis wrote: On Tue, Jan 27, 2009 at 2:48 PM, Nick Hoffman wrote: G'day folks. I've been beating my head on this one problem for a couple of hours, and have managed to figure out what's causing it. However, I don't understand why it&#

Re: [rspec-users] [RSpec] Cloning objects and leaking state

2009-01-27 Thread Nick Hoffman
On 27/01/2009, at 7:44 PM, David Chelimsky wrote: On Tue, Jan 27, 2009 at 1:48 PM, Nick Hoffman wrote: G'day folks. I've been beating my head on this one problem for a couple of hours, and have managed to figure out what's causing it. However, I don't understand why it

[rspec-users] [RSpec] Cloning objects and leaking state

2009-01-27 Thread Nick Hoffman
G'day folks. I've been beating my head on this one problem for a couple of hours, and have managed to figure out what's causing it. However, I don't understand why it's happening, nor do I know how to solve or get around it. One of my methods clones an arg, and it seems that doing so causes

Re: [rspec-users] [RSpec] Error when returning multiple values from a stub

2009-01-27 Thread Nick Hoffman
On 27/01/2009, at 11:03 AM, Nick Hoffman wrote: Hey guys. I've just found some odd behaviour within RSpec 1.1.12 , and would like to know whether this is a bug, or I'm doing something wrong. When I give multiple return values to a stub, like this: SubtitleFile.stub!(:new).and_r

[rspec-users] [RSpec] Error when returning multiple values from a stub

2009-01-27 Thread Nick Hoffman
Hey guys. I've just found some odd behaviour within RSpec 1.1.12 , and would like to know whether this is a bug, or I'm doing something wrong. When I give multiple return values to a stub, like this: SubtitleFile.stub!(:new).and_return @sf1, @sf2 RSpec complains: Mock 'SubtitleFile_1001' re

Re: [rspec-users] Best way to spec nested modules?...

2009-01-26 Thread Nick Hoffman
On 25/01/2009, at 9:56 PM, Stuart Hungerford wrote: Hi, I've got a set of classes in nested Ruby modules which I'm using rspec to specify: module Foo module Baz class C1 ... end class C2 ... end end end To specify C2 behaviour I need to create a bunch of C1 instances:

Re: [rspec-users] [Cucumber, BDD] When not to use Cucumber?

2009-01-23 Thread Nick Hoffman
On 23/01/2009, at 12:04 PM, Ben Mabey wrote: So... I'm curious what people's thoughts are. When writing acceptance tests how do you choose which tool is best for the job? I often hear people complaining about the GWT syntax and they see no benefit of it over the frameworks that provide con

[rspec-users] [RSpec] Message expectations and #dup / #clone

2009-01-19 Thread Nick Hoffman
Can anyone confirm that message expectations are not copied/duplicated to the new object when using Object#dup or #clone ? Thanks! Nick ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] Putting shared specs in a separate file

2009-01-17 Thread Nick Hoffman
On 2009-01-17, at 14:16, LesFreeman wrote: Hello, I am trying to move shared specs out of my spec_helper and into separate files. I found an article about the process here:http:// blog.kineticweb.com/articles/2008/04/15/automagical-rspec-shared- example-loading-from-separate-files Essentially, I

Re: [rspec-users] Testing file attachment with Paperclip

2009-01-17 Thread Nick Hoffman
On 2009-01-17, at 05:10, Fernando Perez wrote: G'day again Fernando. IIRC, Paperclip's #save_attached_files is what takes care of saving the attachment to disk, uploading it to S3, etc. Here's a small gist that tests the allowance of JPG files, and ensures that the file isn't saved [to disk, f

Re: [rspec-users] Testing file attachment with Paperclip

2009-01-16 Thread Nick Hoffman
On 2009-01-16, at 17:42, Fernando Perez wrote: Nicholas Wieland wrote: Does someone have an example on faking a file upload for just ensuring it gets called, without actually uploading the file to s3. I thought that stubbing Model.has_attached_file would be enough, but it doesn't seem so ...

Re: [rspec-users] newbie: errors getting started with cucumber

2009-01-16 Thread Nick Hoffman
On 2009-01-16, at 17:19, Fernando Perez wrote: Aslak Hellesøy wrote: On Thu, Dec 25, 2008 at 2:04 PM, Manasi Vora wrote: I am using webrat 0.3.2 cucumber 0.1.13 activerecord 2.1.1 You need a newer webrat - for example gem install aslakhellesoy- webrat Aslak Thanks that help me out. I

[rspec-users] Which webrat gem should be used?

2009-01-15 Thread Nick Hoffman
Hi guys. Which webrat gem should be used? There seem to be a few: $ gem search -r webrat *** REMOTE GEMS *** aslakhellesoy-webrat (0.3.2.2) benschwarz-webrat (0.3.2.1) brynary-webrat (0.3.2.2) flazz-webrat (0.3.2.1) mfilej-webrat (0.2.1) webrat (0.3.4)

Re: [rspec-users] Cucumber HTML in IE6

2009-01-15 Thread Nick Hoffman
On 2009-01-15, at 11:35, aslak hellesoy wrote: On Thu, Jan 15, 2009 at 5:18 PM, aidy lewis wrote: Hi, The users are using IE6. The Cucumber HTML appears fine in firefox, opera, IE7 etc. However, I am not receiving any colouring in IE6. I put the cucumber.css through the w3c validator and no

[rspec-users] Example on the Cucumber home page

2009-01-14 Thread Nick Hoffman
Great work on the logo and website, Aslak & Co! It looks great, and and the prominent six steps to using Cucumber is exactly what newbs. I have one question about step #2. The Given-block initialises a new Calculator each time it's run. This would cause the "Given I have entered 50 into th

Re: [rspec-users] Rspec Rails high overhead

2009-01-04 Thread Nick Hoffman
On 2009-01-03, at 23:17, Mark Wilden wrote: On Sat, Jan 3, 2009 at 6:58 PM, Reza Primardiansyah > wrote: I found out that running RSpec on Rails takes too much overhead. It takes more than 16s per run although the specs only take less than 6s, like seen below. The killer is the time it tak

Re: [rspec-users] testing call to super in rails helper

2008-12-09 Thread Nick Hoffman
On 2008-12-09, at 06:29, Ivor Paul wrote: Hi I have the following code: def will_paginate(items, options = {}) options = options.merge(:container => true, :class => 'paging') super(items, options) end I am curious about how to test that the call to super is infact being called wi

Re: [rspec-users] NameError when passing a URL helper to a method

2008-12-05 Thread Nick Hoffman
On 2008-12-04, at 19:56, Pat Maddox wrote: Nick Hoffman <[EMAIL PROTECTED]> writes: On 2008-12-04, at 17:43, Nick Hoffman wrote: The only solution that I can think of is to do this: before :each do @account_url = account_url end it_should_redirect_to 'the account page

Re: [rspec-users] proxy associantion on controllers

2008-12-05 Thread Nick Hoffman
On 2008-12-05, at 10:06, Daniel Lopes wrote: Thanks for help and sorry for insistance but I don't understand aspects on rspec ( I think not understand how we use mocks and stubs): Hi Daniel. If you're a bit unsure about when to use mocks vs stubs, have a read of this article by Martin Fowler

Re: [rspec-users] Rails project as a template for other projects (off topic)

2008-12-05 Thread Nick Hoffman
On 2008-12-05, at 01:51, Andrew Premdas wrote: Scott Working on this, assuming I have a cloned project 'foo' from my base project base and I'm working on foo. So I implement something new and then think this should be in base any ideas how to manage this. Was thinking maybe of having a bas

Re: [rspec-users] NameError when passing a URL helper to a method

2008-12-04 Thread Nick Hoffman
On 2008-12-04, at 17:43, Nick Hoffman wrote: The only solution that I can think of is to do this: before :each do @account_url = account_url end it_should_redirect_to 'the account page', @account_url Actually, that suggestion above of mine doesn't work. It fails with:

Re: [rspec-users] NameError when passing a URL helper to a method

2008-12-04 Thread Nick Hoffman
On 2008-12-04, at 17:06, Zach Dennis wrote: On Thu, Dec 4, 2008 at 3:41 PM, Nick Hoffman <[EMAIL PROTECTED]> wrote: Hi guys. I just wrote a small spec helper method to DRY up some of my specs, and found that passing a URL helper (Eg: #photos_url) to a method results in a NameError er

[rspec-users] NameError when passing a URL helper to a method

2008-12-04 Thread Nick Hoffman
Hi guys. I just wrote a small spec helper method to DRY up some of my specs, and found that passing a URL helper (Eg: #photos_url) to a method results in a NameError error. I extracted the problem into its own short spec file to isolate it. Any thoughts on what's going on?: http://gist.githu

Re: [rspec-users] Rails project as a template for other projects (off topic)

2008-12-04 Thread Nick Hoffman
On 2008-12-04, at 13:34, Andrew Premdas wrote: This is of topic but I have a feeling I might get some useful advice here - hope you don't mind I've created a rails project that I want to use as a basis for other rails project. I was wondering if anyone had any tips on workflow for doing th

Re: [rspec-users] rails associations

2008-11-25 Thread Nick Hoffman
On 2008-11-25, at 22:07, David Parker wrote: Hello! So I'm having some problems working out some probably really easy associations in Rails. I've Googled around and read some things on different Rails forums and blogs, but I just haven't seen many solid examples. Anyway, my question is

Re: [rspec-users] Q: object.id is deprecated. How to mock?

2008-11-25 Thread Nick Hoffman
On 2008-11-25, at 14:04, s.ross wrote: In Rails, the primary key, by default 'id', is used all over the place. However, Ruby now deprecates the use of constructs like: @post = Post.find(:first) @post_id = @post.id ..snip.. Thanks, Steve Hi Steve. Ruby deprecated Object#id in favour of Objec

Re: [rspec-users] calling a step from a step

2008-11-24 Thread Nick Hoffman
On 2008-11-24, at 11:47, James Byrne wrote: Missing slash at end of regex /When /should determine the party (.*)/ Sig Thanks. Hey, it happens to the best of us, mate. At least it's an easy fix! ___ rspec-users mailing list rspec-users@rub

Re: [rspec-users] calling a step from a step

2008-11-24 Thread Nick Hoffman
On 2008-11-24, at 11:16, James Byrne wrote: I have this: When /obtain the party (.*)/ do |n| n case Hi James. Shouldn't that be "case n"? -Nick ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] How to spec a Rails helper method

2008-11-24 Thread Nick Hoffman
On 2008-11-24, at 00:39, Zach Dennis wrote: Try: helper.format_utilities Thanks everyone! I should have searched the API rather than Google. I'll do that next time. Cheers, Nick ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyf

Re: [rspec-users] restful_authentication's "permission_denied" and rspec

2008-11-24 Thread Nick Hoffman
On 2008-11-21, at 09:20, Ramon Tayag wrote: Hi everyone, WIth restful_authentication you get a method "permission_denied" that you just slap onto the controller when you don't want a user to gain access to something. In this method Rails does a bunch of stuff then basically tries to be smart an

[rspec-users] How to spec a Rails helper method

2008-11-23 Thread Nick Hoffman
I'm trying to write specs for a helper method that I'm creating, but my specs are failing to find the helper method # app/helpers/properties_helper.rb module PropertiesHelper def format_utilities(utilities) end end # spec/helpers/properties_helper_spec.rb require File.expand_path(File.dirn

Re: [rspec-users] Mocking and stubbing model relationships

2008-11-20 Thread Nick Hoffman
On 2008-11-19, at 12:26, Chris Flipse wrote: I've actually taken this old gem and enhanced it a bit module Spec::Mocks::Methods def stub_association!(association_name, methods_to_be_stubbed ={}) mock_assn = Spec::Mocks::Mock.new(association_name.to_s) stub_association_with(association_

  1   2   3   >