Exception when trying to execute rspec test w/ devise, factory-girl - ruby-on-rails

I am taking back a project in rails 3.0.3 that make uses of devise and localized_routes. The project doesn't have any tests and so I've wrote a very simple test with rspec and factory girl.
when executing the test, I'm getting an error (which is unrelated to the test I believe):
rspec spec/helpers/application_helper_spec.rb
/Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:163:in `define_hash_access': compile error (SyntaxError)
/Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:161: syntax error, unexpected '-', expecting '\n' or ';'
... hash_for_new_user_session_en-ca_path(options = nil) ...
^
/Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:163: syntax error, unexpected kEND, expecting $end
end ...
^
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:151:in `define_named_route_methods'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:149:in `each'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:149:in `define_named_route_methods'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:100:in `[]='
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:300:in `add_route_without_i18n'
from /Users/pl/src/dialogcube/vendor/plugins/localized_routes/lib/localized_routes.rb:21:in `add_route'
from /Users/pl/src/dialogcube/vendor/plugins/localized_routes/lib/localized_routes.rb:12:in `each'
from /Users/pl/src/dialogcube/vendor/plugins/localized_routes/lib/localized_routes.rb:12:in `add_route'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:262:in `match'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1112:in `match'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1297:in `match'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1094:in `match'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1015:in `member'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:525:in `scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1014:in `member'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1199:in `with_scope_level'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1013:in `member'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1094:in `match'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1297:in `match'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:383:in `map_method'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:312:in `get'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:206:in `devise_session'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:898:in `resource'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1208:in `resource_scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:525:in `scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1207:in `resource_scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1199:in `with_scope_level'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1206:in `resource_scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:897:in `resource'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:205:in `devise_session'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `send'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `devise_for'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `each'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:157:in `devise_for'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:237:in `with_devise_exclusive_scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:156:in `devise_for'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:197:in `devise_scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:661:in `constraints'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:525:in `scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:661:in `constraints'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:196:in `devise_scope'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:154:in `devise_for'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:136:in `each'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails/routes.rb:136:in `devise_for'
from /Users/pl/src/dialogcube/config/routes.rb:10
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `draw'
from /Users/pl/src/dialogcube/config/routes.rb:1
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:227:in `load_dependency'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:127:in `each'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.1.5/lib/devise/rails.rb:17
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application/finisher.rb:40
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /Users/pl/src/dialogcube/config/environment.rb:5
from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `gem_original_require'
from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `require'
from /Users/pl/src/dialogcube/spec/spec_helper.rb:3
from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `gem_original_require'
from /Users/pl/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:54:in `require'
from /Users/pl/src/dialogcube/spec/helpers/application_helper_spec.rb:1
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `map'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `autorun'
from /Users/pl/.rvm/gems/ruby-1.8.7-p334/bin/rspec:19
application_helper_spec.rb:
require 'spec_helper'
describe ApplicationHelper do
it 'should return a analytics tag' do
s = Factory.build(:analytics_setting)
result = analytics_tag
result.should_not be_nil
end
end
My spec_helper.rb:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'faker'
require 'factory_girl'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
end
(part of) my route.rb:
Dialogcube::Application.routes.draw do
# Omniauth
match '/auth/:provider/callback' => 'authentications#create', :i18n => false
match '/auth/external/:provider' => 'authentications#show', :i18n => false
# Public
devise_for :users,
:path => 'auth',
:controllers => {
:registrations => 'registrations',
:sessions => 'sessions',
:passwords => 'passwords'
}
resources :users do
put :follow_tag, :on => :member
put :unfollow_tag, :on => :member
resources :entries
end
I can't figure out what's going on or why is there a compiler error at that point. It seem, based on the generated method that the locale is en-ca and that the dash characters somehow screws up some part of the code.
Any leads on where I should look?

I think it expects the locale to be en_ca and not en-ca.

Related

How to include view helper in RSpec

I have a module with a custom view helper. Actually it uses the modified code of link_to helper. Just append a query string to the generated link. I have existing tests which fails because the custom helper cannot be found. How can I include it so it is available for RSpec? I tried the following approaches:
1.Using include:
describe MyClass do
include MyHelper
2.Using configure
RSpec.configure do |config|
config.include MyHelper
end
3.Adding it in spec_helper.rb
config.include MyHelper
Here is the error:
1) Mailer#calendar_item_notification should send email for task
Failure/Error: expect {Mailer.calendar_item_notification('User', #user.id).deliver}.to change { ActionMailer::Base.deliveries.count }.by(1)
ActionView::Template::Error:
undefined method `<<' for #<Proc:0x00000013102d28>
# ./app/helpers/mailer_helper.rb:88:in `link_username'
# ./app/views/user_mailer/calendar_item_notification.html.erb:137:in `_app_views_user_mailer_calendar_item_notification_html_erb___206027131771876632_159436760'
# ./app/mailers/user_mailer.rb:136:in `calendar_item_notification'
# ./spec/mailers/user_mailer_spec.rb:19:in `block (4 levels) in <top (required)>'
# ./spec/mailers/user_mailer_spec.rb:19:in `block (3 levels) in <top (required)>'
# ./spec/support/misc.rb:13:in `block in suppress_output'
# ./spec/support/misc.rb:12:in `tap'
# ./spec/support/misc.rb:12:in `suppress_output'
# -e:1:in `<main>'
Thanks

Rspec: Testing registarion routing in rails with devise

I'm Trying to build a simple Blog using rails 4 and For authentication I'm using Devise.
The blog is simple and it will only have one registered user which is the admin. so the registration page should be available when there are no users in the database else it will redirect to the home page.
I'm trying to learn testing in the process. So I started testing the RegistrationContrroler However it doesn't seem to pass.
class RegistrationsController < Devise::RegistrationsController
before_action :one_user_registered?, only: [:new, :create]
protected
def one_user_registered?
if ((User.count == 1) & (user_signed_in?))
redirect_to root_path
elsif User.count == 1
redirect_to new_user_session_path
end
end
end
Specs:
RSpec.describe RegistrationsController, type: :controller do
context "Admin already registred" do
it "cannot create new user" do
#user_attr = FactoryGirl.attributes_for(:user)
# Create Admin
User.create!(#user_attr)
#request.env["devise.mapping"] = Devise.mappings[:user]
post :create, user: #user_attr
User.count should eq_to(1)
end
end
end
spec/factories.rb :
FactoryGirl.define do
factory :user do
sequence(:email) { |n| "user#{n}#example.com" }
password "secure"
end
factory :post do
sequence(:id){ |n| n }
sequence(:title) { |n| "Post title #{n}" }
body "Post body"
sequence(:slug) { |n| "Post title #{n}" }
end
end
routes.rb
Rails.application.routes.draw do
devise_for :users, controllers: { registrations: "registrations" }
authenticated :user do
resources :posts
end
unauthenticated :user do
resources :posts, only: [:show, :index]
end
root 'posts#index'
end
Stacktrace :
F
Failures:
1) RegistrationsController Admin already registred cannot create new user
Failure/Error: User.count should eq_to(1)
expected: 1
got: #<RegistrationsController:0x00000003a413b8 #_action_has_layout=true, #_routes=nil, #_headers={"Conten...enticatable]>, #req touest_format=:html, #marked_for_same_origin_verification=false, #current_user=nil>
(compared using ==)
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-support-3.5.0/lib/rspec/support.rb:87:in `block in <module:Support>'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-support-3.5.0/lib/rspec/support.rb:96:in `notify_failure'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-expectations-3.5.0/lib/rspec/expectations/fail_with.rb:27:in `fail_with'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-expectations-3.5.0/lib/rspec/expectations/handler.rb:38:in `handle_failure'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-expectations-3.5.0/lib/rspec/expectations/handler.rb:50:in `block in handle_matcher'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-expectations-3.5.0/lib/rspec/expectations/handler.rb:27:in `with_matcher'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-expectations-3.5.0/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/memoized_helpers.rb:81:in `should'
# ./spec/controllers/registrations_controller_spec.rb:13:in `block (3 levels) in <top (required)>'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:252:in `instance_exec'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:252:in `block in run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:494:in `block in with_around_and_singleton_context_hooks'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:451:in `block in with_around_example_hooks'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:471:in `block in run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:611:in `block in run_around_example_hooks_for'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:336:in `call'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-rails-3.5.1/lib/rspec/rails/example/controller_example_group.rb:191:in `block (2 levels) in <module:ControllerExampleGroup>'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:441:in `instance_exec'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:441:in `instance_exec'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:382:in `execute_with'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:613:in `block (2 levels) in run_around_example_hooks_for'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:336:in `call'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-rails-3.5.1/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:441:in `instance_exec'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:441:in `instance_exec'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:382:in `execute_with'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:613:in `block (2 levels) in run_around_example_hooks_for'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:336:in `call'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:614:in `run_around_example_hooks_for'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/hooks.rb:471:in `run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:451:in `with_around_example_hooks'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:494:in `with_around_and_singleton_context_hooks'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example.rb:249:in `run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example_group.rb:627:in `block in run_examples'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example_group.rb:623:in `map'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example_group.rb:623:in `run_examples'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example_group.rb:589:in `run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example_group.rb:590:in `block in run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example_group.rb:590:in `map'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/example_group.rb:590:in `run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:113:in `block (3 levels) in run_specs'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:113:in `map'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:113:in `block (2 levels) in run_specs'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/configuration.rb:1836:in `with_suite_hooks'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:112:in `block in run_specs'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/reporter.rb:77:in `report'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:111:in `run_specs'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:87:in `run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:71:in `run'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/lib/rspec/core/runner.rb:45:in `invoke'
# /home/chaker/.rvm/gems/ruby-2.3.1/gems/rspec-core-3.5.1/exe/rspec:4:in `<top (required)>'
# /home/chaker/.rvm/gems/ruby-2.3.1/bin/rspec:23:in `load'
# /home/chaker/.rvm/gems/ruby-2.3.1/bin/rspec:23:in `<main>'
# /home/chaker/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
# /home/chaker/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
Finished in 0.08188 seconds (files took 1.95 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/controllers/registrations_controller_spec.rb:7 # RegistrationsController Admin already registred cannot create new user
You're missing a dot!
User.count.should eq_to(1)
Adding a should method is the way rspec patches all objects to support the should comparisons.
Preferable would be...
expect(User.count).to eq(1)
The error showed that the should by itself was received by the RegistrationsController, not by the User.count... and of course the RegistrationsController doesn't equal 1.

factory_girl undefined method `save!' for

## app/models/armor_type.rb
class ArmorType < ActiveRecord::Base
validates :name, presence: true
...
end
## spec/models/armor_type_spec.rb
require 'rails_helper'
RSpec.describe ArmorType, type: :model do
it "has a valid name" do
armor_type = create(:armor_type)
end
end
## spec/factories/armor_types.rb
FactoryGirl.define do
factory :armor_type do
name "cloth"
end
end
## spec/support/factory_girl.rb
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
## spec/rails_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
require 'support/factory_girl'
require 'capybara/rspec'
## Gemfile
group :development, :test do
gem 'byebug'
gem 'rspec-rails'
gem 'factory_girl_rails'
end
I can't seem to get factory_girl to work properly. I created at testApp using a SQLite3 test database and it worked, however using my current application which uses a PostgreSQL test database I get the following error;
1) ArmorType has a valid name
Failure/Error: armor_type = create(:armor_type)
NoMethodError:
undefined method `save!' for #<ArmorType:0x000000071a8b58 #name="cloth">
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/configuration.rb:14:in `block in initialize'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:15:in `[]'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:15:in `create'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in `result'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/factory.rb:42:in `run'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# ./.bundle/gems/activesupport-4.2.3/lib/active_support/notifications.rb:166:in `instrument'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:22:in `run'
# ./.bundle/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/models/armor_type_spec.rb:6:in `block (2 levels) in <top (required)>'
# .bundle/binstubs/rspec:16:in `load'
# .bundle/binstubs/rspec:16:in `<main>'
I've gone ahead and created another test app using a PostgreSQL test database and I get the same errors. Any help would be appreciated.
Cheers!
I had inadvertently created a file 'armor_type.rb" in the very early stages of testing, resulting in this error. It was not related to factory_girl, nor rspec.
newbiemistakes

Writing webmock stubs on Modules specs

My problem is I'm creating a wrapper to deal with a connection to an external server (GeoNetwork) and treat its response.
While I had my request in my Search Controller, it was working fine. Then I tried to follow this solution for the wrapper:
http://code.tutsplus.com/articles/writing-an-api-wrapper-in-ruby-with-tdd--net-23875
But now, I'm having an error on webmock that I can't figure out why.
../lib/wrapper/api.rb
module Wrapper
class Api
class << self
attr_accessor :base_uri
end
include HTTP
#base_uri = 'http://boldo.caiena.net:8080/geonetwork/srv/eng/'
builder_for_summary = Nokogiri::XML::Builder.new do |xml|
xml['csw'].GetRecords('xmlns:csw' => 'http://www.opengis.net/cat/csw/2.0.2',
'service' => 'CSW',
'version' => '2.0.2',
'resultType' => 'results',
# metadata records start at position 1
'startPosition' => '1',
'maxRecords' => '10') do
xml['csw'].Query('typeNames' => 'gmd:MD_Metadata') {
xml['csw'].Constraint('version' => '1.1.0'){
xml.Filter('xmlns' => 'http://www.opengis.net/ogc',
'xmlns:gml' => 'http://www.opengis.net/gml'){
xml.PropertyIsLike('wildCard' => '',
'singleChar' => '_'){
xml.PropertyName 'any'
xml.Literal '' #params[:search_field]
}
}
}
}
end
end
response = HTTP.post("#{#base_uri}csw", body: builder_for_summary.to_xml)
.with_headers(content_type: "application/xml")
.response
end
end
../spec/lib/api_spec.rb
require 'spec_helper'
describe Wrapper::Api do
it 'should work' do
expect('Yay!').to be_an_instance_of String
end
describe 'default attributes' do
it 'should include http methods' do
expect(Wrapper::Api).to include HTTP
end
it 'should have the base url set to the GeoNetwork API endpoint' do
expect(Wrapper::Api.base_uri).to eq('http://boldo.caiena.net:8080/geonetwork/srv/eng/')
end
end
describe 'request' do
it 'makes a request to GeoNetwork' do
WebMock.should have_requested(:post, "#{Wrapper::Api.base_uri}csw")
end
end
end
../spec/spec_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require_relative '../config/environment'
require_relative '../lib/wrapper'
require 'rspec/rails'
require 'rspec/autorun'
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
config.before(:each) do
support_path = 'spec/support/fixtures/'
url = 'http://boldo.caiena.net:8080/geonetwork/srv/eng/'
canned_request = File.read "#{support_path}request_all_metadata.xml"
canned_response = File.read "#{support_path}all_metadata_results.xml"
stub_request(:post, "#{url}csw")
.with(header:'application/xml')
.to_return(body: canned_response)
end
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
# Enabling FactoryGirl methods with ease
config.include FactoryGirl::Syntax::Methods
config.include Capybara::DSL
end
The error I'm getting is:
/Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/webmock-1.17.4/lib/webmock/http_lib_adapters/http_gem_adapter.rb:125:in `halt': Real HTTP connections are disabled. Unregistered request: POST http://boldo.caiena.net:8080/geonetwork/srv/eng/csw with body '<?xml version="1.0"?> (WebMock::NetConnectNotAllowedError)
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="2.0.2" resultType="results" startPosition="1" maxRecords="10">
<csw:Query typeNames="gmd:MD_Metadata">
<csw:Constraint version="1.1.0">
<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
<PropertyIsLike wildCard="" singleChar="_">
<PropertyName>any</PropertyName>
<Literal/>
</PropertyIsLike>
</Filter>
</csw:Constraint>
</csw:Query>
</csw:GetRecords>
' with headers {'Host'=>'boldo.caiena.net', 'User-Agent'=>'RubyHTTPGem/0.5.0'}
You can stub this request with the following snippet:
stub_request(:post, "http://boldo.caiena.net:8080/geonetwork/srv/eng/csw").
with(:body => "<?xml version=\"1.0\"?>\n<csw:GetRecords xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" service=\"CSW\" version=\"2.0.2\" resultType=\"results\" startPosition=\"1\" maxRecords=\"10\">\n <csw:Query typeNames=\"gmd:MD_Metadata\">\n <csw:Constraint version=\"1.1.0\">\n <Filter xmlns=\"http://www.opengis.net/ogc\" xmlns:gml=\"http://www.opengis.net/gml\">\n <PropertyIsLike wildCard=\"\" singleChar=\"_\">\n <PropertyName>any</PropertyName>\n <Literal/>\n </PropertyIsLike>\n </Filter>\n </csw:Constraint>\n </csw:Query>\n</csw:GetRecords>\n",
:headers => {'Host'=>'boldo.caiena.net', 'User-Agent'=>'RubyHTTPGem/0.5.0'}).
to_return(:status => 200, :body => "", :headers => {})
============================================================
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/webmock-1.17.4/lib/webmock/http_lib_adapters/http_gem_adapter.rb:76:in `exec'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/webmock-1.17.4/lib/webmock/http_lib_adapters/http_gem_adapter.rb:146:in `perform'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/http-0.5.0/lib/http/client.rb:58:in `request'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/http-0.5.0/lib/http/chainable.rb:50:in `request'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/http-0.5.0/lib/http/chainable.rb:15:in `post'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/lib/wrapper/api.rb:34:in `<class:Api>'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/lib/wrapper/api.rb:2:in `<module:Wrapper>'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/lib/wrapper/api.rb:1:in `<top (required)>'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/lib/wrapper.rb:4:in `block in <top (required)>'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/lib/wrapper.rb:3:in `each'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/lib/wrapper.rb:3:in `<top (required)>'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/spec/spec_helper.rb:5:in `require_relative'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/spec/spec_helper.rb:5:in `<top (required)>'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/spec/controllers/search_controller_spec.rb:1:in `require'
from /Users/thiagoalves/Workspace/copernico-ide/copernico/spec/controllers/search_controller_spec.rb:1:in `<top (required)>'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `each'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:22:in `run'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
from /Users/thiagoalves/.rvm/gems/ruby-2.1.0#copernico/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'

undefined method 'env' for nil:NilClass

This is what my spec file looks like: spec/api/v1/projects_spec.rb
require "spec_helper"
describe "/api/v1/projects", :type => :api do
context "projects viewable by this user" do
it "JSON" do
end
end
end
It contained a lot more but I deleted a lot of lines in an unsuccessful attempt to find the error which goes like this:
Failure/Error: Unable to find matching line from backtrace
NoMethodError: undefined method `env' for nil:NilClass
This piece of code is from the "Rails 3 in Action" by Ryan Bigg. The only other file it includes is: spec/support/api/helper.rb
module ApiHelper
include Rack::Test::Methods
def app
Rails.application
end
end
RSpec.configure do |c|
c.include ApiHelper, :type => :api
end
I've been trying to google the error for the past 1 hr and the closest thing that I found was this and as a result I deleted the code which used Devise::Test_Helpers. Sadly, its still not working.
Any help would be appreciated. Thank you so much.
Stack Trace
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/lib/devise/test_helpers.rb:24:in `setup_controller_for_warden'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-rails-2.8.1/lib/rspec/rails/adapters.rb:15:in `block (2 levels) in setup'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:35:in `instance_eval'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:35:in `run_in'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `block in run_all'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `each'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:70:in `run_all'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:368:in `run_hook'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:292:in `block in run_before_each_hooks'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:292:in `each'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:292:in `run_before_each_hooks'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:217:in `run_before_each'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:79:in `block in run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:173:in `with_around_hooks'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:77:in `run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:355:in `block in run_examples'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `map'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `run_examples'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:337:in `run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `map'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block in run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/reporter.rb:34:in `report'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:25:in `run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
# /home/prakhar/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
You're still including Devise::TestHelpers somewhere. Check and see what "spec_helper" is loading.
Instead of just including the Devise Test Helper, you can specify it's type, so that it's not included in routing spec:
config.include Devise::TestHelpers, :type => :helper
config.include Devise::TestHelpers, :type => :controller

Resources