0

I 'm trying to make a of my first application on ruby ... Thats's my test file

   require File.dirname(__FILE__) + '/../test_helper'

   class SupplierTest < ActiveSupport::TestCase
        fixtures :suppliers
        def test_name
           supplier=Supplier.create(:name => 'juan' , :province => nil)
           assert_equal 'juan' , supplier.get_name
        end
   end

and the fixture

   juan: 
     id:1
     name:juan
     province:nil

and the result is

    Psych::SyntaxError: (<unknown>): could not find expected ':' while scanning    a  simple key at line 8 column 1
user3447780
  • 97
  • 1
  • 6

1 Answers1

1

YAML requires a space between the : and the value, so try updating your fixture to:

juan: 
  id: 1
  name: juan
  province: 

(writing nil in province will result in the value "nil". Leaving it empty will result in a true nil value)

Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
  • I 've cchanged the fixture adding the spaces bur now says ActiveRecord::Fixture::FormatError: – user3447780 Apr 22 '14 at 08:55
  • Double check that your YAML is properly formatted, if it is, check if maybe this is your problem: http://stackoverflow.com/questions/15406670/after-upgrading-to-rails-3-2-i-see-activerecordfixtureformaterror-a-yaml-er – Uri Agassi Apr 22 '14 at 09:01
  • 1
    Check YAML syntax and correctness using any tool online or offline. Eg. yaml-online-parser.appspot.com – SreekanthGS Apr 22 '14 at 09:28
  • To explicitly express Ruby's `nil` in YAML, use [`null`](http://yaml.org/type/null.html). – Holger Just Apr 22 '14 at 11:14