dupe icon indicating copy to clipboard operation
dupe copied to clipboard

Dupe doesn't raise ActiveResource::ResourceNotFound?

Open nzifnab opened this issue 14 years ago • 1 comments

I'm getting this error:

Dupe::Network::Mock::ResourceNotFoundError in 'User#find_by_id should return nil if the id is not correct'
Failed with 404: the request '/v1/users/202.xml' returned nil.

But my code in the model looks like this:

def self.find_by_id(user_id)
  find(user_id)
rescue ActiveResource::ResourceNotFound
  nil
end

I find it odd that Dupe doesn't throw up ActiveResource::ResourceNotFound errors since that's what one would be rescuing in the code. My spec doesn't work because the error is being raised, even though I'm rescuing the real-world exception.:

it "should return nil if the id is not correct" do
  User.find_by_id(@user.id + 200).should be_nil
end

Sorry if it feels like I'm being nitpicky with dupe! I reaaaally love dupe :) It's great and does just about everything I need. But there are these couple things I feel it's missing to be really stellar

nzifnab avatar Apr 08 '10 22:04 nzifnab

i think you're right, i should just raise ActiveResource::ResourceNotFound errors instead of the Dupe version of them... adding it to the list!

moonmaster9000 avatar Apr 08 '10 23:04 moonmaster9000