Skip to content

Commit

Permalink
Merge pull request #18 from josephruscio/feature/create_invalid_resource
Browse files Browse the repository at this point in the history
Add #create_invalid_resource
  • Loading branch information
nextmat committed Jan 22, 2014
2 parents a5a084d + 286660c commit 5b5f374
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/rack-test-rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def create_resource(params={})
last_response.original_headers["Location"]
end

# create resource, but expect a 400 - helper for the common case
# of testing invalid parameters for creating your resource.
#
def create_resource_invalid(opts)
create_resource({code: 400}.merge(opts))
end

def read_resource(params={})
id = params.delete(:id)
expected_code = params.delete(:code)
Expand Down Expand Up @@ -88,6 +95,13 @@ def update_resource(params={})
end
end

# update resource, but expect a 400 - helper for the common case
# of testing invalid parameters for updating your resource.
#
def update_resource_invalid(opts)
update_resource({code: 400}.merge(opts))
end

def delete_resource(params={})
delete "#{resource_uri}/#{params[:id]}#{@rack_test_rest[:extension]}"

Expand Down

0 comments on commit 5b5f374

Please sign in to comment.