similar to: problem with assert_raise in Unit Test

Displaying 20 results from an estimated 2000 matches similar to: "problem with assert_raise in Unit Test"

2006 Nov 22
1
Using assert_raise
When Im writing tests and I do: assert_raise RuntimeError, raise("raising") Then I run the test is says the test failed and I have 1 error: RuntimeError: hey Should assert_raise catch that error and say the test passed? Thanks for your time and help. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because
2006 May 09
7
going crazy!!!!!! ActiveRecord::StatementInvalid in Project
any suggestions on why I am gaining this error. ActiveRecord::StatementInvalid in ProjectsController#create Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' , , , , )'' at line 1: INSERT INTO projects (`name`, `date_created`, `quote_id`, `client_id`, `description`, `user_id`)
2008 Oct 24
1
rescue_from and assert_raise
Since commit 5e3517ea7b9fbd460f772bffc9212d882011f2bc, rescue_from is now being handled in tests. I''ve been using rescue_from to handle custom exceptions and testing that those exceptions are raised in functional tests with assert_raise. This no longer works now. What''s the proper way to test this now? --~--~---------~--~----~------------~-------~--~----~ You received this
2006 Jan 28
1
Unit Tests Behavior
Hi, Working on unit tests and I have a few cascade delete constraints I am testing. The unit tests stop at the first assert_raise test. Is this typical? def test_destroy_all_cascade_delete assert_equal 1, Iep.find(:first).client_id assert_equal 1, Encounter.find(:first).client_id @client.destroy assert_raise(ActiveRecord::RecordNotFound) { Iep.find(1) } <--
2006 Mar 08
0
Unit tests dynamic finders
Hi all, I am having a problem with unit tests. Whenever I have a dependency between two models (B depends on A) deleting A should also delete B. This is simple with the dependent parameter in the model file of A. But when I write a test the dependency seems to work, I can''t find the answer with id 1 anymore(Answer.find(1)). But I appearently _do_ find it with
2010 Jan 22
0
Problem with acts_as_commentable Plugin
Hi, i''m trying to use the acts as commentable Plugin, bit it seems not to work: My Commentable Model is the Task Class. if i try to get the Comments of a Task Object , e.g. task.find(:first) task.comments it occurs this error: ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ''comments.task_id'' in ''where clause'': SELECT * FROM
2006 Feb 23
2
find_by_sql aliasing issue when accessing attributes
I was recently having problems accessing attributes in an object. Can somebody explain to me why this is, and if it is a bug? I have the following code: @archives = RapturePost.find_by_sql "select distinct date_format(rapture_posts.date_created,''%Y-%m'') date_created from rapture_posts where rapture_posts.site_id = 1 order by rapture_posts.date_created desc" I
2006 Feb 22
2
accessing an attribute within an embedded object
When I dump an instance variable to the web browser using object.inspect I get the following: This: <%= debug archive.inspect %> Yields this: #<RapturePost:0x2aaaacada118 @attributes={\"date_created\"=>\"2006-02\"}>" How do I access that date created value? Neither of the following work. The don''t give me the actual date value, only nil or
2006 Jan 19
0
file_column error: tmp file created but not actual
Hi When I submit the form with field_column, the actual image is not uploaded, only temp files are crreated and I dont see actual file created and the image file name is not in the database and get "fieldWithErrors". Then if submit again, the actual file in created and an database record is generated. Here is the log file. I print @params and @wallpaper. I find the following: 1st
2005 Dec 20
0
Problem destroying in unit tests with HABTM
Hi converted two of my models to HABTM today but I am having a real hard time getting my unit tests to pass now. Specifically, when I destroy a record I get this error: ...many many lines of this above... (eval):4:in `destroy_without_habtm_shim_for_categories'' (eval):4:in `destroy_without_habtm_shim_for_categories'' (eval):4:in
2006 Jun 12
3
Default value for model var
I know this has got to be a really dumb question, but here goes anyway. I''ve got a model with an associated table. One of the columns in the table is ''date_created'', which I want to be set to the date/time each row was added to the table. Seems to me that setting this in the initialize method for the model would be the right thing to do,... class MyThing <
2006 Mar 21
3
Newbie - ActiveRecord relationships
So I''ve worked through Agile Web Development with Rails and I''m now trying my first little app to get into the swing of things. Its a task tracking app where people can create tasks and assign them to others, and also log time against the tasks. I''m having trouble working out the model relationships. This is what I''ve got so far, but its not right as
2007 May 31
0
Rails AR/SQLServer Unit Test: [6912] failed (but getting better)
"bitsweat" has given AR/SQLServer some love, but it''s still unhappy... http://dev.rubyonrails.org/changeset/6912 ------------------------------------------------------------------------ r6912 | bitsweat | 2007-05-31 10:15:56 -0700 (Thu, 31 May 2007) | 1 line Fix an edge case with find with a list of ids, limit, and offset. Closes #8437.
2008 Apr 23
0
self referential (n-n relationship) belongs many controller
Hi all, I ve some troubles in my small acpplication (only 2 tables). I want to follow up tasks but these tasks are linked to others tasks. So I ve tried to do store the nn relationship in other table called links 1st table : tasks columns : id | infos neutral... (as title, description etc ...) ----------------------------------------------------------------------------------- model : class
2006 Mar 09
4
habtm questions
I''ve got some of this working but other parts are ellusive. I have CREATE TABLE `bags` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL default '''', PRIMARY KEY (`id`) CREATE TABLE `packages` ( `id` int(255) NOT NULL auto_increment, `name` varchar(255) NOT NULL default '''', PRIMARY KEY (`id`) CREATE TABLE
2006 May 06
6
assert_raises --> how does it work?
Hi, I have this code fragment: def test_delete_concept assert_not_nil Concept.find(concepts(:entreprise).id) get :delete_concept, {:concept_id => concepts(:entreprise).id} assert_raises :RecordNotFound, Concept.find(concepts(:entreprise).id) end basicaly, on the first line, I make sure that the concept exist in the DB. On the second line I delete the concept fron the DB.
2006 Jul 18
2
Testing which RuntimeError is raised
I am just starting to use unit testing. Way cool. But I am not finding very clear docs on assert_raise. I have managed to write a test that tells me that the destroy I am trying to test fails with a RuntimeError (as it should). However, I would really like to test that it rails for the specific reason I have in my model. How can I get more specific? Am I going to have to create my own exception
2005 Dec 22
1
How to write unit tests with respect to model callbacks?
Hello, I am exploring the "Testing" part of Rails, but It seems some things work differently than I thought it would. Consider the following model: class Client < ActiveRecord::Base has_one :project def after_create Project.new(:name => self.name, :is_client => true, :client_id => self.id).save end def after_update
2006 Jul 16
4
Calculations across multiple tables
I have a time tracking app where (pseudo-code) Client has_many Task has_many TimeRecord TimeRecord start_at, :datetime end_at, :datetime What I''m trying to do (and I have done using find_by_sql in the past) is get a sum of the timespan given by ended_at - begun_at for each client. Is it naive to imagine that AR''s calculations will span relations to provide a grouped
2009 Jun 29
0
[PATCH server] Add svc_vm_actions method to VmService.
Also includes a couple minor model changes to support better error reporting. This method was added so that a client could submit multiple vms to the service layer in one call and get back appropriate messages showing any failures without those failures also causing the entire call to fail, or forcing the client to implement handling (begin/rescue blocks) of these errors to continue through the