Displaying 20 results from an estimated 43 matches for "test_create".
2006 Aug 11
5
Unit tests - NilClass problem
...:
http://blog.codahale.com/2005/12/23/a-rails-howto-simplify-your-unit-tests/
My customer_test.rb looks like this:
require File.dirname(__FILE__) + ''/../test_helper''
class CustomerTest < Test::Unit::TestCase
fixtures :customers
# Replace this with your real tests.
def test_create
test_creation_of :model => Customer,
:record => @customer,
:fixture => @first,
:attributes => [:id, :name, :contact_firstname,
:contact_lastname, :contact_address, :contact_country, :contact_state,
:contact_email, :contact_p...
2006 Mar 19
2
Unit test confusion
...way of doing it? I''d guess the one that actually
works is right, but there''s a lot of stuff on google about the other
ways that I can''t get to work.
The actual error messages for the failed assertions are different:
@artists["beatles"]["name"]:
test_create(ArtistTest):
NoMethodError: You have a nil object when you didn''t expect it!
The error occured while evaluating nil.name
test/unit/artist_test.rb:15:in `test_create''
@beatles.name:
test_create(ArtistTest):
NoMethodError: You have a nil object when you didn''t expect...
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 + '' '' +
@borrower.LastName + ''...
2006 Apr 16
5
Newbie Problems with pluralization
...quire File.dirname(__FILE__) + ''/../test_helper''
class TaxGroupTest < Test::Unit::TestCase
fixtures :taxes, :tax_groups, :taxes_tax_groups
# Replace this with your real tests.
def setup
@taxgroup = TaxGroup.find(1)
end
# Replace this with your real tests.
def test_create
assert_equal 1, @taxgroup.id
assert_equal "Ontario", @taxgroup.name
assert_equal "Ontario w/ pst", @taxgroup.description
assert_equal "GST", @taxgroup.taxes[1].name
end
end
in which i get the following error:
1) Error:
test_create(TaxGroupTest):
A...
2006 May 05
3
posting xml in functional test
Hello,
I''m trying to write a functional test for a simple CRUD controller which
accepts / emits xml in a REST- like fashion. However the following code
won''t work for me - an exception is generated
def test_create
post :create, ''<person><name>john</name></person>'',
{''Content-Type''=>''application/xml''}
assert_response 200
end
Anyone give me a hint where I''m going wrong ?
thanks in advance
-------------- next part --...
2006 Jun 08
1
fixtures instance variable naming
...odel.
have a news_releases.yml as a fixture with:
first:
id: 1
title: my first release
body: this is still my first test of a news release
publish: 0
date_publication: 2006-06-06 17:28:00
in news_release_test.rb, i have
def setup
@news_release = NewsRelease.find(1)
end
def test_create
assert_kind_of NewsRelease, @news_release
assert_equal @news_release["first"]["id"], @news_release.id
end
and i receive:
"NoMethodError: You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured whi...
2006 Jul 24
1
All functional tests fail with RoutingError
All,
I''m using InstantRails 1.0 on Windows XP and all my functional
(controller) tests fail with ActionController::RoutingError, although
the actions work OK through a web server/browser. Here''s an example of
an error:
1) Error:
test_create(AdminControllerTest):
ActionController::RoutingError: No url can be generated for the hash
{:controlle
r=>"admin", :action=>"create"}
generated_code/routing/generation.rb:92:in `generate_default_path''
c:/Install/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gem...
2006 Jul 06
6
Functional tsts
Hi all,
I have created projects module in my application using scaffold,
and it created me everything, and all the modules are working except the
functional test. This is the error
1) Failure:
test_create(ProjectsControllerTest)
[test/functional/projects_controller_test.rb
:55]:
Expected response to be a <:redirect>, but was <200>
8 tests, 25 assertions, 1 failures, 0 errors
50 def test_create
51 num_projects = Project.count
52
53 post :create, :project => {}
54...
2006 Mar 20
2
Testing Models And Fixtures
...y
created_at: 2006-02-01 00:00:00
updated_at: 2006_02-02 00:00:00
===========
post_test.rb
===========
require File.dirname(__FILE__) + ''/../test_helper''
class PostTest < Test::Unit::TestCase
fixtures :posts
def setup
@post = Post.find(1)
end
def test_create
assert_kind_of Post, @basic_post
assert_equal @basic_post.id, @post.id
assert_equal @basic_post.title, @post.title
assert_equal @basic_post.body, @post.body
assert_equal @basic_post.created_at,
@post.created_at_before_type_cast
assert_equal @basic...
2005 Oct 28
2
Accessing fixture
...2005-10-25 00:00:00
updated_on: 2005-10-25 00:00:00
And I have a test class as:
require File.dirname(__FILE__) + ''/../test_helper''
class SiteTest < Test::Unit::TestCase
fixtures :sites,
:contenttypes,
:contentitems
def setup
end
def test_create
puts @sites
puts @sites["simple_site"]
end
end
When I attempt to print out the fixture I just get
nil. I thought you reference the fixture as an
instance variable with the name of the fixture file.
So I use "@sites" since the fixtures are located in
sites.yml...
2005 Feb 09
1
[DEFECT] ''validates_inclusion_of'' not working as expected (couldn''t post to Trac as it gave me an error)
...Task < ActiveRecord::Base
belongs_to :project
validates_inclusion_of :project, :in Project.find_all
end
---
You would expect the validation to work properly (Project.find_all
returns an enumerable), but Ruby complains of a syntax error when
performing the validation callback:
---
1) Error:
test_create(TasksControllerTest):
SyntaxError: compile error
/usr/local/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/validations.rb:378:
syntax error
errors.add("project", "is not included in the list") unless
([#<Project:0xb7d47a88 @attributes={"name"=>&...
2006 Feb 15
2
First unit test fails
...gile'' chapter 12
''Testing''. I''ve followed the steps carefully, setting up a fixture and
unit test to check the creation of an order. When I run the test I get
the following:
Loaded suite test/unit/order_test
Started
F
Finished in 0.108008 seconds.
1) Failure:
test_create(OrderTest) [test/unit/order_test.rb:17]:
<"Wed Feb 15 12:56:26 GMT 2006"> expected but was
<Wed Feb 15 12:56:26 GMT 2006>.
1 tests, 6 assertions, 1 failures, 0 errors
My fixture populates the mySQL order table with: ''2006-02-15 12:56:26''
Is there some kind...
2005 Feb 19
0
[Error] Using validates_presence_of for datetime field causes parse error?
...| |
In my model, I have
validates_presence_of :creation_date
And the relevant portion of the unit testing ruby file is:
def setup
@student_survey = StudentSurvey.new
#<snip>
@student_survey.creation_date = DateTime.now
end
def test_create
@student_survey.save
end
When I run this unit test, I get:
1) Error:
test_create(StudentSurveyTest):
NoMethodError: private method `gsub!'' called for #<DateTime:
11776418931730081/4800000000,-5/24,2299161>
/usr/lib/ruby/1.8/date/format.rb:238:in `_parse'...
2006 May 16
3
Testing How To Question
I''m using the functional test for a method like this:
def test_create
post :create, :phase => ''copynew'', :id => 1
assert_response :success
assert_template ''create''
assert_tag :content => ''New Item''
assert_not_nil @item
end
This posts a request to the create method in the controller. Is the...
2006 Jun 08
2
accessing fixtures in tests
...one can make it suggestions.
i have news_release_test.rb, using new_releases.yml as the fixture file
according to the agile book, i should be able to access the fixture
properties within my test as such:
assert_equal @first_test.id , @news_release.id
unfortunately, i try that and get:
"test_create(NewsReleaseTest):
RuntimeError: Called id for nil, which would mistakenly be 4 -- if
you really wanted the id of nil, use object_id"
after looking on api.rubyonrails.com, i saw and tried this:
@news_releases["first_test"]["id"]
and now i get the following error:
"...
2006 Apr 13
1
Setting up Testing model, getting an error
I setup a testing model in my Depot web app from the Agile Web
Development with Rails book and came up with the following errors:
Loaded suite test/unit/product_test
Started
EE
Finished in 0.050279 seconds.
1) Error:
test_create(ProductTest):
Errno::ENOENT: No such file or directory -
/Users/Mike/Sites/depot/config/../test/fixtures/categories
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:327:in
`open''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_r...
2007 Mar 22
1
Functional test and flash with an error
...t=>"User James Apps was successfully created.",
:attributes=>{:id=>"notice"}, :tag=>"div"} in the file application.rb.
I tried using a regular expression - /#{user.first_name}/ , but that
wouldn''t work either
user_controller_test.rb
1) Failure:
test_create(Admin::UserControllerTest)
[/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/assertions/tag_assertions.rb:102:in
`assert_tag''
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/assertions/tag_assertions.rb:99:in
`clean_backtrace''
/...
2006 Jan 03
3
Rails Noob Question
...baby steps. Ran into a hitch when it was saying that my
fixture
variable was nil:
require File.dirname(__FILE__) + ''/../test_helper''
class MessageTest < Test::Unit::TestCase
fixtures :messages, :tags, :messages_tags
def setup
@message = Message.find(1)
end
def test_create
assert_kind_of Message, @message
assert_not_nil @messages
# assert_equal @messages["peace_message"].title, @message.title
end
end
The three fixtures exist (messages, tags, messages_tags) and have data.
Brute force tests (assert_equal "my message title", @message.ti...
2005 Dec 15
4
Order of tests matters???
I have a problem with tests. I always thought that the order of tests doesn''t
matter because the fixtures are reloaded before every test method. However, I''ve
just discovered that this isn''t true.
This is a quote from the "Guide to testing the rails" howto:
"... if we had another test method, we wouldn’t have 10 users on the 2nd test
because they would
2009 May 18
0
[PATCH server] fixed functional tests after recent controller refactoring and managed node controller fixes.
...::TestCase
assert assigns(:host).valid?
end
- def test_new
- get :new, :hardware_pool_id => pools(:default).id
-
- assert_response :redirect
- assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:default).id
- end
-
- def test_create
- num_hosts = Host.count
-
- post :create, :host => {}
-
- assert_response :redirect
- assert_redirected_to :controller => 'dashboard'
-
- assert_equal num_hosts, Host.count
- end
-
- def test_edit
- get :edit, :id => @host_id
-
- assert_response :redirect
-...