Skip to content

Commit

Permalink
spec attribute conversion looking for a matching pickle reference fir…
Browse files Browse the repository at this point in the history
…st, and when not found just using the string instead
  • Loading branch information
ianwhite committed Aug 25, 2010
1 parent 03cbbaf commit e3b703e
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions spec/pickle/session/conversion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,20 @@
attributes(%q(user: the user "Fred")).should == {'user' => fred}
end

specify %Q(when field is a pickle-ref (like 'the user "Fred"')which does not refer it should raise UnknownFieldsFormatError) do
specify %Q{when field is a pickle-ref (like 'the user "Fred"') which does not refer it should raise UnknownFieldsFormatError} do
should_receive(:retrieve).with('the user "Fred"').and_raise(Pickle::UnknownModelError)
lambda{attributes(%q(user: the user "Fred"))}.should raise_error(Pickle::UnknownFieldsFormatError)
end

# describe "and a user Fred has been stored in pickle" do
# describe 'the user "Fred"' do
# it {should == fred}
# end
#
# describe '"Fred"' do
# it {should == fred}
# end
# end
#
# describe "and a user Fred has not been stored in pickle" do
# describe 'the user "Fred"' do
# it {should == fred}
# end
#
# describe '"Fred"' do
# it {should == "Fred"}
# end
# end
specify %Q{when field is "Fred" and there is no pickled "Fred" then the attributes should contain the string "Fred"} do
should_receive(:retrieve).with('"Fred"').and_raise(Pickle::UnknownModelError)
attributes(%q(user: "Fred")).should == {'user' => "Fred"}
end

specify %Q{when field is "Fred" and there is a pickled "Fred" then the attributes should contain the fred object} do
should_receive(:retrieve).with('"Fred"').and_return fred = mock
attributes(%q(user: "Fred")).should == {'user' => fred}
end
end
end
end

0 comments on commit e3b703e

Please sign in to comment.