spec/unit/proxyable_spec.rb in couchrest_model-2.0.1 vs spec/unit/proxyable_spec.rb in couchrest_model-2.0.3

- old
+ new

@@ -192,10 +192,11 @@ it "should create view methods" do @obj.should respond_to('all') @obj.should respond_to('by_name') @obj.should respond_to('find_all') @obj.should respond_to('find_by_name') + @obj.should respond_to('find_by_name!') end it "should create 'all' view method that forward to model's view with proxy" do @model.should_receive(:all).with(:proxy => @obj).and_return(nil) @obj.all @@ -210,9 +211,17 @@ view = mock('view') view.should_receive('key').with('name').and_return(view) view.should_receive('first').and_return(nil) @obj.should_receive(:by_name).and_return(view) @obj.find_by_name('name') + end + + it "should create 'find_by_name!' that raises error when there are no results" do + view = mock('view') + view.should_receive('key').with('name').and_return(view) + view.should_receive('first').and_return(nil) + @obj.should_receive(:by_name).and_return(view) + lambda { @obj.find_by_name!('name') }.should raise_error(CouchRest::Model::DocumentNotFound) end end describe "instance" do