I'm trying to debug this mailer error in 4.1.1 and can't figure out how to get more information on what to look into:
TypeError (no implicit conversion of nil into String):
app/controllers/api/v1/contact_form_controller.rb:5:in `create'
Here's the controller, line 5 in the error is the second line here:
def create
#mail = ContactFormMailer.contact_email(contact_params).deliver
# ContactFormSender.perform_async(contact_params)
render nothing: true, status: 200
end
My mailer looks like this:
class ContactFormMailer < ActionMailer::Base
default from: ENV["CONTACT_EMAIL"]
def contact_email(args)
#from = args[:from]
#body = args[:body]
#title = args[:title]
mail(to: ENV["CONTACT_EMAIL"], subject: 'Contact form')
end
end
The error only throws when I call deliver, which leads me to believe that it's a mailer.config issue, but everything I've looked into for gmail seems correct:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => ENV["DOMAIN"] }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings =
{
address: ENV["SMTP_SERVER"],
port: 587,
domain: ENV["MAILER_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["SMTP_USER"],
password: ENV["SMTP_PWD"]
}
I doubled checked all of my ENV variables and tried putting begin rescue end around my controller action to get more information on the error, but it just says it's a type error. Is there anyway I can get more information from a logger or something? The error makes me think it's a config setting or something that isn't being passed through, but I have no idea where to keep looking.
Edit: Here's the rest of the error:
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.0ms)
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.1ms)
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.5ms)
Rendered /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (28.8ms)
Edit 2: here's the real backtrace:
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `initialize'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `open'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `tcp_socket'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:551:in `block in do_start'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `call'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:550:in `do_start'
# /Users/evan/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:520:in `start'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/mail-2.5.4/lib/mail/message.rb:248:in `deliver!'
# ./app/controllers/api/v1/contact_form_controller.rb:5:in `create'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:189:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:136:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionview-4.1.1/lib/action_view/rendering.rb:30:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:595:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:64:in `process'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:501:in `post'
# ./spec/controllers/api/v1/contact_form_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:151:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:151:in `block in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.1.0/lib/rspec/rails/example/controller_example_group.rb:179:in `block (2 levels) in <module:ControllerExampleGroup>'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:380:in `execute_with'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:446:in `block (2 levels) in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.1.0/lib/rspec/rails/adapters.rb:72:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:321:in `instance_exec'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:380:in `execute_with'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:446:in `block (2 levels) in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:221:in `call'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:447:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/hooks.rb:500:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:330:in `with_around_example_hooks'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example.rb:148:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:500:in `block in run_examples'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:496:in `map'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:496:in `run_examples'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:463:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:464:in `block in run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:464:in `map'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/example_group.rb:464:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:111:in `block (2 levels) in run_specs'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:111:in `map'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:111:in `block in run_specs'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/reporter.rb:53:in `report'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:107:in `run_specs'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:85:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:69:in `run'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/lib/rspec/core/runner.rb:37:in `invoke'
# /Users/evan/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.1.1/exe/rspec:4:in `<top (required)>'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `load'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `<main>'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
# /Users/evan/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Your SMTP_SERVER env variable is nil.
I can consistently reproduce this error with:
2.1.2 :004 > TCPSocket.open nil, 40
TypeError: no implicit conversion of nil into String
from (irb):4:in `initialize'
from (irb):4:in `open'
from (irb):4
from /Users/mauricio/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'
You can see the actual line where it breaks here.
You should force your code to validate there's a value for all the env variables you need right at the config file instead of assuming there are values for them.
Related
When running rspec or cucumber tests I get this error:
Secret token is empty
I have my secret_key_base set in my env
Stacktrace:
RuntimeError:
Secret token is empty
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:103:in `block in track_links'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/nokogiri-1.10.5/lib/nokogiri/xml/node_set.rb:238:in `block in each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/nokogiri-1.10.5/lib/nokogiri/xml/node_set.rb:237:in `upto'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/nokogiri-1.10.5/lib/nokogiri/xml/node_set.rb:237:in `each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:88:in `track_links'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:17:in `perform'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/mailer.rb:39:in `block in save_ahoy_options'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/safely_block-0.3.0/lib/safely/core.rb:50:in `safely'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/mailer.rb:27:in `save_ahoy_options'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:413:in `block in make_lambda'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:246:in `block in halting'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `block in invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:132:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionpack-5.1.7/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionpack-5.1.7/lib/abstract_controller/base.rb:124:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/rescuable.rb:23:in `block in process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/rescuable.rb:15:in `handle_exceptions'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/rescuable.rb:22:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionview-5.1.7/lib/action_view/rendering.rb:30:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/base.rb:609:in `block in process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `block in instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/base.rb:608:in `process'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:105:in `block in processed_mailer'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:104:in `tap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:104:in `processed_mailer'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:95:in `deliver_now'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/delivery_job.rb:14:in `perform'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:37:in `block in perform_now'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/i18n-0.9.5/lib/i18n.rb:268:in `with_locale'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/translation.rb:7:in `block (2 levels) in <module:Translation>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:24:in `block (4 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `block in instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:23:in `block (3 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `block in tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `block in tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:26:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:20:in `block (2 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:135:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:33:in `perform_now'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:22:in `block in execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/railtie.rb:26:in `block (4 levels) in <class:Railtie>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/execution_wrapper.rb:85:in `wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/reloader.rb:68:in `block in wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/execution_wrapper.rb:85:in `wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/reloader.rb:67:in `wrap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/railtie.rb:25:in `block (3 levels) in <class:Railtie>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:135:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/execution.rb:20:in `execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/queue_adapters/delayed_job_adapter.rb:36:in `perform'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:81:in `block in invoke_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:61:in `block in initialize'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:66:in `execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:40:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:78:in `invoke_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:19:in `block (2 levels) in enqueue_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:61:in `block in initialize'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:66:in `execute'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/lifecycle.rb:40:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:17:in `block in enqueue_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:16:in `tap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:16:in `enqueue_job'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/delayed_job-4.1.8/lib/delayed/backend/base.rb:12:in `enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/queue_adapters/delayed_job_adapter.rb:17:in `enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/enqueuing.rb:51:in `block in enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:15:in `block (3 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `block in tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `block in tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:26:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/tagged_logging.rb:69:in `tagged'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:44:in `tag_logger'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/logging.rb:14:in `block (2 levels) in <module:Logging>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `instance_exec'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:135:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/enqueuing.rb:47:in `enqueue'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activejob-5.1.7/lib/active_job/configured_job.rb:13:in `perform_later'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:121:in `enqueue_delivery'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/actionmailer-5.1.7/lib/action_mailer/message_delivery.rb:76:in `deliver_later'
# ./app/models/group_user.rb:182:in `send_email_joined_group'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:413:in `block in make_lambda'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:235:in `block in halting_and_conditional'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `block in invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `each'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:511:in `invoke_after'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:132:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:827:in `_run_create_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/callbacks.rb:344:in `_create_record'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/timestamp.rb:102:in `_create_record'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/persistence.rb:554:in `create_or_update'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/callbacks.rb:340:in `block in create_or_update'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:131:in `run_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/callbacks.rb:340:in `create_or_update'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/persistence.rb:162:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/validations.rb:50:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/attribute_methods/dirty.rb:43:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:313:in `block in save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:384:in `block in with_transaction_returning_status'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:210:in `transaction'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:381:in `with_transaction_returning_status'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/transactions.rb:313:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activerecord-5.1.7/lib/active_record/suppressor.rb:46:in `save!'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/evaluation.rb:18:in `create'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy/create.rb:9:in `tap'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy/create.rb:9:in `result'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/factory.rb:43:in `run'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/notifications.rb:168:in `instrument'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/factory_runner.rb:28:in `run'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/factory_bot-5.1.1/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/features/groups/groups_show_spec.rb:17:in `block (3 levels) in <top (required)>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/rspec-prof-0.0.7/lib/rspec-prof.rb:76:in `block (2 levels) in <top (required)>'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:286:in `load'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:286:in `block in load'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:286:in `load'
# /Users/hidr0/.rvm/gems/ruby-2.4.6/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call'
# -e:1:in `<main>'
I went to:
.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/processor.rb:103
There I found:
raise "Secret token is empty" unless AhoyEmail.secret_token
which meant that the secret_token in the ahoy gem isn't set.I went to:
.rvm/gems/ruby-2.4.6/gems/ahoy_email-1.1.0/lib/ahoy_email/engine.rb
I found that I have commented a lot of the stuff there for debugging purposes.
gem uninstall ahoy_email -v 1.1.0
gem install ahoy_email -v 1.1.0
And it worked.
Moral of the story: 'Do not work in your gems folder.'
I'm trying to write a test that creates and object and then saves it. I want to make sure that the object is created and present on the redirected page after submission. But, I can't seem to click on the "Save" button.
relevant test:
describe 'Create a new contact list', :type => :feature do
it 'Creates a contact list with a name' do
visit new_contact_list_url
expect(page).to have_content("New Contact List")
fill_in "contact_list_name", with: "Group 1"
find('#save').click
expect(page).to have_content("Group 1")
end
end
Error I'm getting:
1) Create a new contact list Creates a contact list with a name
Failure/Error: find('#save').click
NoMethodError:
undefined method `id' for nil:NilClass
relevant HAML
=form_for(#contact_list, html: {multipart: true}) do |f|
.form-group
.field
=f.label "Contact List Name"
=f.text_field :contact_list_name, :class => 'form-contorl', :id => 'contact_list_name'
%h3 Contacts
=f.fields_for :contacts do |contact|
=render 'contact_fields', f: contact
.links
=link_to_add_association 'Add Contact', f, :contacts, :class => 'btn btn-primary', :id => 'add_contact'
=f.submit :class => 'btn btn-warning', :value => 'Save', :id => 'save'
rspec with --backtrace enabled
Failures:
1) Create a new contact list Creates a contact list with a name
Failure/Error: find("#new_contact_list").find("#save").click
NoMethodError:
undefined method `id' for nil:NilClass
# ./app/controllers/contact_lists_controller.rb:17:in `create'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller /metal/implicit_render.rb:4:in `send_action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/abstract_controller/base.rb:198:in `process_action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:117:in `call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:117:in `call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:505:in `call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:505:in `call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:92:in `_run_callbacks'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776:in `_run_process_action_callbacks'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `block in instrument'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `instrument'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
# ./.bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/abstract_controller/base.rb:137:in `process'
# ./.bundle/ruby/2.2.0/gems/actionview-4.2.1/lib/action_view/rendering.rb:30:in `process'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal.rb:196:in `dispatch'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_controller/metal.rb:237:in `block in action'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:74:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:43:in `serve'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:43:in `block in serve'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:30:in `each'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:30:in `serve'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:819:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:38:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/flash.rb:260:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/cookies.rb:560:in `call'
# ./.bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/query_cache.rb:36:in `call'
# ./.bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88:in `call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88:in `_run_callbacks'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
# ./.bundle/ruby/2.2.0/gems/web-console-2.2.1/lib/web_console/middleware.rb:39:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
# ./.bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:38:in `call_app'
# ./.bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `block in call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:26:in `tagged'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:68:in `tagged'
# ./.bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
# ./.bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
# ./.bundle/ruby/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/static.rb:113:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
# ./.bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:518:in `call'
# ./.bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:164:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/urlmap.rb:66:in `block in call'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `each'
# ./.bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `call'
# ./.bundle/ruby/2.2.0/gems/rack-test-0.6.3/lib/rack/mock_session.rb:30:in `request'
# ./.bundle/ruby/2.2.0/gems/rack-test-0.6.3/lib/rack/test.rb:244:in `process_request'
# ./.bundle/ruby/2.2.0/gems/rack-test-0.6.3/lib/rack/test.rb:67:in `post'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/rack_test/browser.rb:60:in `process'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/rack_test/browser.rb:35:in `process_and_follow_redirects'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/rack_test/browser.rb:26:in `submit'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/rack_test/form.rb:76:in `submit'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/rack_test/node.rb:61:in `click'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/node/element.rb:134:in `block in click'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/node/base.rb:84:in `synchronize'
# ./.bundle/ruby/2.2.0/gems/capybara-2.5.0/lib/capybara/node/element.rb:134:in `click'
# ./spec/features/create_contact_list_spec.rb:10:in `block (2 levels) in <top (required)>'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:148:in `instance_exec'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:148:in `block in run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `call'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# ./.bundle/ruby/2.2.0/gems/rspec-rails-3.0.2/lib/rspec/rails/adapters.rb:72:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:294:in `instance_exec'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `call'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:432:in `run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:485:in `run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:303:in `with_around_example_hooks'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example.rb:145:in `run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:494:in `block in run_examples'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:490:in `map'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:490:in `run_examples'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:457:in `run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `map'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:54:in `report'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:108:in `run_specs'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:86:in `run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
# ./.bundle/ruby/2.2.0/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
# /Users/cowan/.rvm/gems/ruby-2.2.1/bin/rspec:23:in `load'
# /Users/cowan/.rvm/gems/ruby-2.2.1/bin/rspec:23:in `<main>'
# /Users/cowan/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
# /Users/cowan/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
edit for relevant controller action (create)
def create
#contact_list = ContactList.new(contact_list_params)
#contact_list.user_id = current_user.id
if #contact_list.save
flash[:success] = "Contact List Created"
redirect_to contact_lists_url
else
render 'contact_lists/new'
end
end
How would I log in a user using rspec? Since my login helper methods
are in app/helpers/sessions_helper.rb
Just write some function where you're signing in via Capybara, i.e.
visit '/auth'
fill_in :login, with: 'John'
fill_in :password, with: '123'
click 'Login'
and then use it in your tests, for example, in before { } block.
If you have a lot of tests and this approach is too slow, take a look at Warden::Test::Helpers.
Also, take a look at this answer: Using Devise in rspec feature tests.
Instead of find("#save").click, have you tried using click('Save')?
If you have, were you unsuccessful? Answering why that is might help you here.
I have the follwing in my factories.rb:
factory :ffsupervisor, class: Supervisor do
first_name "ffsupervisor"
email "ffsupervisor#abc.com"
password "123456"
type "Supervisor"
association :agency, name: "FFAgency", full_fee: "2.0", partial_fee: "1.0", agency_type: "Fulfilment"
end
I'm able to build and save an instance of Supervisor in my DB with FactoryGirl::create(:ffsupervisor) in the Rails Console. When I try to do the same thing in my feature specs, I end up getting:
NoMethodError: undefined method `stringify_keys'.
I've looked into a lot of questions in SO regarding this issue. Haven't been able to figure out what I'm missing out though. Any heads up on this would be great. TIA!
EDIT:
This is the stack trace I'm getting:
1) Workflow order_item lifecycle.
Failure/Error: #supervisor= FactoryGirl::create(:ffsupervisor) # Creates both agency & supervisor.
NoMethodError:
undefined method `stringify_keys' for #<Supervisor:0x0000000baa9410>
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:436:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:131:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:17:in `assign_attributes'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/core.rb:192:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:47:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'
# ./app/mailers/synup_mailer.rb:13:in `confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:189:in `process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__1572042514373682743__process_action__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:136:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/rendering.rb:44:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:503:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:497:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:121:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:121:in `actual_message'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:97:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:40:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:40:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/authenticatable.rb:173:in `send_devise_notification'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:102:in `send_confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:158:in `send_on_create_confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:397:in `_run__462299154380556768__create__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:303:in `create_record'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/timestamp.rb:57:in `create_record'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/persistence.rb:466:in `create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `block in create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:393:in `_run__462299154380556768__save__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/persistence.rb:128:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/validations.rb:57:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `block in save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/ar_after_transaction-0.4.0/lib/ar_after_transaction.rb:19:in `block in transaction_with_after'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/ar_after_transaction-0.4.0/lib/ar_after_transaction.rb:17:in `transaction_with_after'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/configuration.rb:14:in `block in initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `[]'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `create'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/notifications.rb:161:in `instrument'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method'
# ./spec/features/workflow_spec.rb:39:in `block (2 levels) in <top (required)>'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `instance_eval'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:179:in `call'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:179:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:87:in `block (2 levels) in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:89:in `call'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:89:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:418:in `run_hook'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:329:in `run_around_each_hooks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:111:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `map'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `run_examples'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:371:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `map'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/reporter.rb:34:in `report'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:25:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
I have set up Pundit together with Devise for authorization on my application. In one of my controllers, I have before_action :authorize.
I then have the following test:
describe SomeController do
before(:each) do
login_user(FactoryGirl.create(:user, :user_type => :admin))
end
describe "GET index" do
it "it retrieves the index" do
something = FactoryGirl.create(:Something)
get :index
assigns(:something).should eq([something])
end
end
end
I receive the error:
wrong number of arguments (0 for 1)
The login helper is fairly straight forward:
module ControllerMacros
def login_user(user)
if user.nil?
user = FactoryGirl.create(:user)
end
#request.env["devise.mapping"] = Devise.mappings[:user]
sign_in user
end
end
Update:
Stacktrace:
Failure/Error: get :index
ArgumentError:
wrong number of arguments (0 for 1..2)
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/pundit-0.2.3/lib/pundit.rb:62:in `authorize'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:424:in `block in make_lambda'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:160:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:160:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:136:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionview-4.1.1/lib/action_view/rendering.rb:30:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:595:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:64:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:19:in `block in process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:72:in `catch'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:72:in `_catch_warden'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/devise-3.2.4/lib/devise/test_helpers.rb:19:in `process'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.1.1/lib/action_controller/test_case.rb:495:in `get'
# ./spec/controllers/SomeController_spec.rb:31:in `block (4 levels) in <top (required)>'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `instance_eval'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:179:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:179:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:108:in `call'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:108:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:446:in `run_hook'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:340:in `run_around_each_hooks'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:111:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `run_examples'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:371:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `map'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block in run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/reporter.rb:58:in `report'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:25:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
# /Users/Me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
Pundit's authorize method is not intended to be called as a before_action. before_action calls a method with no arguments, and authorize takes a model object and an optional permission name. That's why you're getting the error you are.
You're not showing enough of the relevant code for me to see what you should do next, but I suggest getting Pundit to work in your controller action before pulling it out into a callback.
There is an example of the correct use of authorize here: https://github.com/elabs/pundit
You can define a private helper method in your controller(or in the application_controller if you will use it in all the controllers) which calls authorize current_user, and then call the private method before_action. Like this:
private
def perform_authorization
authorize current_user
end
and then call it as a before_action :
before_action :perform_authorization
I wrote a full rails engine, and trying to test (with RSpec) my controller.
Error only occurred, when render method called. On return or redirect methods all works fine. And problem only with tests. I use dummy app.
stack:
# Failure/Error: get(:search, params)
ActionView::Template::Error:
undefined method `config' for #<Rails::App:0x000000034d9ee8>
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.15/lib/rails.rb:78:in `root'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:175:in `inspect'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:334:in `identifier_method_name'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:330:in `method_name'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:267:in `compile'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:244:in `block in compile!'
# <internal:prelude>:10:in `synchronize'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:232:in `compile!'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:144:in `block in render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications.rb:123:in `block in instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications.rb:123:in `instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/template.rb:143:in `render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications.rb:123:in `block in instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications.rb:123:in `instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/template_renderer.rb:18:in `render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/renderer.rb:36:in `render_template'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_view/renderer/renderer.rb:17:in `render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/rendering.rb:110:in `_render_template'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/streaming.rb:225:in `_render_template'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/rendering.rb:103:in `render_to_body'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/rendering.rb:88:in `render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/rendering.rb:16:in `render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
# /home/shooma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/core_ext/benchmark.rb:5:in `ms'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.15/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/instrumentation.rb:39:in `render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/base.rb:167:in `process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/callbacks.rb:403:in `_run__3295526729938120009__process_action__2756155078140629527__callbacks'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/callbacks.rb:405:in `__run_callback'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/callbacks.rb:81:in `run_callbacks'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications.rb:123:in `block in instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.15/lib/active_support/notifications.rb:123:in `instrument'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.15/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/base.rb:121:in `process'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/abstract_controller/rendering.rb:45:in `process'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/metal/testing.rb:17:in `process_with_new_base_test'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/test_case.rb:490:in `process'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/test_case.rb:54:in `process'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.15/lib/action_controller/test_case.rb:407:in `get'
# ./spec/controllers/pretty_search_controller_spec.rb:37:in `block (5 levels) in <top (required)>'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example.rb:114:in `instance_eval'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example.rb:114:in `block in run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/hooks.rb:104:in `call'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/hooks.rb:104:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/hooks.rb:446:in `run_hook'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:340:in `run_around_each_hooks'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example.rb:111:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:386:in `map'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:386:in `run_examples'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:371:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `block in run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `map'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `block in run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `map'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `block in run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `map'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/example_group.rb:372:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:28:in `map'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:28:in `block in run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/reporter.rb:58:in `report'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/command_line.rb:25:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:80:in `run'
# /home/shooma/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.14.6/lib/rspec/core/runner.rb:17:in `block in autorun'
In which direction i should dig?
engine on GitHub
UPD:
when in controller call render - I got error.
but if in controller call render :text => 'foo' - test passes.
problem somewhere in dummy application config. but i can't locate it.
UPD2:
falling spec:
context 'action should return #options and #results' do
it '#options should be an instance variable, which eq hash of three keys' do
get(:search, params)
# do something
end
end
controller:
def search
# do something
render
end
RESOLUTION:
It was my fault. Problem was in overloading some internal rails classes in test environment. Sorry for spent time, #sameera207, and thank you for participation.
the difference between render and redirect is, redirect loads your redirected action but render doesn't,
Ex:
def new
#user = User.new
end
def create
if <some conditions>
redirect_to 'new'
else
render 'new'
end
end
so when you call render, it doesnt create User.new, only redirect will. So probably you are rendering an action which loads something from config.
So the solutions would be
def new
#user = User.new
end
def create
if <some conditions>
redirect_to 'new'
else
#user = User.new
render 'new'
end
end
I hope u get the idea. and if you could post the spec someone might be able to help easier ..