test/integration/users_test.rb in datacentred-0.1.1pre vs test/integration/users_test.rb in datacentred-1.1.1
- old
+ new
@@ -1,20 +1,24 @@
require_relative '../test_helper'
module Datacentred
class UsersIntegrationTest < Minitest::Test
-
def setup
-
- @create_params_without_pass = {"user" => {"email" => "death@afterlife2.com"}}
- @create_params = {"user" => {"email" => "death@afterlife.com",
- "password" => "melvin11", "first_name" => "Foo","last_name" => "Bar"}}
- @create_params2 = {"user" => {"email" => "death2@afterlife2.com",
- "password" => "melvin22"}}
+ @create_params_without_pass = {email: "death@afterlife2.com"}
+ @create_params = {
+ email: "death@afterlife.com",
+ password: "melvin11",
+ first_name: "Foo",
+ last_name: "Bar"
+ }
+ @create_params2 = {
+ email: "death2@afterlife2.com",
+ password: "melvin22"
+ }
@user_id = "bda96ae2c89347d5a059d663c153ec2a"
- @update_params = {"user" => {"first_name" => "Foo2"}}
- @short_password = {"user" => {"password" => "tiny"}}
+ @update_params = {first_name: "Foo2"}
+ @short_password = {password: "tiny"}
end
def test_user_object_properties
VCR.use_cassette('list_users') do
@users = Datacentred::User.all
@@ -48,11 +52,11 @@
end
end
def test_raises_not_found_if_cant_find_user
VCR.use_cassette('user_show_not_found') do
- assert_raises(Datacentred::NotFoundError) do
+ assert_raises(Datacentred::Errors::NotFound) do
@user = Datacentred::User.find("unknown")
end
end
end
@@ -66,11 +70,11 @@
end
end
def test_raises_unprocessable_entity_if_failed_validation_for_create
VCR.use_cassette('user_create_failed_validation') do
- assert_raises(Datacentred::UnprocessableEntity) do
+ assert_raises(Datacentred::Errors::UnprocessableEntity) do
@user = Datacentred::User.create(@create_params_without_pass)
end
end
end
@@ -83,45 +87,45 @@
end
def test_raises_unprocessable_entity_if_failed_validation_for_update
VCR.use_cassette('user_update_failed_validation') do
@user = Datacentred::User.create(@create_params)
- assert_raises(Datacentred::UnprocessableEntity) do
+ assert_raises(Datacentred::Errors::UnprocessableEntity) do
@user = Datacentred::User.update(@user.id, @short_password)
end
end
end
def test_raises_not_found_if_user_doesnt_exist
VCR.use_cassette('user_update_not_found') do
- assert_raises(Datacentred::NotFoundError) do
+ assert_raises(Datacentred::Errors::NotFound) do
@user = Datacentred::User.update("unknown", @update_params)
end
end
end
def test_delete_user
VCR.use_cassette('delete_user') do
@user = Datacentred::User.create(@create_params)
- Datacentred::User.delete(@user.id)
- assert_raises(Datacentred::NotFoundError) do
+ Datacentred::User.destroy(@user.id)
+ assert_raises(Datacentred::Errors::NotFound) do
@user = Datacentred::User.find(@user.id)
end
end
end
def test_raises_unprocessable_entity_if_failed_validation_for_delete
VCR.use_cassette('user_delete_failed_validation') do
- assert_raises(Datacentred::UnprocessableEntity) do
- @user = Datacentred::User.delete("my_user_id")
+ assert_raises(Datacentred::Errors::UnprocessableEntity) do
+ @user = Datacentred::User.destroy("my_user_id")
end
end
end
def test_user_cant_be_deleted_if_not_found
VCR.use_cassette('user_delete_not_found') do
- assert_raises(Datacentred::NotFoundError) do
- @user = Datacentred::User.delete("unknown")
+ assert_raises(Datacentred::Errors::NotFound) do
+ @user = Datacentred::User.destroy("unknown")
end
end
end
end
end