Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Stub a controller method containing arguments
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jeevan reddy  
View profile  
 More options Sep 9 2012, 2:05 am
From: jeevan reddy <li...@ruby-forum.com>
Date: Sun, 09 Sep 2012 08:00:25 +0200
Local: Sun, Sep 9 2012 2:00 am
Subject: [rspec-users] Stub a controller method containing arguments
controller code:

class BooksController < ApplicationController
  def index
   param1, param2 = "123", "456"
    @test = method_1(param1, param2)
  end

  private
  def method_1(param1, param2)
    return "test"
  end
end

controller tests

describe "GET index" do
  it "get books" do
    param1, param2 = "12334", "456233"
    controller.stub!(:method_1).with(param1,param2).and_return("test")
    get :index
    assert_response :success
    assigns(:test).should eq("test")
  end
end

How to stub a controller private method which will take any arguments

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Chelimsky  
View profile  
 More options Sep 9 2012, 7:37 am
From: David Chelimsky <dchelim...@gmail.com>
Date: Sun, 9 Sep 2012 06:31:56 -0500
Local: Sun, Sep 9 2012 7:31 am
Subject: Re: [rspec-users] Stub a controller method containing arguments

In your example above, the values of param1 and param2 are different
in the rspec example and the controller, so I'm guessing you're
getting a failure. If you're constraining a stub with specific args,
they have to match.

Curious - why do you care about the args in your real spec?
_______________________________________________
rspec-users mailing list
rspec-us...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »