similar to: rspec model class methods

Displaying 20 results from an estimated 6000 matches similar to: "rspec model class methods"

2008 Mar 05
3
having trouble specing an ajax request
Do I need to spec an AR. If yes, what is the best way to spec this. here is the code - def index @deals = Deal.paginate(:all, :conditions => prepare_search_conditions, :order => ''created_at DESC'', :page => params[:page] ) if request.xhr? render :update do |page| page.replace_html "table", :partial =>
2011 Jul 27
3
Rspec with ActionMailer and .deliver
I''m in the process of migrating from Rails 2 with rspec 1 to Rails 3 with rspec 2, the process has been going pretty well, however, today I came across an issue that I wanted to share. I have a controller that sends out an email through a mailer. Rails 2 code: CurriculumCommentMailer.deliver_comment_update(@curriculum_comment, "created") Rails 3 code:
2007 Jun 14
1
rspec will_paginate
Hi Rspec-Users, I''m not sure if I am correctly specing my index since I''m using will_paginate. params[:filter_by] will filter the paginate list accordingly. Tickets Controller: def index @tickets = Ticket.filter_status_by(params[:filter_by],params[:page]) end Ticket Model: def self.filter_status_by(status, page, per_page = 10) conditions = {:status => false} if
2007 Aug 11
2
Rspec and acl_system2 plugin
Hello, I''m trying to spec a Rails application using the couple restful_authentication/acl_system2 plugins. In my admin layout, I put the following code : <% restrict_to "admin" do -%> <ul id="admin-tabs"> <li> /users Users management </li> </ul> <% end -%> Then in my spec file
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 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 May 23
2
rspec mocha and controller specs without integrated_views
The ability to choose a mocking framework is great as I prefer mocha, but I am have problems. On my controller specs, I am forced to ''integrate_views'' as the following code below shows you, the mocking of views is rspec specific. See stub! versus mocha''s stub unless block_given? unless integrate_views?
2007 May 08
4
help with rspec''ing controller
Hi, I''m a rspec newbie. I''m having trouble with rspec''ing a simple controller to Create a record. I''ve tried a couple of approaches and still get errors: Mock ''remedy'' expected :save! with (any args) once, but received it 0 times -or- Mock ''Remedy'' received unexpected message :save with (no args). Here are my two
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
2008 Jan 30
2
How do I get logging with rspec?
Say I''m testing a controller with rspec, and I have logger.debug and logger.error calls. Normally I''d like them to write to the appropriate file, but in this case I''d like to see the output on STDOUT. Is there an easy way to redirect logging in rspec to do this? I''m thinking that controller.should_receive(:logger).and_return(logger) should start it off,
2007 Nov 01
2
Writing controller specs
One thing that is bothering me about my controller specs is that sometimes I end up with a number of examples that are the same except for the example name. The reason that this happens is that I''ve expressed all the expected behavior with should_receive. While this does more or less work as intended it doesn''t feel right. As an example, let''s say I''m writing
2011 May 14
1
RSpec stub question
Hi I am using Mongoid. In Mongoid while saving a record we typically give like in the controller @post.safely.save For a model class Post I am writing rspecs for my controller and want to mock the model. So what I am doing is let(:post) { mock_model(Post).as_null_object } before(:each) do Post.stub(:new).and_return(post) end it "creates new post"
2007 Jun 03
3
should_receive.again
Hi, It appears that if I have 2 should_receives in a row, the latest one overrides the previous one(s). If there isn''t one, could we add a way to accumulate them, such as @thing.should_receive(:method).and_return(@value) @thing.should_receive(:method).again.and_return(@value) @thing.should_receive(:method).again.and_return(@value) would be equivalent to
2007 Oct 01
0
View Spec - Misbehaving
I''m trying to write my first view spec; I''ve done some controller specs with integrated views, but thought that isolating the views for some of these tests might be nice. So I wrote this: > describe PlayerContainer, "show" do > > PARENT_ID = 12 > CHILD_NAME = ''Child Name'' > PARENT_NAME = ''Parent Name'' > >
2007 Dec 04
1
spec''ing shared controller methods
I want to isolate and spec methods that are shared by controllers, and live in application.rb. Whereas I usually also provide examples in individual controllers that use these methods, not necessarily all the edge cases and I''d like to isolate the examples. This is the approach I''m taking (thanks to bryanl for suggestions and http://pastie.caboo.se/123626). WDYT? This
2007 Oct 26
5
specing rescue, ensure and else blocks of an Exception
Greetings, I''m using rspec with rcov for my applications and there is one issue which I cannot solve nor can find any proper information regarding it: specing what is in a rescue block in case of an exception. I''m using Ruby on Rails and I usually make use of exceptions in my controllers, like the following example: def action @foo = Foo.find(1)
2011 Jun 30
2
Testing RSpec views: the index action; is my methodology flawed?
This is my organizations_controller_spec.rb: require ''spec_helper'' describe Superadmin::OrganizationsController do describe "GET index" do it "shows a list of all organizations" do #pending "don''t know why this doesn''t work" Organization.should_receive(:all) end end end ============ This is my
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)
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)
2012 May 05
1
rspec-mocks and rspec-rails-2.10.1 are released!
These are patch releases recommended for anybody who has already upgraded to 2.10. ### rspec-mocks-2.10.1 full changelog: http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1 Bug fixes * fix [regression of edge case behavior](https://github.com/rspec/rspec-mocks/issues/132) * fixed failure of `object.should_receive(:message).at_least(0).times.and_return value` * fixed failure