... who go running for help whenever they encounter a tiny problem ... but help. After the recent help from Francisco Hernandez I can now run the first of the test for my rails app. I am having problems getting a fixture to run. Whenever I add any content to it I get the following error: Fixture::FormatError: a YAML error occured parsing ./test/unit/../fixtures/projects.yml c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:218:in `read_fixture_files'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:197:in `initialize'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:161:in `new'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:161:in `create_fixtures'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:160:in `map'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:160:in `create_fixtures'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:147:in `instantiate_fixtures'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:359:in `instantiate_fixtures'' c:/tools/ruby/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/fixtures.rb:344:in `setup'' My table is called projects and has two fields id and name I am trying to use a file in the following format --- project1: id: 1 name: p1 --- For the life of me I can''t figure out what I have done wrong. Thanks (again), R.
Rob Lally wrote:> ... who go running for help whenever they encounter a tiny problem ... > but help. > > After the recent help from Francisco Hernandez I can now run the first > of the test for my rails app. I am having problems getting a fixture to > run. > > My table is called projects and has two fields id and name > > I am trying to use a file in the following format > --- > > project1: > id: 1 > name: p1 > > --- > > For the life of me I can''t figure out what I have done wrong.And now in a spectacular show of bad form I am going to answer my own question. Or at least attempt to. The YAML fixtures seem to respect 2 spaces as an indent and nothing else; not tabs and not 1,4 or 8 spaces. Or so it seems to me since I changed to another editor that was set to use 2 spaces and voila, everything popped into life. Is this correct? I can''t find it written down anywhere. R.
* Rob Lally (ruby-TLoEj6T5Eh2QE6UZXBUcsgC/G2K4zDHf@public.gmane.org) [050128 10:00]:> The YAML fixtures seem to respect 2 spaces as an indent and nothing else; > not tabs and not 1,4 or 8 spaces.This is correct. This is the expected behavior. Rick -- http://www.rickbradley.com MUPRN: 723 | and beginning to random email haiku | put it into practice in | their own neighborhoods.
I had the same hang-up and arrived at the same conclusion. Why can''t it autodetect tabs/spaces? (i.e. the first time it sees leading whitespace it assumes that the rest of the block will be delimited by the same amount and type of whitespace, reporting an error if the amount of whitespace decreases by less than one increment) The Python language should, in theory have the exact same problem, being whitespace delimited, but so long as you don''t mix tabs and spaces and make it look good in your editor, it will execute as expected. In 15,000+ lines of whitespace-delimited python code I haven''t once caused a bug due to whitespace dependence yet in my first fifteen lines of YAML I was already hitting a wall. This seems like a principle of least surprise violation--if it''s consistent and looks right in a sane text editor, YAML should parse it correctly. How can this be remedied? Brian On Fri, 28 Jan 2005 10:23:24 -0500, Rick Bradley <rick-xSCPAUIMY+WN9aS15agKxg@public.gmane.org> wrote:> * Rob Lally (ruby-TLoEj6T5Eh2QE6UZXBUcsgC/G2K4zDHf@public.gmane.org) [050128 10:00]: > > The YAML fixtures seem to respect 2 spaces as an indent and nothing else; > > not tabs and not 1,4 or 8 spaces. > > This is correct. This is the expected behavior. > > Rick > -- > http://www.rickbradley.com MUPRN: 723 > | and beginning to > random email haiku | put it into practice in > | their own neighborhoods. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- The years ahead pick up their dark bags. They move closer. There''s a slight rise in the silence then nothing. -- (If you''re receiving this in response to mail sent to bluczkie-OM76b2Iv3yLQjUSlxSEPGw@public.gmane.org, don''t be concerned This is my new address, but mail will be forwarded here indefinitely)
Hi Brian, YAML only accepts spaces and not tabs as delimiters (see http://www.yaml.org/faq.html). But it accepts different numbers of spaces (see http://yaml.org/spec/current.html#id2519916) ! I have tested this with my Rails 0.9.4.1 installation and it worked fine with 1, 2 and 4 spaces but (as expected) not with tabs. So everything seems to work as defined in the YAML-specs! Michael
On Fri, 28 Jan 2005 12:14:30 -0500, Brian L. <zorander-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I had the same hang-up and arrived at the same conclusion. > > Why can''t it autodetect tabs/spaces? (i.e. the first time it sees > leading whitespace it assumes that the rest of the block will be > delimited by the same amount and type of whitespace, reporting an > error if the amount of whitespace decreases by less than one > increment) The Python language should, in theory have the exact same > problem, being whitespace delimited, but so long as you don''t mix tabs > and spaces and make it look good in your editor, it will execute as > expected. In 15,000+ lines of whitespace-delimited python code I > haven''t once caused a bug due to whitespace dependence yet in my first > fifteen lines of YAML I was already hitting a wall.YAML doesn''t accept tabs. Read the FAQ on it. I happen to agree with YAML''s choice. It should, however, accept a varying number of spaces (i.e. 2, 4, 8) as being an indent. Joe