Displaying 20 results from an estimated 400 matches similar to: "rSpec / Nested Routes / Mocks"
2007 Oct 26
3
Specing with Subdomains as Account Keys
How do you go about implementing and rspecing subdomains as account
keys? I''m sure that this must be an issues for others as well.
So I have an app using subdomains as account keys. The Application
Controller sets up @current_company in a before filter. Everything is
done within the context of the @current_company.
After reading about Demeter''s Revenge
2007 Oct 16
2
Does a mock model have to satisfy contraints
I am a little confused to the what happens with the following:
before do
@site = mock_model(Site, :to_param => "1")
Site.stub!(:new).and_return(@site)
end
def post_with_successful_save
@site.should_receive(:save).and_return(true)
post :create, :site => {}
end
I understand that the "@site.should_receive(:save)..." places a check to
whether the
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
2006 Aug 05
5
RESTful Nesting issue
I?m having a strange issue with nested routes though, and was wondering
if anyone could shed some light on this?
If I have:
map.resources :users do |users|
users.resources :items
end
When I try to call
<%= link_to_remote ''Delete'', :url => item_url(@item), :with =>
"''_method=delete''", :confirm => ''Are you sure?''
2006 Apr 04
2
HABTM
Hi.
Im new to Ruby and new to Ruby on Rails and have problems realizing a =20=
simple many_to_many relationship:
My tables:
items <-> items_users <-> users
------------------------------------------------------------------------=20=
--------------------------------------
id user_id =
id
name item_id name
... =
password
=
......
My Code:
class
2007 Jan 05
2
Using RESTful routes in controller tests
Why can''t I use the RESTful route helpers in my specs?
In my controller I''m doing a redirect: redirect_to list_path(:id =>
@item.list_id)
Now when I write: controller.should_redirect_to list_path(:id => 2)
I''m getting the following error:
NoMethodError in ''POST on /lists/2/items should redirect to index on
succesful POST''
You have a nil object
2006 Aug 24
2
Design questions on creating digg.com-like URLs (are they considered RESTful?)
Hi everyone, I''m working on creating a site that functions similar to
digg.com (please no "no more digg clones" remarks please! :) ). One
thing I really like about digg is there URLs are very nice to read and I
would like to emulate that without having a lot of actions spread out
all over my application.
So in my app I have three main resources:
Users, Tags, and Items
2009 Sep 01
13
Function Testing Reloading Fixtures before assertion
Hey Everyone,
I have a function test the is failing (despite the fact the function
actually works in the application). I was looking for some debug
advice on how to find my problem.
Here is the test:
def test_should_delete_word
assert_equal ''published'', words(:one).status
debugger
delete :destroy, :id => words(:one).to_param
assert_equal
2006 Jul 07
5
link_to: link is missing id
I''m using a legacy table, where the unique id is not ''id''
I have a Model class like the following:
class Article < ActiveRecord::Base
set_primary_key "ARTICLE_ID"
end
however, using a link_to like the following (modified scaffolding),
the link has no id value:
<% for article in @articles %>
<tr>
<% for column in
2013 Apr 12
1
What is the meaning of the method to_param?
Hey!
Foe example i have next code:
test "should update user" do
put :update, id: @user.to_param, user: @input_attributes
assert_redirected_to users_path
end
What return id: @user.to_param?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group
2007 Jan 24
2
A spec where interaction-based testing breaks down... (at least for now)
Here are the specs:
context "Finding all the stylesheets available to a company" do
setup do
@mock_company = mock("company")
@mock_company.stub!(:to_param).and_return "1"
Stylesheet.stub!(:find)
end
def do_find
Stylesheet.find_available_to @mock_company
end
specify "should convert the company into a parameter" do
2007 Jan 30
5
errors while testing resource controller using rpec
I am testing a resource called venue in this piece of code (generated
using script/rspec_resource)
====================
context "Requesting /venues using POST" do
controller_name :venues
setup do
@mock_venue = mock(''Venue'')
@mock_venue.stub!(:save).and_return(true)
@mock_venue.stub!(:to_param).and_return(1)
Venue.stub!(:new).and_return(@mock_venue)
2010 Jan 04
2
to_parm and how it can be used in a helper
is there a way to pass the data returned by the to_parm function in a
helper?
i followed the info provided at
http://www.jroller.com/obie/entry/seo_optimization_of_urls_in and am
able to successfully get the correct urls, now i want to be able to get
the same (id-whatever) text and pass it to a helper function for further
processing.
Any ideas as to how this can be achieved?
--
Posted via
2007 Oct 28
2
failing test with nested controller routes
I have googled and browsed through spec-users archives, but didn''t
find anything different.
I used rspec scaffold command to generate a mvc for groups, I used
nested controller so I could have a separate interface for admin.
the specs are the same as generated, so I won''t post the whole thing.
I did put the nested routes names on the calls to the name routes:
it
2007 Sep 28
2
form action url example
Hi,
I have the following example:
it ''should have a form with an action attribute'' do
response.should have_tag( "form[action=?]",
''/users/1/machines/1/trouble_tickets'')
end
for a form like so:
<% form_for( :trouble_ticket,
:url => { :action => ''create'',
:user_id => @machine.current_owner,
2007 Feb 09
2
Re: customizing map.resources for REST
Yeah... I''m totally struggling to grok resource routes too... seems like
they''ve totally blown the beautiful simplicity of the old url pattern
stuff out of the water.
Would love to hear an answer to this question!!!
b
Andy Triboletti wrote:
> I want to customize map.resources so it uses a uid in the URL instead
> of the database id. The uid is a field on my object.
2007 Feb 17
1
"warning: object#id will be deprecated" with mocks
hi all
I have the following code in a spec:
@user = mock("user")
User.stub!(:authenticate).and_return(@user)
@user.should_receive(:id).once.and_return(99)
post :login, {:username => ''username'', :password => ''password''}
session[:user_id].should == 99
it works as expected but I get the following warning when I run the spec:
warning:
2007 Jan 11
5
ASF: cannot determine document number from primary key
I''m getting this exception from acts_as_ferret:
A RuntimeError occurred in search#similar:
cannot determine document number from primary key:
#<MyClass:0x9feba20>
[RAILS_ROOT]/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:132:in
`document_number''
As a result of this call:
object.more_like_this
The relevant backtrace:
2006 Jul 23
4
Anything like with_scope for ActionController?
There are areas of my application that "want" to use a url structure
like
domain/<human_readable_param>/<Module>/<Controller>/<Action>/<Id>
Please note that the human readable parameter I need to inject is NOT
related to the <id> being used by the action/controller pair. It''s
identifying a container object whose contains are operated
2007 May 20
9
How to test for exceptions
Hi folks,
I''m in the process of converting a Test::Unit functional test to RSpec, but I''ve run into a slight problem. I tried looking through the documentation but I still don''t know what I missed.
Thanks in advance,
Blake
describe VenuesController, "on update" do
before(:each) do
@venue = mock("venue")