i keep getting this error message.
1) Worker::HomeController GET #index has a 200 status code
Failure/Error: get :home
NoMethodError:
undefined method `get' for #<RSpec::ExampleGroups::WorkerHomeController::GETIndex:0x2ba04c836f18>
# ./spec/controllers/worker/home_controller_spec.rb:14
Finished in 0.12277 seconds (files took 2 minutes 59.7 seconds to load) 1 example, 1 failure
i am using these gems
group :development, :test do
gem "rspec", "~> 1.3"
gem "rspec-rails", "~> 1.3"
gem "nokogiri", "1.3.3"
gem "rubyzip", "0.9.7"
gem "capybara", "2.0.0"
gem "database_cleaner", "1.4.1"
gem "factory_girl", "2.5.0"
gem "rspec-core", "3.3.0"
end
this issue is related to rspec config as far as I understand
following is the spec file
require 'spec_helper'
require 'factory_girl'
require 'date'
RSpec.describe Worker::HomeController, :type => :controller do
before :each do
Factory.create(:zipcode, :zip => "60290")
end
describe "GET #index" do
it "has a 200 status code" do
get :home
response.code.should eq("200")
end
end
end
the project directory structure is :
app
controllers
worker
home_controller.rb
spec
controllers
worker
home_controller_spec.rb
Rspec 2.x
will assume that everything in the controllers directory is a controllerspec
.This was changed in Rspec 3:
File-type inference disabled by default
https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#file-type-inference-disabled
Also do not forgot to
require 'rspec/rails'