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 I''ll have access to a Hash of the model objects in the instance variable @dogs. And further, that the fixture records are "found" and loaded into instance variables named as the fixture. That is, I can also access @fido, and @fido = @dogs["fido"]. However, I am getting no @dogs at all. I do get dogs (local variable), but no @dogs. And I get no @fido or @fifi either. My error? Doc error? Help! Thanks, Steve -- Posted via http://www.ruby-forum.com/.
Steve Crozier wrote:> 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 I''ll have access to a Hash of the model > objects in the instance variable @dogs. And further, that the fixture > records are "found" and loaded into instance variables named as the > fixture. That is, I can also access @fido, and @fido = @dogs["fido"]. > > However, I am getting no @dogs at all. I do get dogs (local variable), > but no @dogs. And I get no @fido or @fifi either. > > My error? Doc error? Help!Doc error. Kind of. There''s a setting called self.use_instanciated_fixtures in test_helper.rb that controls whether the @dogs[:foo] syntax works. As of 1.0, it''s off by default. Instead, you can use the syntax dogs(:foo). -- Alex
Thanks, Alex. I had seen that setting, but had interpreted it differently. I tried it and it works great. Steve Alex Young wrote:> Steve Crozier wrote: >> fifi: >> fixture. That is, I can also access @fido, and @fido = @dogs["fido"]. >> >> However, I am getting no @dogs at all. I do get dogs (local variable), >> but no @dogs. And I get no @fido or @fifi either. >> >> My error? Doc error? Help! > Doc error. Kind of. There''s a setting called > self.use_instanciated_fixtures in test_helper.rb that controls whether > the @dogs[:foo] syntax works. As of 1.0, it''s off by default. Instead, > you can use the syntax dogs(:foo).-- Posted via http://www.ruby-forum.com/.
Assuming you are using the latest rails you use fido = dogs(''fido''). What you are using below from the docs are called instantiated fixtures and they are slow (especially when you have lots of them). See tests/test_helper.rb to see how to turn them back on if you really want to. Otherwise change your tests to get the fixtures as you need them as above. -- Owen Steve Crozier wrote:> 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 I''ll have access to a Hash of the model > objects in the instance variable @dogs. And further, that the fixture > records are "found" and loaded into instance variables named as the > fixture. That is, I can also access @fido, and @fido = @dogs["fido"]. > > However, I am getting no @dogs at all. I do get dogs (local variable), > but no @dogs. And I get no @fido or @fifi either. > > My error? Doc error? Help! > > Thanks, > > Steve > >
Reasonably Related Threads
- package.skeleton does invalide regular name, bis... (PR#12020)
- Security of ssh across a LAN, public key versus password
- Call for testing: OpenSSH 8.4
- OpenSSH not requesting touch on FIDO keys (was: OpenSSH not requesting PIN code for YubiKey)
- Call for testing: OpenSSH 8.2