require "rails_helper" #-#-#-#-#REST#-#-#-#-# RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Index" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end # get /api/<%= api_version %>/<%= resource_plural %> it "Gets all of the <%= resource_singular %>s" do FactoryGirl.create_list(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>, 10) get 'api/<%= api_version %>/<%= resource_plural %>', nil, @header expect(response.status).to eq(200) #ok expect(::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>.count).to eq(10) expect(json["<%= resource_plural %>"].length).to eq(10) end end end RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Show" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end # get /api/<%= api_version %>/<%= resource_plural %>/1 it "Gets a <%= resource_singular %> by id" do <%= resource_singular %> = FactoryGirl.create(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>) get "api/<%= api_version %>/<%= resource_plural %>/#{<%= resource_singular %>.id}", nil, @header expect(response.status).to eq(200) #ok end end end RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Create" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end # post /api/<%= api_version %>/<%= resource_plural %> it "Creates <%= resource_singular %>" do attrs = FactoryGirl.attributes_for(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>) #attrs[:column] = "LaunchU" hash = {"<%= resource_singular %>" => attrs} post 'api/<%= api_version %>/<%= resource_plural %>', hash, @header expect(response.status).to eq(200) #ok end end end RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Update" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end # patch/put /api/<%= api_version %>/<%= resource_plural %>/1 it "Updates <%= resource_singular %>" do #Create the <%= resource_singular %> through the api attrs = FactoryGirl.attributes_for(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>) #attrs[:column] = "LaunchU" <%= resource_singular %> = FactoryGirl.create(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>) hash = {"<%= resource_singular %>" => attrs} put "api/<%= api_version %>/<%= resource_plural %>/#{<%= resource_singular %>.id}", hash, @header expect(response.status).to eq(200) #ok end end end RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Destroy" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end # delete /api/<%= api_version %>/<%= resource_plural %>/1 it "Deletes <%= resource_singular %>" do #Create the <%= resource_singular %> through the api attrs = FactoryGirl.attributes_for(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>) #attrs[:column] = "LaunchU" <%= resource_singular %> = FactoryGirl.create(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>) expect(<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>.count).to eq(1) #Now delete the <%= resource_singular %> through the api delete "api/<%= api_version %>/<%= resource_plural %>/#{<%= resource_singular %>.id}", nil, @header expect(json).to eq({}) expect(response.status).to eq(200) #ok expect(<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>.count).to eq(0) end end end #-#-#-#-#Collection Routes#-#-#-#-# RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Collection Routes" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end # get /api/1/collection it "checks response of a collection route" do end end end #-#-#-#-#Serialization#-#-#-#-# RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Serialization" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end it "checks the index json sent back" do end end end #-#-#-#-#Errors#-#-#-#-# RSpec.describe ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>, :type => :request do describe "Errors" do before(:example) do @user = FactoryGirl.create(:people_user_1) token = @user.tokens[0].auth_token @header = {::Settings.token_header => token, "Email" => @user.email} end # get /api/<%= api_version %>/<%= resource_plural %>/1 it "checks for a 404" do <%= resource_singular %> = FactoryGirl.create(:<%= module_snake %>_<%= resource_singular %>_<%= api_version %>) get "api/<%= api_version %>/<%= resource_plural %>/#{<%= resource_singular %>.id + 1}", nil, @header expect(response.status).to eq(404) #ok end end end