Re: [rspec-users] testing a render layout statement in a controller

2008-10-31 Thread Harry Bishop
Bart Zonneveld wrote: > On 16-okt-2008, at 8:50, Dave Gamphani Phiri wrote: > >> Here, I was trying to test if the out put displays with a layouts/menu >> template. >> Can somebody help on how you test the render(:layout => "layouts/ >> menu") statement in a controller or this is supposed to be te

[rspec-users] daylight savings time difference with rspec?

2008-10-26 Thread Harry Bishop
Hi all, I wanted to check this with you. I have an rspec example that checks the correct expiration date set on an object. The expiration is set in the model with expires_on = Time.now + next_duration[phase] where next_duration can either be in units of seconds or n.days (should be the same thi

Re: [rspec-users] can't seem to test redirect?

2008-10-24 Thread Harry Bishop
Hi All, I got the redirect to work with: def do_post post :create, {:motion => do_motion_input("ten")} end it "creates new proposal with proposer set" do do_post response.should be_success end it "once motion is saved redirects to show motion" do @motion = motions(:ten)

Re: [rspec-users] can't seem to test redirect?

2008-10-24 Thread Harry Bishop
Matt Wynne wrote: > On 24 Oct 2008, at 21:57, Harry Bishop wrote: >> Harry Bishop wrote: >>>response.should redirect_to(@motion) > > What is this Motion? is it really something that you can redirect > people to? Maybe you meant redirect_to(url_for(@motion))?

Re: [rspec-users] can't seem to test redirect?

2008-10-24 Thread Harry Bishop
Harry Bishop wrote: > Pat Maddox wrote: > >> >> So there are two points you need to address right now: >> * How do you want this action to behave? (success or redirect?) >> * Don't stub behavior that you want to verify (if you want it to >> redirect

Re: [rspec-users] can't seem to test redirect?

2008-10-24 Thread Harry Bishop
Pat Maddox wrote: > > So there are two points you need to address right now: > * How do you want this action to behave? (success or redirect?) > * Don't stub behavior that you want to verify (if you want it to > redirect, let it redirect) > > Pat Hi Pat, I am new to rspec and still trying

Re: [rspec-users] can't seem to test redirect?

2008-10-24 Thread Harry Bishop
Pat Maddox wrote: > Harry Bishop <[EMAIL PROTECTED]> writes: > >> format.html { redirect_to(@motion) } >> >> TIA, >> Harry > > Can you post your example code as well? Also, are there any errors? > Here are my two guesses at this point: >

[rspec-users] can't seem to test redirect?

2008-10-24 Thread Harry Bishop
I'm posting to the create action and seeing the line "at the motion save part of create in the following: def create @motion = Motion.new(params[:motion]) respond_to do |format| if @motion.save puts "at the motion save part of create" flash[:notice] = 'Motion was su

Re: [rspec-users] Where is current_user?

2008-10-22 Thread Harry Bishop
David Chelimsky wrote: > On Tue, Oct 21, 2008 at 9:39 PM, Harry Bishop <[EMAIL PROTECTED]> > wrote: >> approach you are providing would indicate that an attr_read method is >> preferred so that the retrieve method can be stubbed since the instance >> variable doesn&#

Re: [rspec-users] Where is current_user?

2008-10-21 Thread Harry Bishop
Thanks David, Your method works well and rspec succeeds now. Is the preferred way of using code with rspec to not rely on instance variables set in a parent during execution but to rely on the method only construct to be able to interact? I see the way this works for the outline you provided.

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
Hi David, Yes, I understand. I was trying to answer Zack with regard to my attempt to set the @current_user and what happened. I will be using your method as a test shortly. Thanks, HR -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailin

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
Zach Dennis wrote: > The @current_user instance variable was being set by the > ApplicationController#retrieve_user method, but your spec was stubbing > out the #retrieve_user method. This means that the original > ApplicationController#retreieve_user method is not going to get called > because yo

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
David Chelimsky wrote: > When things are hard to test they are hard to maintain, so > maintainability requires testability. When a simple change makes > something easier to test, that change brings a lot of value. That's > the spirit of rspec, BDD and even TDD. Thanks David, I am new to rspec and

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
> David Chelimsky wrote: >> >> I'd add a current_user method that returns @current_user, and then >> stub *that* in the code examples: Hi David, I found that I can stub out is_showable?(@current_user, @motion) and the test passes. I was trying to use the code logic to do this, but now see

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
David Chelimsky wrote: > retrieve_user, the real method, sets an instance variable that other > methods expect to be set rather than returning a value. When this is > stubbed with a *return value* of the user, the instance variable never > gets set inside the controller. > > I'd add a current_user

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
David Chelimsky wrote: > On Mon, Oct 20, 2008 at 7:30 AM, Harry Bishop <[EMAIL PROTECTED]> > wrote: >> @current_user is retrieved in the application controller with >> retrieve_user. > > I don't see where retrieve_user is getting called in the rspec example

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
@current_user is retrieved in the application controller with retrieve_user. -- 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] Where is current_user?

2008-10-20 Thread Harry Bishop
Harry Bishop wrote: > David Chelimsky wrote: >> On Mon, Oct 20, 2008 at 6:53 AM, Harry Bishop <[EMAIL PROTECTED]> >> wrote: >>>>> called from the database to test the true interaction between user and >>>>> motion. >>>> >&

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
David Chelimsky wrote: > On Mon, Oct 20, 2008 at 6:53 AM, Harry Bishop <[EMAIL PROTECTED]> > wrote: >>>> called from the database to test the true interaction between user and >>>> motion. >>> >>> Not necessarily. Have you looked into usin

Re: [rspec-users] Where is current_user?

2008-10-20 Thread Harry Bishop
Scott Taylor wrote: > On Oct 20, 2008, at 1:00 AM, Harry Bishop wrote: > >> before(:each) do >> true. >> end >> action. >> >> A mock would require rebuilding the User model for all the checks done >> in the controller and I am trying to avoid tha

[rspec-users] Where is current_user?

2008-10-19 Thread Harry Bishop
Hi, I have a controller that uses the current_user attributes to determine if a motion is showable. I can see the motion track through from a fixture to the show action, but not the current_user. My rspec test is describe MotionsController, "handling GET /motions/1" do fixtures :people, :mot

Re: [rspec-users] Why @controller is nil error on loading fixtures in model?

2008-10-19 Thread Harry Bishop
Zach Dennis wrote: > On Sat, Oct 18, 2008 at 6:10 PM, Harry Bishop <[EMAIL PROTECTED]> > wrote: >> '/../helpers/votes_spec_helper') >> >> but no change. >> >> I would appreciate some assistance here to get this off the ground. > > It&

[rspec-users] Why @controller is nil error on loading fixtures in model?

2008-10-18 Thread Harry Bishop
Hi, I'm new to rspec and working on catching up my app with rspec testing. I'm running OSX 10.5.5 with Rails 2.1.0 and Rspec 1.1.8. Most things I've tried work except loading fixtures. I setup a describe block for the model as require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')