Skip to content

Instantly share code, notes, and snippets.

@ljkbennett
Last active December 19, 2015 16:28
Show Gist options
  • Save ljkbennett/5983612 to your computer and use it in GitHub Desktop.
Save ljkbennett/5983612 to your computer and use it in GitHub Desktop.
Mongoid route testing problems
require 'spec_helper'
describe "artifact routes" do
it "routes post /artifacts to artifacts#create" do
{post: "/artifacts"}.should route_to(controller: "artifacts", action: "create")
end
it "routes delete /artifacts/:id to artifacts#create" do
artifact = FactoryGirl.build(:artifact)
{delete: "/artifacts/#{artifact._id}"}.should route_to(controller: "artifacts", action: "destroy", id: artifact._id)
end
it "routes put /artifacts/:id to artifacts#update" do
artifact = FactoryGirl.build(:artifact)
{put: "/artifacts/#{artifact._id}"}.should route_to(controller: "artifacts", action: "update", id: artifact._id)
end
end
Failure/Error: {put: "/artifacts/#{artifact._id}"}.should route_to(controller: "artifacts", action: "update", id: artifact.id)
The recognized options <{"controller"=>"artifacts",
"action"=>"update",
"id"=>"51dfe0f251a6bc312a000002"}> did not match <{"controller"=>"artifacts",
"action"=>"update",
"id"=>"51dfe0f251a6bc312a000002"}>, difference: <{"id"=>"51dfe0f251a6bc312a000002"}>.
<{"controller"=>"artifacts",
"action"=>"update",
"id"=>"51dfe0f251a6bc312a000002"}> (Hash) expected but was
<{"controller"=>"artifacts",
"action"=>"update",
"id"=>"51dfe0f251a6bc312a000002"}> (ActiveSupport::HashWithIndifferentAccess).
require 'spec_helper'
describe "artifact routes" do
it "routes post /artifacts to artifacts#create" do
{post: "/artifacts"}.should route_to(controller: "artifacts", action: "create")
end
it "routes delete /artifacts/:id to artifacts#create" do
artifact = FactoryGirl.build(:artifact)
{delete: "/artifacts/#{artifact._id}"}.should route_to(controller: "artifacts", action: "destroy", id: artifact._id.to_s)
end
it "routes put /artifacts/:id to artifacts#update" do
artifact = FactoryGirl.build(:artifact)
{put: "/artifacts/#{artifact._id}"}.should route_to(controller: "artifacts", action: "update", id: artifact._id.to_s)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment