I'm having trouble integrating JS tests into my rails/angular application. In particular, my test setup is choking on the 8th and final occurrence of {{handlebars}} in this html file, and I cant' figure out what's special about this occurrence.
The problem error comes at line 784 of _form.html.erb:
<textarea class="figures_json col-lg-11 col-md-10 col-xs-9" readonly="readonly" name="dance[figures_json]" id="dance_figures_json">
{{2+2}}</textarea>
And the error is this:
dm#red:~/contra$ rspec ./spec/features/dances/create_spec.rb:7
Run options: include {:locations=>{"./spec/features/dances/create_spec.rb"=>[7]}}
F
Failures:
1) Creating dances creates a new dance with non-javascript data
Failure/Error: JSON.parse figures_json
ActionView::Template::Error:
784: unexpected token at '{{2+2}}'
# ./app/models/dance.rb:10:in `figures'
# ./app/views/dances/_bodyshow.html.erb:6:in `_app_views_dances__bodyshow_html_erb__2235413439078114529_46217560'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/template.rb:145:in `block in render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:166:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/template.rb:333:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/template.rb:143:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/partial_renderer.rb:339:in `render_partial'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/partial_renderer.rb:310:in `block in render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `block in instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/partial_renderer.rb:309:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/renderer.rb:47:in `render_partial'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/renderer.rb:21:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/helpers/rendering_helper.rb:32:in `render'
# ./app/views/dances/show.html.erb:16:in `_app_views_dances_show_html_erb__1493296941766923553_47454680'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/template.rb:145:in `block in render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:166:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/template.rb:333:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/template.rb:143:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `block in instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/template_renderer.rb:52:in `render_template'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/template_renderer.rb:14:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/renderer.rb:42:in `render_template'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/renderer/renderer.rb:23:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/rendering.rb:100:in `_render_template'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/streaming.rb:217:in `_render_template'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/rendering.rb:83:in `render_to_body'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/rendering.rb:32:in `render_to_body'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/renderers.rb:37:in `render_to_body'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/abstract_controller/rendering.rb:25:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/rendering.rb:16:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/core_ext/benchmark.rb:12:in `ms'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:44:in `block in render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.3/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:43:in `render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/abstract_controller/base.rb:198:in `process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:115:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:553:in `block (2 levels) in compile'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:88:in `run_callbacks'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `block in instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `instrument'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.3/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/abstract_controller/base.rb:137:in `process'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionview-4.2.3/lib/action_view/rendering.rb:30:in `process'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal.rb:196:in `dispatch'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_controller/metal.rb:237:in `block in action'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:45:in `serve'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/journey/router.rb:43:in `block in serve'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/journey/router.rb:30:in `each'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/journey/router.rb:30:in `serve'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:821:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/warden-1.2.4/lib/warden/manager.rb:35:in `block in call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/warden-1.2.4/lib/warden/manager.rb:34:in `catch'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/warden-1.2.4/lib/warden/manager.rb:34:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/flash.rb:260:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/cookies.rb:560:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.3/lib/active_record/query_cache.rb:36:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:84:in `run_callbacks'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/web-console-2.2.1/lib/web_console/middleware.rb:39:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.3/lib/rails/rack/logger.rb:38:in `call_app'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.3/lib/rails/rack/logger.rb:20:in `block in call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `block in tagged'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:26:in `tagged'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `tagged'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.3/lib/rails/rack/logger.rb:20:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/request_id.rb:21:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.3/lib/action_dispatch/middleware/static.rb:116:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.3/lib/rails/engine.rb:518:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.3/lib/rails/application.rb:165:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/urlmap.rb:66:in `block in call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `each'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/server.rb:43:in `call'
# /home/dm/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find css "h1" with text "Call Me" but there were no matches. Also found "Internal Server Error", which matched the selector but not all filters.
# /home/dm/.rvm/gems/ruby-2.3.0/gems/capybara-2.7.1/lib/capybara/node/matchers.rb:128:in `block in assert_selector'
Finished in 1.77 seconds (files took 1.59 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/features/dances/create_spec.rb:7 # Creating dances creates a new dance with non-javascript data
Here's a link to my Gemfile.lock so you can see what versions of stuff I'm using.
Are you sure that problem comes from line 784 of _form.html.erb? I can't find this file in a call stack! Call stack states it chokes on dance.rb#10 and, probably, figures_json contains that {{2+2}} which is not a JSON.
UPDATE
I just had a spare minute to download & look what is actually happening in the app.
When you render new action you, actually, send the create action via JS and create the Dance with value {{2+2}} from that _form. While it looks odd to me (why create on just new action?) I figure out the reason – angular does not evaluate expressions inside textarea, you need to bind it to ng-model. So, you want to re-write that textarea as this:
<textarea class="figures_json col-lg-11 col-md-10 col-xs-9" readonly="readonly" name="dance[figures_json]" id="dance_figures_json" ng-model="2+2">
Related
I'm running into an error that says:
ActionView::Template::Error:
wrong number of arguments (given 1, expected 0)
Here's the relevant code in the model:
class LocationProgram < ApplicationRecord
include CtasMixin
belongs_to :location, inverse_of: :location_programs
belongs_to :program, inverse_of: :location_programs
belongs_to :thumbnail, class_name: 'ImageAsset', foreign_key: :thumbnail_asset_id
has_many :content_images, -> { order('sequence ASC NULLS LAST') }, as: :contentable, dependent: :destroy
has_cta :ecommerce_cta, "buy-tickets"
%w(content_images thumbnail ecommerce_cta).each do |attr|
# this code below raises the error
# line below is location_program.rb:50
define_method(attr) { program&.send(attr) || super(attr) }
end
...
end
class Program < ApplicationRecord
include CtasMixin
has_many :location_programs, dependent: :destroy, inverse_of: :program
has_many :locations, through: :location_programs
belongs_to :thumbnail, class_name: 'ImageAsset', foreign_key: :thumbnail_asset_id
has_many :content_images, -> { order('sequence ASC NULLS LAST') }, as: :contentable, dependent: :destroy
has_cta :ecommerce_cta, "buy-tickets"
...
end
module CtasMixin
extend ActiveSupport::Concern
module ClassMethods
def has_cta(attr_name, default_slug = '')
belongs_to attr_name, class_name: 'CallToAction'
define_method "#{attr_name}_default_object" do
CallToAction.find_by(slug: default_slug) if default_slug.present?
end
define_method "#{attr_name}_value" do
# Line below is line 35
send(attr_name).try(:value_t) || send("#{attr_name}_default_value")
end
define_method "#{attr_name}_default_value" do
if default_slug.present?
cta = send("#{attr_name}_default_object")
cta ? cta.value_t : default_slug.titleize
end
end
end
end
end
I recently upgraded my rails version from 5.0 to 5.2 and this happened when I tried to run rspec.
I'm not too sure what's going on here, I suspect it has something to do with my CtasMixin concern. I've tried to search around but I wasn't able to figure out anything that's related to my issue here.
Full stack trace:
Failure/Error: define_method(attr) { program&.send(attr) || super(attr) }
ActionView::Template::Error:
wrong number of arguments (given 1, expected 0)
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/associations/builder/association.rb:107:in `ecommerce_cta'
# ./app/models/location_program.rb:50:in `block (2 levels) in <class:LocationProgram>'
# ./app/models/concerns/ctas_mixin.rb:35:in `block in has_cta'
# ./app/views/site/locations/programs/show.html.erb:23:in `_app_views_site_locations_programs_show_html_erb__1085825840410338714_70185561273160'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/template.rb:159:in `block in render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/notifications.rb:170:in `instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/template.rb:354:in `instrument_render_template'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/template.rb:157:in `render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/notifications.rb:168:in `block in instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/notifications.rb:168:in `instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/template_renderer.rb:52:in `render_template'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/template_renderer.rb:16:in `render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/renderer.rb:44:in `render_template'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/renderer/renderer.rb:25:in `render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/rendering.rb:103:in `_render_template'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/streaming.rb:219:in `_render_template'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/rendering.rb:84:in `render_to_body'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/rendering.rb:52:in `render_to_body'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/renderers.rb:142:in `render_to_body'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/abstract_controller/rendering.rb:25:in `render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/rendering.rb:36:in `render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/core_ext/benchmark.rb:14:in `ms'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/instrumentation.rb:46:in `block in render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/instrumentation.rb:45:in `render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/wicked_pdf-2.0.1/lib/wicked_pdf/pdf_helper.rb:46:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/wicked_pdf-2.0.1/lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/wicked_pdf-2.0.1/lib/wicked_pdf/pdf_helper.rb:30:in `render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/implicit_render.rb:35:in `default_render'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/andand-1.3.3/lib/andand.rb:60:in `me'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/abstract_controller/base.rb:194:in `process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/sentry-raven-2.13.0/lib/raven/integrations/rails/controller_transaction.rb:7:in `block in included'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/callbacks.rb:118:in `instance_exec'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/notifications.rb:168:in `block in instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/notifications.rb:168:in `instrument'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/abstract_controller/base.rb:134:in `process'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionview-5.2.4.1/lib/action_view/rendering.rb:32:in `process'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal.rb:191:in `dispatch'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_controller/metal.rb:252:in `dispatch'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/routing/route_set.rb:34:in `serve'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/journey/router.rb:52:in `block in serve'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/journey/router.rb:35:in `each'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/journey/router.rb:35:in `serve'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/routing/route_set.rb:840:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/route_downcaser-1.2.3/lib/route_downcaser/downcase_route_middleware.rb:42:in `_call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/route_downcaser-1.2.3/lib/route_downcaser/downcase_route_middleware.rb:11:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/scout_apm-2.6.6/lib/scout_apm/middleware.rb:17:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/warden-1.2.8/lib/warden/manager.rb:36:in `block in call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/warden-1.2.8/lib/warden/manager.rb:34:in `catch'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/warden-1.2.8/lib/warden/manager.rb:34:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/tempfile_reaper.rb:15:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/etag.rb:27:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/conditional_get.rb:27:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/head.rb:12:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/session/abstract/id.rb:266:in `context'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/session/abstract/id.rb:260:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/cookies.rb:670:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/rack/logger.rb:38:in `call_app'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/rack/logger.rb:26:in `block in call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/tagged_logging.rb:71:in `block in tagged'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/tagged_logging.rb:28:in `tagged'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/tagged_logging.rb:71:in `tagged'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/rack/logger.rb:26:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/method_override.rb:24:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/runtime.rb:22:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activesupport-5.2.4.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-rewrite-1.5.1/lib/rack/rewrite.rb:24:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/static.rb:127:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/font_assets-0.1.14/lib/font_assets/middleware.rb:17:in `block in call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/font_assets-0.1.14/lib/font_assets/middleware.rb:40:in `do_request'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/font_assets-0.1.14/lib/font_assets/middleware.rb:16:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/sendfile.rb:110:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/sentry-raven-2.13.0/lib/raven/integrations/rack.rb:51:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/railties-5.2.4.1/lib/rails/engine.rb:524:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/urlmap.rb:74:in `block in call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/urlmap.rb:58:in `each'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/urlmap.rb:58:in `call'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-test-1.1.0/lib/rack/mock_session.rb:29:in `request'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-test-1.1.0/lib/rack/test.rb:266:in `process_request'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-test-1.1.0/lib/rack/test.rb:129:in `custom_request'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/rack-test-1.1.0/lib/rack/test.rb:58:in `get'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/capybara-3.31.0/lib/capybara/rack_test/browser.rb:68:in `process'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/capybara-3.31.0/lib/capybara/rack_test/browser.rb:43:in `process_and_follow_redirects'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/capybara-3.31.0/lib/capybara/rack_test/browser.rb:23:in `visit'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/capybara-3.31.0/lib/capybara/rack_test/driver.rb:45:in `visit'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/capybara-3.31.0/lib/capybara/session.rb:278:in `visit'
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/capybara-3.31.0/lib/capybara/dsl.rb:58:in `block (2 levels) in <module:DSL>'
# ./spec/features/site/locations_pages_spec.rb:189:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# ArgumentError:
# wrong number of arguments (given 1, expected 0)
# /Users/mattvo/.rvm/gems/ruby-2.6.5/gems/activerecord-5.2.4.1/lib/active_record/associations/builder/association.rb:107:in `ecommerce_cta'
I am attempting to export data to an excel document and have been following railscast 362 however I am getting errors. The main issue I seem to be having is that previously campaign didnt have a model file but rather an observer file. When I create a campaign model file an error occurs relating to ransack search features on the page however these errors do not occur when i remove the campaign model file again. Can anyone explain the difference and why I might be getting this error.
Controller: campaigns_controller.rb
def index
#search = Campaign.search(params[:q])
#campaigns = #search.result.page(params[:page]||1)
if params[:sort]
#my_campaigns = Campaign.active
#campaigns = #my_campaigns
#campaigns = #campaigns.order(sort_column + " " + sort_direction).page(params[:page]||1)
end
respond_to do |format|
format.html
format.csv { send_data #campaigns.to_csv }
format.xls
end
end
Model: campaign.rb
class Campaign < ActiveRecord::Base
def self.to_csv(options = {})
CSV.generate(options) do |csv|
csv << column_names
all.each do |product|
csv << product.attributes.values_at(*column_names)
end
end
end
end
View link
= link_to '<i class="glyphicon glyphicon-cloud-download"></i>'.html_safe, admin_campaigns_path(format: "csv"), title: "Download Campaign XLS", rel: 'tooltip'
= link_to '<i class="glyphicon glyphicon-cloud-download"></i>'.html_safe, admin_campaigns_path(format: "xls"), title: "Download Campaign XLS", rel: 'tooltip'
Full Trace
/home.rvm/gems/ruby-2.3.0/gems/ransack-1.1.0/lib/ransack/search.rb:89:in `method_missing'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:1159:in `value_before_type_cast'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:1147:in `value_before_type_cast'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:1041:in `block in to_input_field_tag'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:1041:in `fetch'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:1041:in `to_input_field_tag'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:690:in `text_field'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:1283:in `text_field'
app/views/admin/campaigns/index.html.haml:45:in `block in _app_views_admin_campaigns_index_html_haml___1611602558606621117_84091040'
/home.rvm/gems/ruby-2.3.0/gems/haml-3.2.0.rc.4/lib/haml/helpers/action_view_mods.rb:133:in `block (2 levels) in form_for_with_haml'
/home.rvm/gems/ruby-2.3.0/gems/haml-3.2.0.rc.4/lib/haml/helpers.rb:278:in `with_tabs'
/home.rvm/gems/ruby-2.3.0/gems/haml-3.2.0.rc.4/lib/haml/helpers/action_view_mods.rb:133:in `block in form_for_with_haml'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
/home.rvm/gems/ruby-2.3.0/gems/haml-3.2.0.rc.4/lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/capture_helper.rb:40:in `capture'
/home.rvm/gems/ruby-2.3.0/gems/haml-3.2.0.rc.4/lib/haml/helpers/action_view_mods.rb:59:in `capture_with_haml'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:378:in `form_for'
/home.rvm/gems/ruby-2.3.0/gems/haml-3.2.0.rc.4/lib/haml/helpers/action_view_mods.rb:135:in `form_for_with_haml'
/home.rvm/gems/ruby-2.3.0/gems/haml-3.2.0.rc.4/lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss'
/home.rvm/gems/ruby-2.3.0/gems/ransack-1.1.0/lib/ransack/helpers/form_helper.rb:24:in `search_form_for'
app/views/admin/campaigns/index.html.haml:42:in `_app_views_admin_campaigns_index_html_haml___1611602558606621117_84091040'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/template.rb:145:in `block in render'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications.rb:125:in `instrument'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/template.rb:143:in `render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/template_renderer.rb:48:in `block (2 levels) in render_template'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications.rb:123:in `block in instrument'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications.rb:123:in `instrument'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/template_renderer.rb:47:in `block in render_template'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/template_renderer.rb:55:in `render_with_layout'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/template_renderer.rb:46:in `render_template'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/template_renderer.rb:18:in `render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/renderer.rb:41:in `render_template'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_view/renderer/renderer.rb:22:in `render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/rendering.rb:110:in `_render_template'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/streaming.rb:225:in `_render_template'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/rendering.rb:103:in `render_to_body'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/rendering.rb:88:in `render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/rendering.rb:16:in `render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
/home.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.2/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/instrumentation.rb:39:in `render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/mime_responds.rb:196:in `respond_to'
app/controllers/admin/campaigns_controller.rb:20:in `index'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/base.rb:167:in `process_action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:459:in `block in _run__3061069654697754334__process_action__3738294813647729293__callbacks'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_8614'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:326:in `around'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:310:in `_callback_around_15'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_8614'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:414:in `_run__3061069654697754334__process_action__3738294813647729293__callbacks'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:405:in `__run_callback'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/rescue.rb:29:in `process_action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications.rb:123:in `block in instrument'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications.rb:123:in `instrument'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/home.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.2/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/base.rb:121:in `process'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/abstract_controller/rendering.rb:45:in `process'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal.rb:203:in `dispatch'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_controller/metal.rb:246:in `block in action'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/routing/route_set.rb:36:in `call'
/home.rvm/gems/ruby-2.3.0/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/home.rvm/gems/ruby-2.3.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/home.rvm/gems/ruby-2.3.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/routing/route_set.rb:608:in `call'
/home.rvm/gems/ruby-2.3.0/gems/warden-1.2.6/lib/warden/manager.rb:35:in `block in call'
/home.rvm/gems/ruby-2.3.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `catch'
/home.rvm/gems/ruby-2.3.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/etag.rb:23:in `call'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/conditionalget.rb:25:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/head.rb:14:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/flash.rb:242:in `call'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/session/abstract/id.rb:210:in `context'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/session/abstract/id.rb:205:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/home.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.2/lib/active_record/query_cache.rb:64:in `call'
/home.rvm/gems/ruby-2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:405:in `_run__2077840542981017711__call__2151128257704977288__callbacks'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:405:in `__run_callback'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/home.rvm/gems/ruby-2.3.0/gems/better_errors-1.1.0/lib/better_errors/middleware.rb:58:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/rack/logger.rb:32:in `call_app'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/rack/logger.rb:16:in `block in call'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/tagged_logging.rb:22:in `tagged'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/rack/logger.rb:16:in `call'
config/initializers/quiet_assets.rb:7:in `call_with_quiet_assets'
/home.rvm/gems/ruby-2.3.0/gems/request_store-1.3.1/lib/request_store/middleware.rb:9:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/methodoverride.rb:21:in `call'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/runtime.rb:17:in `call'
/home.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.22.2/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/lock.rb:15:in `call'
/home.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.22.2/lib/action_dispatch/middleware/static.rb:83:in `call'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/engine.rb:484:in `call'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/application.rb:231:in `call'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/content_length.rb:14:in `call'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/rack/log_tailer.rb:17:in `call'
/home.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/connection.rb:86:in `block in pre_process'
/home.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/connection.rb:84:in `catch'
/home.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/connection.rb:84:in `pre_process'
/home.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/connection.rb:53:in `process'
/home.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/connection.rb:39:in `receive_data'
/home.rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run_machine'
/home.rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run'
/home.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/backends/base.rb:73:in `start'
/home.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/server.rb:162:in `start'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/handler/thin.rb:13:in `run'
/home.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/server.rb:268:in `start'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/commands/server.rb:70:in `start'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/commands.rb:55:in `block in <top (required)>'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/commands.rb:50:in `tap'
/home.rvm/gems/ruby-2.3.0/gems/railties-3.2.22.2/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
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 am new to rails and am trying to get the following bit of rspec to pass that will enable calling a path to flag a course as hidden:
describe 'PATCH hide_course' do
before :each do
#course = create(:course)
end
it 'marks the course as hidden' do
patch :hide_course, id: #course
expect(#course.reload.hidden?).to be_true
end
it 'redirects to courses#index' do
patch :hide_course, id: #course
expect(response).to redirect_to course_url
end
end
I then set the following route with no problems:
resources :courses
put '/courses/:id/hide_course', to: 'courses#hide_course'
My problem is in setting the controller action. Here is the bit I wrote in my CoursesController:
def hide_course
#course = Course.find(params[:id])
#course.hide
end
private
def course_params
params.require(:course).permit(:name,:description,:department,:hidden,
:lecture_attributes => [:name,:description,:level])
end
My model then looks like this:
def hide
update!(:hidden => true)
end
What is the best way for me to set up this method in rails 4? I keep getting errors about the hidden attribute not existing even though it is in my schema. Thanks!
PS- The backtrace I get for the first spec is this:
1) CoursesController PATCH hide_course marks the course as hidden
Failure/Error: patch :hide_course, id: #course
ActiveRecord::UnknownAttributeError:
unknown attribute: hidden
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/attribute_assignment.rb:59:in `rescue in _assign_attribute'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/attribute_assignment.rb:35:in `each'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/persistence.rb:262:in `block in update!'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/transactions.rb:218:in `transaction'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/persistence.rb:261:in `update!'
# ./app/models/course.rb:13:in `hide'
# ./app/controllers/courses_controller.rb:60:in `hide_course'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/abstract_controller/base.rb:198:in `process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:114:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:114:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:231:in `block in halting'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:231:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:231:in `block in halting'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:166:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:166:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:231:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:231:in `block in halting'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:166:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:166:in `block in halting'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:87:in `call'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/callbacks.rb:87:in `run_callbacks'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/notifications.rb:164:in `block in instrument'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0.beta2/lib/active_support/notifications.rb:164:in `instrument'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/activerecord-4.2.0.beta2/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/abstract_controller/base.rb:137:in `process'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionview-4.2.0.beta2/lib/action_view/rendering.rb:30:in `process'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/test_case.rb:628:in `process'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/test_case.rb:64:in `process'
# /Users/sjensen/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.0.beta2/lib/action_controller/test_case.rb:516:in `patch'
# ./spec/controllers/courses_controller_spec.rb:171:in `block (3 levels) in <top (required)>'
Make sure your test db is setup correctly. Try running rake db:test:prepare
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 ..