I have a WelcomeController#index which simply renders index.html.erb. I need to test this by checking whether a link in the page has a particular href as passing some specific query parameter can change this href.
I want to test the basic index page without query parameter.
In spec/controllers/welcome_controller_spec.rb I have,
require 'spec_helper'
# describe WelcomeController, :type => :controller do
# it "tests index page content" do
# get :index
# assert_response 200
# end
# end
RSpec.describe WelcomeController, :type => :controller do
it "should go to the index page" do
get 'index'
response.should render_template "welcom/index"
response.body.should =~ /test link text/
end
end
But when I run rspec spec/controllers/welcome_controller_spec.rb
I keep getting this error
Failures:
1) WelcomeController should go to the index page
Failure/Error: get 'index'
NoMethodError:
undefined method `get' for #<RSpec::ExampleGroups::WelcomeController:0x0000000003ac3ca0>
Did you mean? gets
gem
# ./spec/controllers/welcome_controller_spec.rb:13:in `block (2 levels) in <top (required)>'
Finished in 0.00038 seconds (files took 1.09 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/controllers/welcome_controller_spec.rb:12 # WelcomeController should go to the index page
I using Ruby 2.5, Rails 5 and RSpec 3