[rspec-users] rspec-users Digest, Vol 57, Issue 22

Micah Martin micah at 8thlight.com
Wed Mar 23 09:59:37 EDT 2011


On Mar 23, 2011, at 12:22 AM, rspec-users-request at rubyforge.org wrote:

> Send rspec-users mailing list submissions to
> 	rspec-users at rubyforge.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://rubyforge.org/mailman/listinfo/rspec-users
> or, via email, send a message with subject or body 'help' to
> 	rspec-users-request at rubyforge.org
> 
> You can reach the person managing the list at
> 	rspec-users-owner at rubyforge.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of rspec-users digest..."
> 
> 
> Today's Topics:
> 
>   1. How to test a Rails 3 metal controller? (Thibaut Barr?re)
>   2. Re: How to test a Rails 3 metal controller? (David Chelimsky)
>   3. Is it possible to run rspec continuously? (Benyi Wang)
>   4. Re: Is it possible to run rspec continuously? (Katrina Owen)
>   5. Re: Is it possible to run rspec continuously? (Justin Ko)
>   6. Re: Is it possible to run rspec continuously? (Adam Sroka)
>   7. Testing routes with a prefix (Radhesh Kamath)
>   8. Stubs and Object Constructor (andyl)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Tue, 22 Mar 2011 05:50:57 -0700 (PDT)
> From: Thibaut Barr?re <thibaut.barrere at gmail.com>
> To: rspec-users at rubyforge.org
> Subject: [rspec-users] How to test a Rails 3 metal controller?
> Message-ID:
> 	<044ce36f-f765-48a0-a145-f539e01ea2ec at j35g2000prb.googlegroups.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Hi!
> 
> I could not find an easy solution to this question: how can I properly
> test an Rails controller action?
> 
> We were trying to run the following test:
> 
>    get :show, :id => 'hello'
>    response.should redirect_to("http://www.google.com")
> 
> But we got:
> 
> undefined method `formats=' for #<LinksController:0x00000104000b40>
> 
> After reading a couple of blog posts, we tried this work-around:
> 
> class LinksController
>  include ActionController::UrlFor
>  include ActionController::Testing
>  include Rails.application.routes.url_helpers
>  include AbstractController::ViewPaths
> end
> 
> It works only partially, we're now stuck with the limits of our monkey-
> patching and get the following error:
> 
> undefined method `protected_instance_variables' for
> LinksController:Class
> 
> Well - is there a clean way to test our a Rails metal with RSpec?
> 
> Thanks for your support!
> 
> -- Thibaut
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Tue, 22 Mar 2011 08:36:49 -0500
> From: David Chelimsky <dchelimsky at gmail.com>
> To: rspec-users <rspec-users at rubyforge.org>
> Subject: Re: [rspec-users] How to test a Rails 3 metal controller?
> Message-ID: <A571B576-B10C-41D5-82DE-46220CF225C9 at gmail.com>
> Content-Type: text/plain;	charset=utf-8
> 
> On Mar 22, 2011, at 7:50 AM, Thibaut Barr?re <thibaut.barrere at gmail.com> wrote:
> 
>> Hi!
>> 
>> I could not find an easy solution to this question: how can I properly
>> test an Rails controller action?
>> 
>> We were trying to run the following test:
>> 
>>   get :show, :id => 'hello'
>>   response.should redirect_to("http://www.google.com")
>> 
>> But we got:
>> 
>> undefined method `formats=' for #<LinksController:0x00000104000b40>
>> 
>> After reading a couple of blog posts, we tried this work-around:
>> 
>> class LinksController
>> include ActionController::UrlFor
>> include ActionController::Testing
>> include Rails.application.routes.url_helpers
>> include AbstractController::ViewPaths
>> end
>> 
>> It works only partially, we're now stuck with the limits of our monkey-
>> patching and get the following error:
>> 
>> undefined method `protected_instance_variables' for
>> LinksController:Class
>> 
>> Well - is there a clean way to test our a Rails metal with RSpec?
> 
> Use a request spec (in spec/requests) instead of a controller spec.
>> 
>> Thanks for your support!
>> 
>> -- Thibaut
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Tue, 22 Mar 2011 14:37:42 -0700
> From: Benyi Wang <bewang.tech at gmail.com>
> To: rspec-users at rubyforge.org
> Subject: [rspec-users] Is it possible to run rspec continuously?
> Message-ID:
> 	<AANLkTi=J_jrJVvVM=XbzGqCDHOOC0VAtHRjeE+SRvNvs at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> When I run rspec in Rails, it seems that a ruby process is created and
> loaded with rails components due to the statement require 'spec_helper'.
> This usually takes a while to run even a single spec. Does a tool for rspec
> like rails console exist so that you can run specs continuously without
> loading everything each time?
> 
> autotest actually starts a new process each time when there is a change, and
> I can still feel the obvious delay.
> 
> Any idea?
> 
> Thanks.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110322/66b84abf/attachment-0001.html>
> 
> ------------------------------
> 
> Message: 4
> Date: Tue, 22 Mar 2011 22:59:49 +0100
> From: Katrina Owen <katrina.owen at gmail.com>
> To: rspec-users <rspec-users at rubyforge.org>
> Subject: Re: [rspec-users] Is it possible to run rspec continuously?
> Message-ID:
> 	<AANLkTikT6BwYij7V83VqLh003cO-x2j4+CA+RVrT4pES at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> Hi there,
> 
> Check out Spork. Spork will fire up a distributed ruby process that
> your tests can run in.
> 
> You'll need to restart spork any time environment files change (check
> out guard for this, though), but that's minor considering the increase
> in speed that you can see.
> 
> Katrina
> 
> On Tue, Mar 22, 2011 at 10:37 PM, Benyi Wang <bewang.tech at gmail.com> wrote:
>> When I run rspec in Rails, it seems that a ruby process is created and
>> loaded with rails components due to the statement require 'spec_helper'.
>> This usually takes a while to run even a single spec. Does a tool for rspec
>> like rails console exist so that you can run specs continuously without
>> loading everything each time?
>> autotest actually starts a new process each time when there is a change, and
>> I can still feel the obvious delay.
>> Any idea?
>> Thanks.
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>> 
> 
> 
> ------------------------------
> 
> Message: 5
> Date: Tue, 22 Mar 2011 15:02:37 -0700
> From: Justin Ko <jko170 at gmail.com>
> To: rspec-users <rspec-users at rubyforge.org>
> Subject: Re: [rspec-users] Is it possible to run rspec continuously?
> Message-ID:
> 	<AANLkTikAaCStQTwk2gp8FQd8WL0jPFQLmNMTWqk-6KFJ at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> On Tue, Mar 22, 2011 at 2:37 PM, Benyi Wang <bewang.tech at gmail.com> wrote:
> 
>> When I run rspec in Rails, it seems that a ruby process is created and
>> loaded with rails components due to the statement require 'spec_helper'.
>> This usually takes a while to run even a single spec. Does a tool for rspec
>> like rails console exist so that you can run specs continuously without
>> loading everything each time?
>> 
>> autotest actually starts a new process each time when there is a change,
>> and I can still feel the obvious delay.
>> 
>> Any idea?
>> 
>> Thanks.
>> 
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>> 
> 
> Take a look at Spork:
> 
> http://chrismdp.github.com/2010/11/getting-spork-working-now-on-rails-3-rspec-2-and-cucumber/
> https://github.com/timcharper/spork
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110322/3157a29a/attachment-0001.html>
> 
> ------------------------------
> 
> Message: 6
> Date: Tue, 22 Mar 2011 16:28:20 -0700
> From: Adam Sroka <adam.sroka at gmail.com>
> To: rspec-users <rspec-users at rubyforge.org>
> Subject: Re: [rspec-users] Is it possible to run rspec continuously?
> Message-ID:
> 	<AANLkTi=CU+=sReLXaMt1z2nEAhqHnfYTDXwNe0UL2mv9 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Check out this book:
> http://www.pragprog.com/titles/rcctr/continuous-testing-with-ruby
> 
> It is about to be published and is available as a beta PDF. They cover
> several tools and both why and how to use them.
> On Mar 22, 2011 2:57 PM, "Benyi Wang" <bewang.tech at gmail.com> wrote:
>> When I run rspec in Rails, it seems that a ruby process is created and
>> loaded with rails components due to the statement require 'spec_helper'.
>> This usually takes a while to run even a single spec. Does a tool for
> rspec
>> like rails console exist so that you can run specs continuously without
>> loading everything each time?
>> 
>> autotest actually starts a new process each time when there is a change,
> and
>> I can still feel the obvious delay.
>> 
>> Any idea?
>> 
>> Thanks.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110322/c3ab0446/attachment-0001.html>
> 
> ------------------------------
> 
> Message: 7
> Date: Wed, 23 Mar 2011 02:50:36 +0100
> From: Radhesh Kamath <lists at ruby-forum.com>
> To: rspec-users at rubyforge.org
> Subject: [rspec-users] Testing routes with a prefix
> Message-ID: <56848fc4cd4589ba63b2e93883a82dad at ruby-forum.com>
> Content-Type: text/plain; charset=UTF-8
> 
> Hi experts,
> 
> I am trying to test routing in my application, where all routes are
> enclosed in a namespace like so:
> 
> scope 'v1' do
>  resource :blah end
>    collection do
>      something
>    end
>  end
> end
> 
> Is there a clean way to set 'v1' somewhere and just write my routing
> tests like so:
> 
> describe 'routing for blah' do
> it 'should invoke show when it receives /xyz' do
>  { :get => '/blah/xyz'}.should route_to(...)
> end
> end
> 
> i.e., I do not want to say
> { :get => 'v1/blah/xyz'}.should route_to(...)
> 
> Thanks,
> Radhesh
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> 
> ------------------------------
> 
> Message: 8
> Date: Sun, 20 Mar 2011 19:22:19 -0700 (PDT)
> From: andyl <akleak at gmail.com>
> To: rspec at googlegroups.com
> Subject: [rspec-users] Stubs and Object Constructor
> Message-ID:
> 	<16776870.976.1300674139911.JavaMail.geo-discussion-forums at prfx21>
> Content-Type: text/plain; charset="utf-8"
> 
> I'm having trouble using stubs to intercept method calls in the object 
> constructor.  Here's some code with a failing example:
> 
>    class Test2
>      attr_accessor :msg
>      def initialize
>        @msg = sayhi
>      end
>      def sayhi
>        "hi"
>      end
>    end
> 
>    describe Test2, "stubbing methods used during object construction" do
>      it "should assign the stub value to the instance variable" do
>        Test2.stub!(:sayhi).and_return("bye")
>        Test2.new.msg.should == "bye"
>      end
>    end
> 
> (full test-case at https://gist.github.com/878911)
> 
> What should I do to make this work?!?
> 
> Thanks, Andy
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110320/434e56b3/attachment.html>
> 
> ------------------------------
> 
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
> 
> End of rspec-users Digest, Vol 57, Issue 22
> *******************************************



More information about the rspec-users mailing list