fixtures

JUnit parallel to Rails Fixtures?

My team has a set of POJO's that we build up to pass into our code and test various functions. For example we have an Address class which contains address information. It doesn't make sense to constantly rebuild this class every time we have to whack an address onto an object to test something. I am thinking that something like Rails'...

Rails Fixtures vs. Mocks

Hi there, I'm developing a Rails app, and I was just talking with my colleague that we have a mix of fixtures and mocks in our tests, which we're doing using cucumber and Rspec. The question would be: when should each one be used? ...

Ruby fixtures error with password column

I am trying to load a fixture for my tests which has a password column (binary datatype). The tool i am using uses EzCrypto gem for encrypting and decrypting passwords before they are stored/retrieved. Now if my column is binary i thought rails would automatically store the password as encrypted - but all i get is: 1) Error: test_is_wor...

Rail test case fixtures not loading

Rails appears to not be loading any fixtures for unit or functional tests. I have a simple 'products.yml' that parses and appears correct: ruby: title: Programming Ruby 1.9 description: Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programs delivered fast, you should...

Specify database engine to use in fixtures

Is there a way to specify the database engine to be used for fixtures in CakePHP test fixtures? Some of my models depend on database transactions, and I would like to write some tests for their correct behavior. Currently I'm simply auto-importing the schema, but the tables get created with MySQL's standard MyISAM engine, which doesn't s...

Multiple References in Doctrine Fixtures

I have following models: class User extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn ( 'username', 'string', 20 ); $this->hasColumn ( 'password', 'string', 40 ); $this->hasColumn ( 'salt', 'string', 40 ); $this->hasColumn ( 'email', 'string', 80 ); } public fu...

I dump data to a yml file, but can't load. Is it a "to_yaml" bug?

I dump the data from database to "test/fixtures/*.yml", but when I use rake db:fixtures:load, it complains the content of yml is invalid. Following is the content of my yml: answer_00016: id: 16 content: |- <% output_once :define_aaa do %> Your stuff here <% end %> Notice, the <% ... %> par...

How to dump the database to yaml file with content '<% abc do %>ddd<% end %>'?

In my database, there are some text content, one of them is: <% abc do %> ddd <% end %> When I dumped it to yaml with to_yaml(), it is like: content: |- <% abc do %> ddd <% end %> And then, when I use rake db:fixtures:load, such error occurs: The exact error was: NoMethodError: undefined method 'abc' for main:Object...

How to load the data from a .yml file to database?

There is a table questions, and a data file questions.yml. Assume there is no 'Question' model. 'questions.yml' has some recodes dump from the table. --- questions_001: title: ttt1 content: ccc1 questions_002: title: ttt2 content: ccc2 I want to load the data from the yml file, insert them to database. But I can't use rake db...

symfony fixtures: set ondelete: CASCADE on refclass table

Hi! I'm using symfony 1.4.5, Doctrine 1.2 and Mysql 5. In my schema.yml I have a few Many-to-Many relations which work great. But I need the joining table to have onDelete: CASCADE. Now for doctrine it is needed to add onDelete: CASCADE on the side where the foreignkey exists but since the refclass does not have any relations in the ...

How to lazily evaluate ORM call after fixtures are loaded into db in Django?

I've got a module pagetypes.py that extracts a couple of constants (I shouldn't really use word constant here) from the db for later reuse: def _get_page_type_(type): return PageType.objects.get(type=type) PAGE_TYPE_MAIN = _get_page_type_('Main') PAGE_TYPE_OTHER = _get_page_type_('Other') then somewhere in views I do: import pag...

loading sample data in rails

when a user created a new account on my site, id like to load sample data into his account. I would have done this easily with fixtures but the problem is, the sample data needs to know the new account id, so i need to pass this to the fixtures, but i don't know if its possible. That's my idea, but I am open to other best way to load sa...

use rails fixture object in another fixture file

I would like to use an object within a fixtures-file that was instantiated within another fixtures file. Something like the following (which is not working): monitor_france: objecttype_id: 2 name1: i-france-1 name2: <%= monitors(:big_brother).name %> In case you wonder why I try weird things like this: I'm dealing with a legacy ...

HTML code in Rails YAML-fixtures

HI, i have an "Article" model, that has HTML as it's content. I have created some test data with YAML fixtures and faced following problem: As i say "rake db:fixtures:load", following error appears: ArgumentError: syntax error on line 22, col 0: <li>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ...

How do I properly setup transactional fixtures in Rails?

I just started a new project yesterday and I'm having a lot of very strange transactional fixture problems. It sounds like this is something of an issue with Rails, so I'm hoping StackOverflow can help. Here's the rundown. Coworkers can run tests fine. They are running Mac OS X; I'm running Ubuntu. When use_transactional_fixtures is tr...

Symfony doctrine data-load segmentation fault

Hi guys, I'm working through the Symfony Jobeet tutorial and am getting a segmentation fault when trying to load data from my fixtures files. PHP 5.2.6-1+lenny8 with Suhosin-Patch 0.9.6.2 (cli), S symfony version 1.4.5 I'm using the Doctrine plugin. My fixtures below: /data/fixtures/categories.yml JobeetCategory: design: name:...

Problem with HABTM and join table in Rails

I have a simple model: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role < ActiveRecord::Base has_and_belongs_to_many :users end I have created a simple join table: class CreateUsersRoles < ActiveRecord::Migration def self.up create_table :users_roles, :id => false do |t| t.integer :user...

factory_girl + rspec doesn't seem to roll back changes after each example

Similar to the problem described here: http://rpheath.com/posts/411-how-to-use-factory-girl-with-rspec in Short (shorten'd code): spec_helper: config.use_transactional_fixtures = true config.use_instantiated_fixtures = false factories.rb: Factory.define :state do f.name "NY" end in my spec before(:each) do @static_model = ...

Bidirectional relationship in yaml

Hello, I am using Snakeyaml for building my domain graph. I couldn't find the right syntax for it. Please see the domain model, and the yaml. public class Person { String fullname; @OneToMany(mappedBy="person",cascade=CascadeType.ALL) public List<Role> roles; } public class Role { public RoleType roleType...

Django Fixtures Error: Unknown Applicaiton

I have a project w/ multiple apps. I am attempting to use the dumpdata command to create a fixture for each app. Calling dumpdata on a given app seems to work well. This prints the data to the console: python manage.py dumpdata myapp However, when I attempt to create a json file containing the dumped data: python manage.py dumpdat...