2017-05-02 4 views
0

RSpec에서이 오브젝트를 생성했습니다. 두 번째에 unexpected token tCOMMA 오류가 발생합니다. },이 오류가 발생하는 이유는 무엇입니까?예기치 않은 토큰 레일 tCOMMA

let(:test) { 
    { abc: 
     [{ bde: 
     { attribute1: 170.0, 
      attribute2: '2016-12-14', 
      attribute3: 'self entered', 
      attribute4: 'high', 
      attribute5: 
      { attribute6: 'low', 
       attribute7: false, 
       attribute8: nil, 
       attribute9: 129, 
       attribute0: 'mg/dL'}, 
      { attribute11: 'moderate', 
       attribute12: false, 
       attribute13: 130, 
       attribute14: 159, 
       attribute15: 'mg/dL' }, # getting error unexpected token tCOMMA 
      { attribute16: 'high', 
       attribute17: true, 
       attribute18: 160, 
       attribute19: nil, 
       attribute20: 'mg/dL' } 
     } 
     }] 
    }} 
+0

코드를 올바르게 포맷하면'attribute5'는 배열이됩니다. – Bohdan

답변

0

코드에서 attribute5은 해시가 아니라 배열입니다. 이 코드를보십시오 :

let(:test) { 
      { 
       abc: [{ 
       bde: { 
       attribute1: 170.0, 
       attribute2: '2016-12-14', 
       attribute3: 'self entered', 
       attribute4: 'high', 
       attribute5: [{ 
        attribute6: 'low', 
        attribute7: false, 
        attribute8: nil, 
        attribute9: 129, 
        attribute0: 'mg/dL' 
       }, 
       { 
        attribute11: 'moderate', 
        attribute12: false, 
        attribute13: 130, 
        attribute14: 159, 
        attribute15: 'mg/dL' 
       }, 
       { 
        attribute16: 'high', 
        attribute17: true, 
        attribute18: 160, 
        attribute19: nil, 
        attribute20: 'mg/dL' 
       }] 
       } 
      }] 
      } 
     } 
+0

고마워요. 나는 그것을 시도했지만 Rspec을 실행할 때 오류가 '정의되지 않은 메소드'키를 얻었습니까? ' for # ' – user938438932