I have a simple controller:
class MonitorController < ApplicationController
def pinger
render text: 'pong'
end
end
with routes:
Rails.application.routes.draw do
constraints subdomain: 'api' do
scope module: 'api' do
namespace :v1 do
end
end
end
# ********************************************************************************************
root to: 'monitor#pinger'
end
and my controller test:
require 'spec_helper'
describe MonitorController do
context "#pinger" do
it "Responds Successfully." do
get "/"
response.status.should be(200)
end
it "Should contain 'pong' in the response body." do
get "/"
response.body.should == "pong"
end
end
end
No matter what I do I can not seem to get the root route.
Error:
Failures:
1) MonitorController#pinger Should contain 'pong' in the response body.
Failure/Error: get "/"
ActionController::UrlGenerationError:
No route matches {:action=>"/", :controller=>"monitor"}
# ./spec/controllers/monitor_controller_spec.rb:12:in `block (3 levels) in <top (required)>'
2) MonitorController#pinger Responds Successfully.
Failure/Error: get "/"
ActionController::UrlGenerationError:
No route matches {:action=>"/", :controller=>"monitor"}
# ./spec/controllers/monitor_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.13662 seconds
2 examples, 2 failures
Can anyone point me in the right direction as to why these are failing?
In your rspec spec, try using:
get :pinger