require "rails_helper" #-#-#-#-#REST#-#-#-#-# RSpec.describe ::<%= module_camel %>::<%= resource_camel %>, :type => :request do describe "Rest Routes" do before(:example) do 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 %>' 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' 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 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 #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 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 expect(<%= module_camel %>::<%= resource_camel %>.count).to eq(1) #Now delete the <%= resource_singular %> through the api delete 'api/<%= api_version %>/<%= resource_plural %>/1' 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 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 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 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' expect(response.status).to eq(404) #ok end end end