Matchers don't have a to
method that you would use like that. They take a single expected
argument and are evaluated for truthiness, so you'd need to pass a hash, as in:
expect(subject.get_something).to have_attribute(method: :type, value: 'serious')
expect(subject.get_something).to have_attribute(method: :trustworthiness, value: ->(v) { v > 90 } )
with obvious complexity for interpreting the value
parameter
Another approach would be to use the its
functionality, which moved to a separate gem in RSpec 3, as in:
RSpec.describe MySubject do
describe '#get_something' do
subject(:get_something) { MySubject.new.get_something }
its(:type) { should eq 'serious'}
its(:trustworthiness) { should be > 90 }
end
end