houdini/lib/templates/rspec/scaffold/routing_spec.rb.tt

51 lines
1.5 KiB
Text
Raw Normal View History

2020-05-01 19:28:55 +00:00
# frozen_string_literal: true
2020-06-12 20:03:43 +00:00
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
2020-05-01 19:28:55 +00:00
require "rails_helper"
<% module_namespacing do -%>
RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:routing) %> do
describe "routing" do
<% unless options[:singleton] -%>
it "routes to #index" do
expect(get: "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#index")
end
<% end -%>
<% unless options[:api] -%>
it "routes to #new" do
expect(get: "/<%= ns_table_name %>/new").to route_to("<%= ns_table_name %>#new")
end
<% end -%>
it "routes to #show" do
expect(get: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#show", id: "1")
end
<% unless options[:api] -%>
it "routes to #edit" do
expect(get: "/<%= ns_table_name %>/1/edit").to route_to("<%= ns_table_name %>#edit", id: "1")
end
<% end -%>
it "routes to #create" do
expect(post: "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create")
end
it "routes to #update via PUT" do
expect(put: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", id: "1")
end
it "routes to #update via PATCH" do
expect(patch: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", id: "1")
end
it "routes to #destroy" do
expect(delete: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#destroy", id: "1")
end
end
end
<% end -%>