factories

Pluses and minuses of using Factories in a Rails test suite?

I'm currently looking at a hefty Rails test suite. It's nothing I can get into specifics about, but the run time for the entire suite (unit/functional/some integration) can run upward of 5 minutes. We're completely reliant on fixtures and are we're not mocking and stubbing as much as we should be. Our next few sprints are going to be ...

Rails has_and_belongs_to_many is confusing me with fixtures and factories

General Confusion I have bands which can have 3 genres. I read in a previous SO post that the proper way to handle this is a couple steps: 1) In band.rb has_and_belongs_to_many :genres 2) Create a band_genres join table Even after reading the documentation, I am a bit confused as to what HABTM actually means. I guess I would just n...

How do you create RoR Factory associations with accepts_nested_attributes_for?

As Anton points out (thanks Anton!) my problem is Association Caching in the tests and it seems like I did correctly create the nested_attribute in the Factory. The correct syntax is: Factory.define :job do |f| ... f.vehicles_attributes [{:vin => "1", :model => "ford", :make => "escort"},{:vin => "1", :model => "ford", :make => "es...

C++ Templates and Factories

I've been playing with C++ for a few years now, and want to become adept at using and factories. Are there some good web tutorials and/or textbooks that cover this well? I started programming prior to the wide use of the term "patterns" ('80's)... but when I first saw the term I recognized the "pattern" of it's usage. A good referenc...

Generic factorized data helpers (system.data.commons) vs especialized data helpers (sql server) performance?

Hi, I'm planning to improve the performance of some applications. We generally use factored datahelpers (using System.Data.Common, but we are thinking to specialize some applications that are always going to use sql server. Does anyone know or could test if is increased the performance using specialized classes instead of factorized cl...

What is a Factory Design Pattern in PHP?

This confuses me, in the most simplest terms what does it do? Pretend you are explaining to your mother or someone almost please. ...

Understanding Factories and should I use them?

I have never used Factories before for the simple reason, I don't understand when I need them. I have been working on a little game in my spare time, and I decided to implement FMOD for the sound. I looked at a wrapper designed for OpenAL(different sound setup) and it looked something like... SoundObject* SoundObjectManager* SoundObject...

Rails: Factories and Associations in Functional Tests

I'm trying to figure out why this doesn't work. Let's say you three models, User, Foo and Bar. In order for a bar to be created the user must first create and validate a foo object. Class User #snip! has_many :foos has_many :bars Class Foo #snip! belongs_to :user has_many :bars Class Bar #snip! belongs_to :user belongs_to :foo I'm ...

How can I make this simple C# generics factory work?

I have this design: public interface IFactory<T> { T Create(); T CreateWithSensibleDefaults(); } public class AppleFactory : IFactory<Apple> { ... } public class BananaFactory : IFactory<Banana> { ... } // ... The fictitious Apple and Banana here do not necessarily share any common types (other than object, of course). I don't w...

Symfony 1.4.6 loading factories.yml configuration from task

I have the following configuration set in my factories.yml file... all: mailer: param: transport: class: Swift_SendmailTransport param: command: /usr/sbin/sendmail -oi -t ...to overcome the 'double dot' issue as described here. When I run the following code... $mailer = $this->getMailer(); $mess...

Object Factory Question - using database query information to create objects

I have several objects, like products, order, etc. When I get information from my database I take a row and create one of the types of objects. I then work with that object created. I read this is called a factory. Is there some advantage to doing this? Especially in a loosely typed language like PHP? Thanks edit: is this where I g...