I'm testing a Sinatra application, which is using DataMapper, with RSpec.
The following code:
it "should update the item's title" do
lambda do
post "/hello/edit", :params => {
:title => 'goodbye',
:body => 'goodbye world'
}
end.should change(Snippet, :title).from('hello').to('goodbye')
end
Results in this error:
title should have initially been "hello", but was #<DataMapper::Property::String @model=Snippet @name=:title>
I can of course hack this by removing the lambda and only checking if:
Snippet.first.title.should == 'goodbye'
But that can't be a long term solution since the .first Snippet may not be the same in the future.
Can someone show me the right syntax?
Thanks.