undefined method 'env' for nil:NilClass - ruby-on-rails

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

Related

Rspec 'trait not registered error when using Faker

I am trying to use Faker in FactoryBot in my Rails API tests.
The issue I am having that I keep getting this error:
KeyError:
Trait not registered: "first_name"
So far as I can tell I have configured everything right, based on Faker'd docs at least. So far as I can tell I have two actual traits, valid_user and invalid_user that I set like so...
let(:valid_attributes) { FactoryBot.attributes_for :api_v1_user, :valid_user }
let(:invalid_attributes) { FactoryBot.attributes_for :api_v1_user, :invalid_user }
Which are linked to the :api_v1_user factory.
What have I missed or done wrong?
Full Error:
8) /api/v1/users PATCH /update with invalid parameters renders a JSON response with errors for the api/v1_user
Failure/Error: let(:invalid_attributes) { FactoryBot.attributes_for(:api_v1_user, :invalid_user) }
KeyError:
Trait not registered: "first_name"
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/activesupport-6.0.2.2/lib/active_support/hash_with_indifferent_access.rb:191:in `fetch'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/activesupport-6.0.2.2/lib/active_support/hash_with_indifferent_access.rb:191:in `fetch'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/registry.rb:23:in `find'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/decorator.rb:10:in `method_missing'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/internal.rb:49:in `trait_by_name'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:114:in `trait_by_name'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:106:in `block in base_traits'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:106:in `map'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:106:in `base_traits'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:51:in `block in compile'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:50:in `compile'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:130:in `aggregate_from_traits_and_self'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:34:in `to_create'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/trait.rb:17:in `to_create'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:135:in `map'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:135:in `aggregate_from_traits_and_self'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition.rb:34:in `to_create'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/definition_hierarchy.rb:16:in `build_from_definition'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/factory.rb:125:in `build_hierarchy'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/factory.rb:88:in `compile'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/factory.rb:32:in `run'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/activesupport-6.0.2.2/lib/active_support/notifications.rb:182:in `instrument'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/factory_runner.rb:28:in `run'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/factory_bot-5.1.2/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/requests/api/v1/users_spec.rb:6:in `block (2 levels) in <top (required)>'
# ./spec/requests/api/v1/users_spec.rb:92:in `block (4 levels) in <top (required)>'
# ./spec/rails_helper.rb:19:in `block (3 levels) in <top (required)>'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/database_cleaner-1.8.4/lib/database_cleaner/generic/base.rb:16:in `cleaning'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/database_cleaner-1.8.4/lib/database_cleaner/configuration.rb:87:in `block (2 levels) in cleaning'
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/database_cleaner-1.8.4/lib/database_cleaner/configuration.rb:88:in `cleaning'
# ./spec/rails_helper.rb:18:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# KeyError:
# key not found: "first_name"
# /home/etherk1ll/.rvm/gems/ruby-2.7.0/gems/activesupport-6.0.2.2/lib/active_support/hash_with_indifferent_access.rb:191:in `fetch'
spec/factories/api/v1/users.rb
require 'faker'
FactoryBot.define do
factory :api_v1_user, class: 'Api::V1::User' do
trait :valid_user do
first_name { Faker::Name.first_name }
second_name { Faker::Name.second_name }
username { Faker::Internet.username }
email { Faker::Internet.safe_email }
password { Faker::Internet.password(min_length: 8) }
end
trait :invalid_user do
first_name nil
end
end
end
rails_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
RSpec.configure do |config|
config.use_transactional_fixtures = false
DatabaseCleaner.strategy = :truncation
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
config.before(:all) do
DatabaseCleaner.start
end
config.after(:all) do
DatabaseCleaner.clean
end
end
users_spec.rb
Truncated
RSpec.describe "/api/v1/users", type: :request do
let(:valid_attributes) { FactoryBot.attributes_for :api_v1_user, :valid_user }
let(:invalid_attributes) { FactoryBot.attributes_for :api_v1_user, :invalid_user }
let(:valid_headers) {
{}
}
describe "PATCH /update" do
context "with invalid parameters" do
it "renders a JSON response with errors for the api/v1_user" do
user = Api::V1::User.create! valid_attributes
patch api_v1_user_url(user),
params: { api_v1_user: invalid_attributes }, headers: valid_headers, as: :json
expect(response).to have_http_status(:unprocessable_entity)
expect(response.content_type).to eq("application/json")
end
end
end
end
Try wrapping the nil in brackets. FactoryBot eliminated support for static attributes in version 5, so if you're using a newer version, that'll be your problem. Brackets are now required.
trait :invalid_user do
first_name { nil }
end

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.

NoMethodError: undefined method `addrs' for #<Mail::UnstructuredField:0x007fc5c680bf18>

So I was testing emails with RSpec and the email_spec gem and I keep coming across this error that leaves me with no real clue as to what is causing it.
I am very new to RSpec and testing in general. When I googled this the error I found one post that was similar to this error as well as a brief documentation page on the error (which came off to me as very ambiguous).
I believe the reason is due to a possibly outdated gem or method from email_spec, but I am just speculating (there's a pun for your time).
This is the error I keep receiving (I redacted my email for this post):
1) UserMailer it sends an activation email when the user signs up should be delivered from XXXXXXXX#gmail.com
Failure/Error: it { should deliver_from "XXXXXXXX#gmail.com" }
NoMethodError:
undefined method `addrs' for #<Mail::UnstructuredField:0x007fc5c680bf18>
# ./spec/mailers/user_mailer_spec.rb:12:in `block (3 levels) in <top (required)>'
Few things to point out:
I am not directly referencing the addrs method in any of my tests (so I believe)
I have included Email::Helpers and Email::Matchers in my config/test.rb file.
Here is my UserMailer test:
require "spec_helper"
require "email_spec"
describe UserMailer do
describe "it sends an activation email when the user signs up" do
user = FactoryGirl.build(:user)
subject { UserMailer.activate_account(user) }
it { should deliver_to user.email }
# Error seems to be occurring from the "deliver_from" method
it { should deliver_from "XXXXXXX2#gmail.com" }
it { should have_subject "Please confirm to activate your account." }
it { should have_body_text "Hi, #{user.first_name}" }
it { should have_body_text "Confirm Your Account" }
end
end
I would just like to be helped and pointed in the right direction as to what is causing this issue so I may take the appropriate steps to resolve it.
EDIT
Added the backtrace as requested.
# /Library/Ruby/Gems/2.0.0/gems/mail-2.6.3/lib/mail/field.rb:189:in `method_missing'
# /Library/Ruby/Gems/2.0.0/gems/email_spec-1.6.0/lib/email_spec/matchers.rb:92:in `block in matches?'
# /Library/Ruby/Gems/2.0.0/gems/email_spec-1.6.0/lib/email_spec/matchers.rb:6:in `address_array'
# /Library/Ruby/Gems/2.0.0/gems/email_spec-1.6.0/lib/email_spec/matchers.rb:92:in `matches?'
# /Library/Ruby/Gems/2.0.0/gems/rspec-expectations-2.99.2/lib/rspec/expectations/handler.rb:24:in `handle_matcher'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/memoized_helpers.rb:77:in `should'
# ./spec/mailers/user_mailer_spec.rb:12:in `block (3 levels) in <top (required)>'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:116:in `block in run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:178:in `call'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:178:in `run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:241:in `instance_eval_with_args'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:108:in `call'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:108:in `run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:446:in `run_hook'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:463:in `run_around_each_hooks'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:250:in `with_around_each_hooks'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example.rb:113:in `run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:515:in `block in run_examples'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:511:in `map'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:511:in `run_examples'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:496:in `run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:497:in `block in run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:497:in `map'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/example_group.rb:497:in `run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:24:in `block (2 levels) in run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:24:in `map'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:24:in `block in run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/reporter.rb:58:in `report'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:21:in `run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:103:in `run'
# /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:17:in `block in autorun'
Excellent! I was able to figure it out.
Issues was in my actual UserMailer class (in /app/mailers/user_mailer.rb).
The default from: statement at the top did not match with my tests.
class UserMailer < ApplicationMailer
default from: "XXXXXXXX2#gmail.com" # <= This was the culprit
def activate_account(user)
#user = user
mail(:to => #user.email, :subject => "Please confirm to activate your account.")
end
end
I recently ran into this and my problem was that i hadn't provided a proper email address in the :to field
By mistake I had -
mail(to: #user)
Instead of
mail(to: #user.email)

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

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.

Resources