similar to: Testing STI models

Displaying 20 results from an estimated 20000 matches similar to: "Testing STI models"

2006 Mar 18
1
Fixtures and single table inheritance
I''m wondering what the accepted method for doing unit tests on STI models is. I tried to create a fixture for the class but Rails tries to load that data into the non-existent child table. I could create a fixture named for the real, parent table, but then it would be very difficult to test for the individual functionality and integrity of each sub-class. I saw this page
2007 Nov 14
1
New Foxy Fixtures (Rails 2) & STI (Single Table Inheritance)
I''ve got some problems right now using the new model for relationships in fixtures (by label, not by id) and STI. What I''ve got, is a couple of models: Attachment --> FileDownload Version Version has_one file_download with file_download_id on the versions table In my fixtures, I have two FileDownloads in my attachments.yml like so: hemingway_alpha_zip: size: 100
2006 Feb 08
4
Fixture question...
Ok, I''m pretty sure I''ve seen this done before. I have a fixture that isn''t named the same as the table I want to insert the stuff into. Whats the right way to go about this?! Google has failed me! :( -Nick
2008 Jul 20
10
STI and fixtures
Hi all ! Loading fixtures doens''t seems to associate my 2 objects, do know what''s wrong ? In app/ class Manager < Employee has_many :employees, :foreign_key => :reports_to end class Employee < Person belongs_to :manager, :foreign_key => ''reports_to'' end class Person < ActiveRecord::Base belongs_to :address end fixtures for
2005 Dec 15
3
Fixtures and table name
Is there a way to use table name other than the default or to turn it around have multiple fixture files associated to the same table. Here''s my use case: I have multiple unit test classes that all work with the same model class and hence the same database table. However, for each test class I want the data to be in a different state. So I''d like to have something like class
2006 May 09
2
load fixtures
I''m finally getting beyond using basic test fixtures, and a few questions have popped up. Has anyone found ways to do these? 1. Use a test fixture that is named differently from its table name? We''d like to have more than one possible fixture per table. (Or perhaps use test fixtures named similarly but in different directories.) 2. Load a test fixture for one test method only
2008 Jul 05
5
Does RSpec work nicely with UUID primary keys?
I have my application happily generating UUID primary keys using the uuidtools gem. But the auto-generated specifications created by "script/generate rspec_scaffold...", etc, assume that one is using a sequential integer primary key. For those who have hit this same issue, is it just a matter of rewriting the auto-generated specifications to take this into account, or does one have to
2006 Mar 01
5
rails models, logging and testing
Hello, I am using rails 1.0 and I have following questions. Please help me. [1] How can I do logging in the rails models? I checked the wiki but didn''t find anything which I explained how to do logging in models. [2] Say I have a certain model, when I declare a function in the model, and try to use that function from a view or a unit test, I get an error. For views the error occurs
2006 Mar 07
3
STI and unit testing
Hi all, I''m having a bit of a problem with unit testing. I''ve simplified my models to try and get my head round it but I''m still struggling. I''m using STI and trying to write tests for the extended models (code below). I''ve written test cases for the extended models which themselves extend the test case for the parent model, so BarTest extends
2005 Oct 28
2
Accessing fixture
I have a very simple problem. I can''t seem to access a the fixture by name I have a sites.yml with: simple_site: id: 1 name: demo description: A demo site created_on: 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
2007 May 21
2
Rails'' fixtures suck! But what about something like this?
Sorry about the very long email, but this is a hairy topic that''s been annoying me for some time and I decided to try to do something about. Also, if you got this twice, I apologize too, but it didn''t seem to have successfully gone out the first time. Background: ---------- I''ve been dealing with Rails for about a year and a half now. I''ve been using
2005 Dec 14
3
Plugin w/ Migrations and/or Fixtures?
I''m working on a plugin which needs to add both schema and data to the app database, and I''m trying to figure out the best way to do it. I''d like to use a db migration to modify the schema and load the data from a YAML fixture, but Rails doesn''t seem to support migrations for plugins. To do so, the schema_info table would need to change to include a
2006 Jan 16
2
My first test - named fixture not autoloading instance variable
I''m trying to write a test like the one at the bottom of page 148 in Agile Rails. I''m using rails 1.0 I''ve created the fixture correctly I''m pretty sure because the test database table is being populated per the fixture. I have what I think is a simple unit test: ========= require File.dirname(__FILE__) + ''/../test_helper'' class CaseTest
2005 Dec 22
2
nonstandard postgresql sequence names
I''m working with a legacy postgresql database where the names of tables, columns, etc., do not usually follow Rails conventions. I''ve been able to work around it for the most part, but I ran into this: I have the following test: require File.dirname(__FILE__) + ''/../test_helper'' class SponsorTest < Test::Unit::TestCase self.use_transactional_fixtures =
2006 Apr 26
3
Test fixture syntax
OK, I know I''m doing something bone-headed, but I can''t for the life of me figure it out. I''ve read the test fixtures Rdoc about eight dozen times, and it says (to me) that if I have a YAML fixture file, dogs.yml that looks like this: fido: id: 1 breed: Terrier fifi: id: 2 breed: Poodle Then I can include fixtures :dogs in my functional test, and
2006 Dec 14
1
create and destroy fixture manually in method
Hi, My test case has two fixtures and eight methods. But one of the eight methods need one more fixture. How do I solve this? Okay, I put the additional fixture in common place so every method has additional access to the additional fixture. The problem is the additional fixture depend on that two fixtures (foreign key). When I run the test, it complains something like this:
2006 May 23
2
Putting fixtures into subdirectories
I want to organize my fixtures just like the namespace of my models. So for example if I have a model Company::Employee I''d like the fixture to be in fixtures/company/employees.yml. However, I can''t figure out how to specify the path of the fixture file. If I do: fixtures :employees in my unit test it can''t find the fixture file. Any suggestions? Thanks, Todd
2007 Sep 07
4
fixtures in before(:all)
I was planning on using a fixture within a description that didn''t modify the fixture, so I put it in a before(:all) block: describe "Customer", "xml" do fixtures :customers before(:all) do one = customers(:one) end # ... As a result, I got this message: 1) NoMethodError in ''Customer xml before(:all)'' You have a nil object when you
2006 May 09
1
leftover fixture data causing errors
Maybe I''m not getting fixtures, but... I''m having problems as I start using fixtures in functional tests. Data is left in my test database after running functional tests. Not the data created by the test-method (I''m using transactional fixtures), but data from the fixtures themselves. Fixture loading will delete & reload the data again when the test is re-run, but
2007 Dec 01
10
Fixtures Cleanup
All, I''ve been playing a bit with some patches to make the fixture loading and management code a little bit easier to maintain. If I were to start chopping out features, how would you feel about losing: Fixture instantiation, Old school single-file fixtures, CSV fixtures, The ability to specify a subset of fixtures (everything''s always loaded instead), The ability to