similar to: [rspec] looking for a simple refresher

Displaying 20 results from an estimated 2000 matches similar to: "[rspec] looking for a simple refresher"

2007 Aug 21
2
using restful_authentication current_user inside controller specs
I''m using restful_authentication in my app and I have the before filters in my application rhtml: before_filter :login_required around_filter :set_timezone around_filter :catch_errors Currently I have them commented out while rspec''in but I''ll need to add them in my specs. def create @ticket = Ticket.new(params[:ticket]) @ticket.user = current_user if
2007 Oct 05
13
spec''ing view render partial collection, local variable not found
I''m trying to spec out a render partial collection but I get the following error 2) NoMethodError in ''/games/_game.rhtml should show game name'' undefined method `body'' for #<#<Class:0x316580c>:0x2f1154c> /Volumes/EXTERNAL/web/omenking.ca/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb:12:in `matches?''
2007 Jun 02
7
I''m really bad at controllers, help please.
Hey, Sorry for so many questions - I''m really bad at this right now. I''m trying to cover the following code w/ rspec def index if params[:user_id] @user = User.find(params[:user_id]) @messages = @user.messages end end So basically what I''m doing is listing all the messages for a user, provided there is an id parameter. describe
2007 Jul 12
3
Agh, this is annoying. Why is this happening?
My problem: Mock ''Task_1005'' received unexpected message :user_id= with (1) No matter what I do to try to stub that out it will still fail out and give me that message. Here is my spec describe TasksController, "handling POST /tasks" do before(:each) do @task = mock_model(Task, :to_param => "1", :save => true)
2007 Sep 30
9
Problems with testing nested routes using mocking
Hello forum I have there to files #----- virtual_host_controller.rb class VirtualHostsController < ApplicationController before_filter :capture_domain # GET /domain/1/virtual_hosts/1 def show @virtual_host = @domain.virtual_hosts.find(params[:id]) respond_to do |format| format.html # show.rhtml end end private def capture_domain if
2007 Dec 04
10
Unexpected message on :attr_accessor
This may be a dumb noob issue, but I haven''t found any answers while seaching the forum-- I have a controller method def edit @user = User.find params[:id] @user.password_confirmation = @user.password end The User class has an "attr_accessor :password_confirmation" definition (so "password_confirmation" doesn''t exist in the users table). My spec
2007 Nov 21
6
How thorough do you test?
Testing models is great and would not be able to create anything without it, but I am finding testing the controllers and views is a pain. Rest based controllers don''t seem to change that much when compared to the auto-generated code that obviously works. As for views I fail to see why testing it with a mock model does anything. Nothing is ensuring that when changes are made to the
2007 Oct 26
2
Examples of writing controller specs that use authentication
Hello, I''m working on specs for a controller that handles authentication using the restful_authentication plugin. I''m trying to find a resource (tutorial or examples, if possible) about the best way to go about writing mocks and specs to make sure that things like my before_filters are working correctly. Does anyone know of any good resources for this? Thanks, Les
2007 Jun 15
6
problem getting started with stubbing in rails controller specs
Hello, Ingo! I''m copying your question to a new e-mail instead of replying to try to keep message threads separate. Have you tried setting up your expectation before issuing the get statement? For example, take this out of the setup block: get ''index'', :locale => ''en'' and move it after:
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec. I can''t seem to tell rSpec to expect the call @item.user. The following error message plagues me not matter how I try to fuss with the mock: Spec::Mocks::MockExpectationError in ''ItemsController handling POST / items should redirect to the new course on successful save'' Mock
2007 May 31
16
Could anyone please help with rspec/nested resource behavior checking?
My problem has been listed here: http://railsforum.com/viewtopic.php?pid=25439#p25439 Don''t think it would be required to completely re-type it here :) Thanks! -- -Daniel Fischer http://danielfischer.com - Geek Blog http://abigfisch.com - Portfolio http://writersbeat.com - Writing Community
2010 Jul 13
2
[Rspec] Difference between stub and message expectation with any_number_of_times
I''m wondering what''s the difference between stub and message expectation with any_number_of_times, for example: myMock = mock("mymock") myMock.stub!(:is_a?).with(MyClass).and_return(false) and myMock = mock("mymock") myMock.should_receive(:is_a?).with(MyClass).any_number_of_times.and_return(false) because is_a? may not be called at all, it just like a
2007 Feb 15
17
Odd parameter munging with with()
Hi, I have this setup block: setup do session[:login] = ''jhughes'' @user = mock("user") User.stub!(:find).and_return(@user) @params = {:cn => "Bilbo Baggins", :telephoneNumber => "416-277-4418", :mail => "bilbo at baggins.com"} end And then this spec: specify "should update and save the
2007 Oct 06
4
spec''ing views, mock_model associations
I writing a spec that returns the count of how many players in a game: it "should how many players in a link to all players" do render :partial =>"games/game", :object => @game response.should have_tag(''a'',"(2) Players") end I''m not sure how to do the mock model, I think it would be done two ways but unsure of the syntax: 1: add
2007 Jun 05
6
Help with spec controller
Hello, I haven''t been able to create a controller spec. You can see the code here: http://pastie.caboo.se/67980 The error message I''m getting is: Spec::Mocks::MockExpectationError in ''PersonController should tell the Person model to create a new person on POST to create'' Mock ''person'' received unexpected message :save with (no args)
2008 Feb 04
1
Error on nil.build
I can''t figure out why I am getting an error for one of the tests below: ======================== describe AccountsController, "POST" do before :each do @user = mock_model(User) @account = mock_model(Account, :id => 1, :valid => true, :save => true, :users => mock("users", :build => @user)) Account.should_receive(:new).and_return(@account)
2007 Nov 18
9
Not sure why this is failing
I am not sure why the tests don''t see the call of the new method for the Address class. It can be seen in the controller method where the Address.new is called. >> @address = Address.new(params[:address]) What am I doing wrong? Thanks for the help. Here is the error message: Spec::Mocks::MockExpectationError in ''UsersController handling POST /users should create a new
2007 Nov 21
7
describe AddressesController, "handling GET /addresses" do
Hello, I''m working with scaffold generated controller test code for handling GET requests. Address is the model being tested. Address belongs_to Company, Company has_many addresses. In my addresses_controller I have: before_filter :get_company def index @addresses = @company.addresses.find(:all) respond_to do |format| format.html # index.html.erb format.xml {
2007 Oct 08
6
spec''in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do before do @game = mock_model(Game, :to_param => "1") @game.stub_association!(:players, :find => mock_model(Player)) end def do_get get :index, :game_id => @game end it "should be successful" do do_get response.should be_success end it "should
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan is to deprecate the mocking framework." I hadn''t heard anything about that, but then again I haven''t paid super close attention to the list. Are we planning on dumping the mock framework in favor of using Mocha (or any other framework one might want to plug in?). Pat