Displaying 20 results from an estimated 500 matches similar to: "Test should fail !"
2006 Apr 18
7
Functional test, pls help!!!!
Hi guys, recently encountered this funny problem which i really dunno
wat happen...
I have been trying on it for the past few days and just doesnt work.Hope
you guys can give me some enlightenment.
Problem:
The functional test doesnt seems to be able to recognise one of my
model, and when i run the test, it keeps giving me the error of"You have
nil object when you don''t expect
2006 Aug 02
1
REST and functional tests
Just playing around with converting an apps to the new REST goodness in
edge rails, and I''m trying to work out how to convert/write the
functional tests.
Is the recommended way to explicitly use the actions (e.g. get :show,
:id => ...; post :create,..., etc) and test the routes separately, or
duplicate the request, in which case how is that done get "/", :id => 5
2006 Apr 27
6
Functional Test Problem. Nubee, please help
ALl my controllers require the user to be logged in. SO they will be
redirected to my "login" controller.
How do i login first in a functional test? Im assuming i use the setup
method to login the controller.
This is the setup method for the Activities controller functional test:
def setup
@controller = ActivitiesController.new
@request =
2008 Jan 21
9
DRY act_as_authenticated functional testing
I''m using the acts_as_authenticated plug-in for my app. Now I need to
get my functional tests to work properly. I have not written functional
tests before so I''m unsure how to utilize setup so that all of my tests
can use the login. My tests pass if I put login_as :user inside of each
test, but that''s clearly not DRY. Can I add something to my
test_helper.rb file or
2006 Apr 28
2
tests and login_engine
Hi there,
I just started writing tests today after some months of using rails (slap wrists).
I seem to be getting the hang of things, but I''m hitting a wall when it comes to functional_testing pages protected by login_engine/user_engine.
all my assertions come back with:
Expected response to be a <:success>, but was <302>
Is there a way I can login from within a test?
2006 Sep 26
0
some help with functional testing of nested routes
I have the following functional test in test/functional for testing my
products_controller:
require File.dirname(__FILE__) + ''/../test_helper''
require ''products_controller''
# Re-raise errors caught by the controller.
class ProductsController
def rescue_action(e)
raise e
end
end
class ProductsControllerTest < Test::Unit::TestCase
fixtures
2008 Jan 12
0
Can't test application controller methods in functional tests?
I have two methods in application controller that I want to test from
ForumController:
-----------------------
class ApplicationController < ActionController::Base
...
def logout
session[:username] = nil
session[:admin] = nil
redirect_to(request.request_uri)
end
...
def home
redirect_to(:controller => ''forum'', :action =>
2007 Dec 01
5
specifying an HTTP status code
Hi all,
I''m just starting to work w/ RSpec, so 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
2006 Feb 01
3
Testing components
I''m using template components to modularize an application I''m working
on and am really happy with the way it''s going. Unfortunately, all my
attempts at writing functional tests for them fail. Trying to duplicate
my normal controller tests I have:
require File.dirname(__FILE__) + ''/../test_helper''
require File.dirname(__FILE__) +
2010 Apr 05
1
`test': wrong number of arguments (1 for 2) (ArgumentError)
Hi,
Im trying to change the syntax of my tests to the
test "some method" do
...
end
syntax from the existing
def test_some_method
...
end
syntax. Im pasting my test code below. Im getting the error in the
subject line if I try to run the test as a ruby script from the
console.
require File.dirname(__FILE__) + ''/../test_helper''
require
2006 Jul 05
2
How to write get functional test when there is no action by that name
I have following line in route.rb
#event info for an event name
map.connect ''event/:name_url'',:controller => ''home'',:action =>
''event_info''
It causes a URL like http://localhost:3000/event/_jewels_exhibition_ to be
sent to the home controller with action as ''event_info''.
I am trying to test this action. My first
2007 Jun 07
0
Functional Tests Fail - No URL can be generated for hash
Hi,
I''m just learning Ruby and Rails. I have developed a Rails application,
but not using the creation scripts that come with the rails
distribution. Consequently, no test scaffolding is available to me, and
I''m trying to write my functional tests from scratch.
I have what might be considered a standard plain old controller
(dashboard_controller.rb) that I''m trying
2006 Oct 21
6
test_create gets 200 instead of :success
Help!
I have a new/create process that works fine in the actual app. But when
I test I always get a failure in the test_create section. Here''s some
controller code:
def new
end
def create
begin
@borrower = Borrower.new(params[:borrower])
if @borrower.save
flash[:notice] = ''Borrower '' + @borrower.FirstName + '' '' +
2006 Aug 15
7
Trying to Overide Class Object Methdos For Testing
Hi,
I thought I had a handle on the whole singleton class thing but now I''m
not too sure.
I have a class definition:
class ValidationMaster
def validate(params)
# complex and time consuming validation
# returns true on success, raises Exception
# on failure
end
end
Okay, so when I''m running my functional tests within rails, I want to be
able to control how
2007 Jul 30
6
Object.stubs doesn''t seem to work.
Hi
I''m using Mocha 0.5.3 and I want to stub out a call to Time.now, just
like the example in the post
http://blog.floehopper.org/articles/2007/06/08/mocha-0-5-released
However, trying it in irb gets me the following error:
>> require ''mocha''
=> true
>> Time.stubs(:now).returns(Time.parse(''Thu Feb 01 00:00:00 UTC 2007''))
NoMethodError:
2006 Oct 13
6
If I stub do I have to mock as well?
Hi, I''m new to mocha and stubba but eager to learn. I have a rails
functional test in which I would like to stub an instance method of
particular class to always return true. I tried the following:
def test_post_checkout
Order.any_instance.stubs(:successful?).returns(true)
post :checkout
assert_response :redirect
assert_equal "Checkout was successful.",
2006 Jun 17
3
What is this failure trying to tell me?
Here is my unit test code.
post :login, :user=>{ :login => "bob", :password => "test"}
assert_response :redirect
assert_session_has :user
assert_redirected_to :action => ''welcome''
Here is the failure I''m getting when I run my tests.
2) Failure:
test_login_required(UserControllerTest)
2009 Apr 21
2
validates_uniqueness_of
hello all,
i am new to RoR programming and am struck with the functional test whole
checking for uniqeness of carriers. If it is not unique,the the bin
shudn''t be created.Can someone help me in correcting my code.
def test_create_failure_cycle_unique
begin
num_bins = Bin.count
post :create, {:bin => { :carrier => carriers(:A), :cycle =>
cycles(:one), :name =>
2006 Apr 04
1
integration tests - 1.1
I?m using the new 1.1 integration test facility? I?m trying to write a
test that sees if a controller redirects to the correct place and
preserves the query string.
Here?s the code:
class LoginRedirectTest < ActionController::IntegrationTest
def test_non_admin_auth
request_uri = "/datafeed/event/report?blah=blah"
get(request_uri)
follow_redirect!
2007 Jul 25
3
autotest + integration testing (follow_redirect!) error
I''ve got an interesting (possibly) problem right now between autotest
and rails integration tests. There are a few things to preface this
with.
Works fine:
rake test
rake test:integration
Blows up:
autotest
Autotest is correctly determining rails and runs tests just fine. One
part of the behavior is that if I save a change in just the
integration test (even hitting cmd+s to trigger a