Displaying 20 results from an estimated 4000 matches similar to: "undefined method `mock_model'' for [RSpec example]:#<Class:0x25550a8>"
2007 Aug 30
7
mock_model in spec/lib
Has anyone else run into a problem with trying to use mock_model in spec/lib ?
For some reason, I can take the same spec, put it in spec/models, have it run
fine, but put it in spec/lib, and have it complain about not being able to find
#mock_model
Thanks,
Edward
2007 Aug 31
2
Can module spec "behave like" controller spec?
Hello everyone:
Right now I am writing spec on modules, which are provided by my
colleagues. Some of the modules actually contain action methods. I tried
very hard to spec those action methods in modules. But it seems that the
rspec does not allow module spec to ''get'' action like controller does. After
I saw the documentation, I then used :behaviour_type=>:controller.
2007 Oct 23
9
Running rails specs outside of the normal project tree
I want to create a spec/regressions directory with various
regressions (for my rails project). I tried the following:
describe LoginController, "regression for user creation when
steves_sister does not exist", :behavior_type => :controller do
controller_name :login
before :each do
@params = {
"commit"=>"Create Account",
2007 Aug 23
6
controller spec with model that validates_uniqueness
I want to use mocks and stubs to test the controller, but am having
trouble getting my validation not to trigger. Here''s the code:
# spec:
Image.stub!(:find).and_return(@image)
@image.should_receive(:save!).once.with(:any_args)
put :update, :id => @image.id, :category_id =>
@category.id, :image => {:name => ''test'', :image_number =>
2007 Dec 12
3
undefined method: controller_name
With rspec 1.0.8 I have a spec in the directory:
spec/units/controllers/application_controller_spec.rb
require File.dirname(__FILE__) + ''/../../spec_helper''
class DummyController < ApplicationController
def index
raise "Prevent index from rendering"
end
end
describe ApplicationController, "Handling errors in production",
:behaviour_type =>
2007 Aug 27
7
Foreign key constraints, fixtures, and rake task
I''ve got a spec that loads a fixture in the "before" block. This works
fine running scripts/spec, but when I run rake spec instead, I get:
ActiveRecord::StatementInvalid in ''User in fixture :quentin with an IM
service but no IM name should be invalid''
Mysql::Error: Cannot delete or update a parent row: a foreign key
constraint fails
2007 Jul 26
2
rspec_resource error
First of all hi, I''m new to the list, and rather new to rspec as will
probably show in myquestion.
I have tried installing rspec and rspec_on_rails as plugs both using
"script/install" and
"piston import" commands using the "current release install instructions"
here [1]. However,
there doesn''t seem to be any mention of the rspec_resource
2008 Oct 09
1
About received unexpected message :code with (no args)
I use rspec_scaffold to generate a part of examples as below:
it "should expose a newly created awarding_body as @awarding_body" do
AwardingBody.should_receive(:new).with({''these'' =>
''params''}).and_return(mock_awarding_body(:save => true))
post :create, :awarding_body => {:these => ''params''}
2008 Mar 14
2
Lib Specs and config.use_transactional_fixtures = true
Hi
We have specs in our rails project other than model/view/controller ..
we have interests and lib ...
using use_transactional_fixtures = true seems fine in a spec in the m/
v/c and interests directories but not in lib
Just wondered if anyone had any quick thoughts as to why that may be???
Shane Mingins
ELC Technologies (TM)
1921 State Street
Santa Barbara, CA 93101
Phone: +64 4 568
2007 Nov 02
5
RSpec, RESTful nested routes and :path_prefix
Dear list,
In the app we are making we have a rout something like this:
map.resources :projects do |projects|
projects.resources :pages, :controller
=>"Wiki::Pages", :path_prefix => "/projects/:project_id/
wiki", :name_prefix => "project_wiki_"
end
But I can''t get RSpec(I''m very new to it) to accept this. It keeps
throwing errors:
2007 Aug 02
2
Do the :attributes and :content matchers work
[Rails plugin 1.0.5]
Hi,
I am looking for some guidance.
When working on a partial which looks like this
<div class="bug" style="width: 100%;" />
I have some examples which should fail - I think - but do not:
it '' should fail'' do
response.should have_tag( ''div.bug'', :content => ''There is no
2008 Jun 12
1
map.resources :foo_items, :as => :foo confusing my controller specs
I have following resource defined in my config/routes.rb (the model
name is contrived)
map.resources :foo_items, :as => :foo
that I originally generated with rspec_scaffold:
ruby script/generate rspec_scaffold foo_item
but when I use the :as attribute in resources to make the URI path be
''/foo'' instead of ''/foo_items'' the default/generated controller
2006 Oct 17
3
Should fixtures be transactional?
I started using the new Model.should_have(1).records expectation in
rspec_on_rails, and quickly realized that my fixtures were remaining
loaded, even in contexts that didn''t use them. Bug or feature?
Jay Levitt
2007 Dec 16
3
how do I spec my Rails routes?
Once again, here''s something I haven''t figured out. Apologies if this
is too newb-ish, but, how do I spec my routes using RSpec-Rails?
In particular, I''ve got a catch-all route that needs to catch a wide
variety of URLs:
map.document ''*url'', :controller => ''documents'', :action => ''show''
Is there a way to
2009 Apr 19
19
Controller spec: testing that scope is set
In a Rails controller I set the scope on a model class in an around
filter. I have defined expectations on the model classes, and ideally, I
would add a further expectation for the scope. Is this already possible
in some way? How would I go about adding support a scope expectation?
Michael
--
Michael Schuerig
mailto:michael at schuerig.de
http://www.schuerig.de/michael/
2007 May 15
3
nested blocks
Hello,
Does anyone have an explanation for why the following code results in
the error that follows? I also would value any criticisms of my
approach (i.e., defining it_should_populate_collections). Thanks
-Chris
#Code
def it_should_populate_collections(condition=nil)
it "should populate any necessary collections #{condition}" do
[*@collections_to_populate].each do
2007 Aug 13
2
Backtrace tweaker - broken or me?
Using 1.0.8, I just realized that I''ve been scrolling through pages of
backtraces when rspec is supposed to clean them up for me. This is a
new development machine, so I''m not sure if older versions worked or
not. I''m running Ruby 1.8.6, Rails edge, Mac OS X 10.4.10.
I''ve verified that the QuietBacktraceTweaker is the one that''s running.
2006 Nov 07
7
should_redirect_to in advance - feels unnatural
I can understand that it''s easier for rspec to set up a mock in advance
of the controller call. But it makes it difficult to do something like:
context "The HarkController, given Louie the logged-in user" do
setup do
post :login, :username => ''louie'', :password => ''atest''
end
specify "should redirect Louie to the home
2007 Jun 09
11
authentication, controller specs. I think I''m missing something simple ....
Hi all,
I feel like I''m missing something really easy and I''m just not seeing
it.
I''m using the restful_authentication plugin and have a User model. Uesr
has_many :things and Thing belongs_to :user.
That''s it.
I did a "script/generate rspec_scaffold thing" to generate all the
necessary bits. The "rake db:migrate" to create the db.
At
2007 Aug 06
2
Specifying custom rails FormBuilders
I want to write a spec for a custom form builder, but I''m not really
sure where it should live or how to include the right rspec_on_rails
contexts. Ideally, I should be able to write a spec like:
describe LabelledBuilder do
it "should let me create a text field" do
object = mock(object)
object.stub!(:attribute).and_return("Test String")
render