require "rails_helper" #-#-#-#-#REST#-#-#-#-# RSpec.describe ::<%= module_camel %>::<%= resource_camel %>, :type => :request do describe "Rest Routes" do before(:example) do @user = FactoryGirl.create(:people_user) token = @user.tokens[0].auth_token @header = {"Auth-Token" => 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 %>, 10) get 'api/<%= api_version %>/<%= resource_plural %>', nil, @header expect(response.status).to eq(200) #ok end # get /api/<%= api_version %>/<%= resource_plural %>/1 it "Gets a <%= resource_singular %> by id" do FactoryGirl.create(:<%= module_snake %>_<%= resource_singular %>) get 'api/<%= api_version %>/<%= resource_plural %>/1', nil, @header expect(response.status).to eq(200) #ok end # post /api/<%= api_version %>/<%= resource_plural %> it "Creates <%= resource_singular %>" do attrs = FactoryGirl.attributes_for(:<%= module_snake %>_<%= resource_singular %>) #attrs[:column] = "LaunchU" hash = {"<%= resource_singular %>" => attrs} post 'api/<%= api_version %>/<%= resource_plural %>', hash, @header expect(response.status).to eq(200) #ok 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 %>) #attrs[:column] = "LaunchU" hash = {"<%= resource_singular %>" => attrs} post 'api/<%= api_version %>/<%= resource_plural %>', hash, @header #Now update the created <%= resource_singular %> by changing the <%= resource_singular %>name #attrs[:column] = "BlastOff" hash = {"<%= resource_singular %>" => attrs} put "api/<%= api_version %>/<%= resource_plural %>/1", hash, @header expect(response.status).to eq(200) #ok 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 %>) #attrs[:column] = "LaunchU" hash = {"<%= resource_singular %>" => attrs} post 'api/<%= api_version %>/<%= resource_plural %>', hash, @header expect(<%= module_camel %>::<%= resource_camel %>.count).to eq(1) #Now delete the <%= resource_singular %> through the api delete 'api/<%= api_version %>/<%= resource_plural %>/1', nil, @header expect(json).to eq({}) expect(response.status).to eq(200) #ok expect(<%= module_camel %>::<%= resource_camel %>.count).to eq(0) end end end #-#-#-#-#Collection Routes#-#-#-#-# RSpec.describe ::<%= module_camel %>::<%= resource_camel %>, :type => :request do describe "Collection Routes" do before(:example) do @user = FactoryGirl.create(:people_user) token = @user.tokens[0].auth_token @header = {"Auth-Token" => 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 %>::<%= resource_camel %>, :type => :request do describe "Serialization" do before(:example) do @user = FactoryGirl.create(:people_user) token = @user.tokens[0].auth_token @header = {"Auth-Token" => token, "Email" => @user.email} end it "checks the index json sent back" do end end end #-#-#-#-#Errors#-#-#-#-# RSpec.describe ::<%= module_camel %>::<%= resource_camel %>, :type => :request do describe "Errors" do before(:example) do @user = FactoryGirl.create(:people_user) token = @user.tokens[0].auth_token @header = {"Auth-Token" => token, "Email" => @user.email} end # get /api/<%= api_version %>/<%= resource_plural %>/1 it "checks for a 404" do FactoryGirl.create(:<%= module_snake %>_<%= resource_singular %>) get 'api/<%= api_version %>/<%= resource_plural %>/20', nil, @header expect(response.status).to eq(404) #ok end end end