require "rails_helper" #-#-#-#-#REST#-#-#-#-# RSpec.describe ::People::V1::User, :type => :request do describe "Index" do before(:example) do @user = FactoryGirl.create(:people_user_1) end # get /api/1/users it "checks index json response" do FactoryGirl.create_list(:people_user_1, 10) get 'api/1/users' expect(response.status).to eq(200) #ok expect(json["users"]).to_not eq(nil) end end end RSpec.describe ::People::V1::User, :type => :request do describe "Show" do before(:example) do @user = FactoryGirl.create(:people_user_1) end # get /api/1/users/1 it "checks show json response" do get 'api/1/users/1' expect(response.status).to eq(200) #ok expect(json["user"]["id"]).to eq(1) end end end RSpec.describe ::People::V1::User, :type => :request do describe "Update" do before(:example) do @user = FactoryGirl.create(:people_user_1) end # put /api/1/users/1 it "checks update json response" do attrs = FactoryGirl.attributes_for(:people_user_1) attrs["email"] = "Cole@LaunchU.com" hash = {"user" => attrs} put 'api/1/users/1', hash expect(response.status).to eq(200) #ok expect(json["user"]["email"]).to eq("Cole@LaunchU.com") end end end #-#-#-#-#Collection Routes#-#-#-#-# RSpec.describe ::People::V1::User, :type => :request do describe "Collection" do before(:example) do @attrs = FactoryGirl.attributes_for(:people_user_1) end it "Collection" do end end end #-#-#-#-#Serialization#-#-#-#-# RSpec.describe ::People::V1::User, :type => :request do describe "Serialization" do before(:example) do @user = FactoryGirl.create(:people_user_1) end # get /api/1/users it "checks only appropriate attributes are sent back for index" do FactoryGirl.create_list(:people_user_1, 10) get 'api/1/users' expect(response.status).to eq(200) #ok expect(json["users"][0]["password_digest"]).to eq(nil) expect(json["users"][0]["created_at"]).to_not eq(nil) expect(json["users"][0]["updated_at"]).to_not eq(nil) end end end #-#-#-#-#Errors#-#-#-#-# RSpec.describe ::People::V1::User, :type => :request do describe "Authorization" do before(:example) do @user = FactoryGirl.create(:people_user_1) end it "checks for 404 response" do get 'api/1/users/20' expect(response.status).to eq(404) #not_found end end end