2015-06-28 59 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,问题解决了。