2015-06-28 60 views
1

我正在使用Rspec版本3,並且我有一個has_attributes匹配器的問題。Rspec have_attributes匹配器

的代碼我測試:

it 'will match class instances with #have_attributes' do 
     Person = Struct.new(:name, :age) 
     person = Person.new("Jim", 32) 

     expect(person).to have_attributes(:name => "Jim", :age => 32) 

    end 

但我得到這個錯誤:

Failure/Error: expect(person).to have_attributes(:name => "Jim", :age => 32) 

expected #<struct Person name="Jim", age=32> to respond to `has_attributes?` 

感謝

回答

2

看來,這個問題涉及到Rspec的版本,我更新了寶石從3.0.1到3.3.0,問題解決了。