Displaying 10 results from an estimated 10 matches for "be_redirect".
2007 Apr 11
12
redirection doesn''t get detected well?
I''m doing a redirect in one of my controller actions and somehow I can''t
spec it, see this pastie: http://pastie.caboo.se/53120.
When following the link from a browser I''m being redirected to the right
page.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2007 Dec 30
6
Restful-Authentication Rspec Failure Rails 2.0.2
I am trying the Restful-Authentication (latest version, downloaded
today) and upon running the generator, doing the migration, prepping
the test system and putting the resources in routes.rb I get a Rspec
test failure:
''SessionsController logins and redirects'' FAILED
expected not nil, got nil
routes.rb has:
map.resources :users
map.resources :sessions
nothing else was
2007 Dec 01
5
specifying an HTTP status code
...I hope this question isn''t too
obvious or missing the point somehow: Is there a way in RSpec to
specify that a controller action should use a specific HTTP status
code? Specifically I want to test for the usage of 301 as opposed to
302, for a permanent redirection.
response.should be_redirect
looks like it calls ActionController::TestRequest#redirect?, which is
only testing for a status code from 300..399. In an old-fashioned
Test::Unit Rails test I could do assert_response, but I can''t see
anything matching that in RSpec. Is there a less-documented feature
I''...
2012 Feb 18
0
Rails NameError : uninitialized constant RelationshipsController
...ore(:each) do
@user = test_sign_in(Factory(:user))
@followed = Factory(:user, :email => Factory.next(:email))
end
it "should create a relationship" do
lambda do
post :create, :relationship => { :followed_id => @followed }
response.should be_redirect
end.should change(Relationship, :count).by(1)
end
it "should create a relationship using Ajax" do
lamda do
xhr :post, :create, :relationship => { :followed_id =>
@followed }
response.should be_success
end.should change(Relationship, :count)...
2007 Aug 15
4
nuby: how spec redirect_to at ApplicationController
...ill rspec nuby: I must do something wrong obviously.
How can I spec about redirect_to at ApplicationController
describe ApplicationController do
it "method login_required should redirect to home path without login" do
pending "I tried to use controller.login_required.should be_redirected
and got NoMethodError with nil object didn''t expect error."
end
end
class ApplicationController < ActionController::Base
# using it with before_filter
def login_required
# I took out everything except redirecting to make the point simple
redirect_to home...
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
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 Oct 26
5
specing rescue, ensure and else blocks of an Exception
...it "should retrieve a Foo instance, identified by ID and update it''s
parameters" do
Foo.should_receive(:find).with("1").and_return(@foo)
@foo.should_receive(:update_attributes!).with
(valid_params).and_return(@foo)
get :action, :id => 1
response.should be_redirect
end
it "should retrieve a Foo instance, identified by ID and throw an
exception, because of bad parameters" do
Foo.should_receive(:find).with("1").and_return(@foo)
@foo.should_receive(:update_attributes!).with
(valid_params).and_return(@foo)
get :action, :id => 1...
2008 Jan 23
13
DRYing up stories
I''m finding that I''m writing sets of very similar scenarios to check access
permissions for each of my actions. Does anyone have suggestions on how to
dry this up:
Given an existing Account
And a logged in Admin
When the user visits account/manage
Then he should get access
Given an existing Account
And a logged in Manager
When the user visits account/manage
Then he should get
2007 Jul 24
6
Mocking Access Control
I''m trying to jump on the TDD/BDD bandwagon, but am having trouble
understanding how i should mock my user. The user has a habtm
relationship to a roles model (acl_system2 plugin), but I''m not sure
how to tell rspec about a model.
My code:
describe UsersController do
integrate_views
before(:each) do
@user = mock_model(User)