similar to: Unit tests dynamic finders

Displaying 20 results from an estimated 400 matches similar to: "Unit tests dynamic finders"

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 Feb 01
3
Test data life cycle confusion
Hi, It states on page 140 of Agile Web Development with Rails: Here?s the bottom line: even if a test method updates the test database, the database is put back to its default state before the next test method is run. This is important because we don?t want tests to become dependent on the results of previous tests. Well, I''ve been running into a brick wall with some functional tests
2006 May 03
1
Test not Reseting
My test are not resetting for each method in the test class. It was promised to me on page 146 of Agile Web Development on Rails that it would. Am I doing something wrong? The "@delete_victim = User.find(4)" bust the setup class each time it comes around, even though that is in my users.yml class UserTest < Test::Unit::TestCase fixtures :users def setup
2006 Mar 20
2
Testing Models And Fixtures
I have finally decided to look into testing and I am going through the examples in the AWDWR book and I tried the following and it does not work... even though I don''t see why it shouldn''t. =========== posts.yml =========== basic_post: id: 1 title: Title body: Body created_at: 2006-02-01 00:00:00 updated_at: 2006_02-02 00:00:00
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 Apr 04
2
Syntax Error in find()
Maybe I misunderstand the parameterization of find(), I am getting this syntax error for <% @choices = Choic e.find(:all, :conditions => "question_id" = question.id, :order => "order") %> ---- ERROR LOG ---- ActionView::TemplateError (compile error ../config/../app/views/admin/test/show.rhtml:37: syntax error _erbout.concat " "; @choices =
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 Apr 21
2
destory Test Case Messes up all tests
I am trying to create unit tests for my users model but when I add a test that destroys a user, that user is not available in any of the other test. If I remove the test that destroys the user all my other tests work again. All the fixtures are suppose be reloaded between tests right? Here is my testcase : require File.dirname(__FILE__) + ''/../test_helper'' class UserTest
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 Jan 04
4
many to many link table compound primary key explosion
Hi, I have a many-to-many relationship between two tables, questions and answers. My MySQL schema for the link table creates a primary key from the two fields to prevent duplicate records. When I add the same answer to the same question more than once, rails attempts to create a duplicate record and explodes with a MySQL error: MysqlError: Duplicate entry ''3-3'' for key 1:
2006 Jul 01
4
Radio_button in loop problem
Hi all, I can''t figure out why my radio_buttons won''t reflect the values stored in my database. I read through some of the previous posts -- is it true that they don''t work with integers? This is the code I''m using: <% for question in @survey.questions %> <%= debug question %> <%= radio_button ( "question", :question_id,
2012 Feb 23
1
Bug in nested_attributes_for: question about best way to patch
I''ve discovered what I''m pretty confident is unexpected behavior in accepts_nested_attributes_for, and am developing a patch, but I''ve encountered a question about how the core team would prefer the implementation to look. Here''s the bug: when assigning to a belongs_to relationship (and I believe one-to-one, but I haven''t verified yet) if you mark the
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 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
2006 Jan 19
8
Passing variables across forms
I''ve been reading my Agile Dev book over and over again, but I can''t wrap my head around how to do this. There''s a question and answer portion site of my site. You begin the process by adding a question to the database. After that, the program should redirect you straight to adding an answer for that question. The problem is, I don''t know how to keep
2006 Mar 10
0
Multiple radio buttons for defining multiple objects?
Hi, I''ve been working on a multiple choice Question/Answer system. The response object (analagous to a lineitem) has a question_id, user_id, and the actual response. What''s a good way of making a form with multiple response objects which are created from the radio_button helper? Right now I''ve got the following code:
2011 Apr 21
0
Get data from 2 tables
Hi, i have 4 tables: questions, answers, users, and inquiries (relationship) def index question_id = params[:id].to_i question = Question.find(question_id) @answers = question.answers respond_to do |format| format.ext_json { render :json => @answers.to_ext_json(:class => Answer) } end end I have several scaffold in extjs, when I click on row, i get
2012 Oct 06
0
rails 3.2 question/answer with a through table
I have a person has many questions through person_questions. I have an extra column in the join table for the answer. The section below works for a new submit but when I edit I get 3 each with the first 2 of each selected tand the third not so I get 6 check boxes some selected some not. Is there a way to get this to work properly os just the questions in the db show up once each with the
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
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