ruby on rails 4 - How can I stub a controller helper method in a view spec with RSpec 3.4? -
i'm testing view rspec (3.4 on rails 4.2.5). , use decent_exposure gem in crud controller. decent_exposure makes easy define named methods made available views , memoize resultant values.
but don't understand how can stub these methods in view spec. tried according rspec documentation, raises error.
why doesn't work? how can stub method article
in view?
my controller
class account::articlescontroller < account::basecontroller expose(:articles) { current_user.articles } expose(:article, attributes: :article_params) # post /account/articles # post /account/articles.json def create respond_to |format| if article.save format.html { redirect_to account_article_url(article), notice: 'article created.' } format.json { render :show, status: :created, location: account_article_url(article) } else format.html { render :new } format.json { render json: article.errors, status: :unprocessable_entity } end end end # patch/put /account/articles/1 # patch/put /account/articles/1.json def update respond_to |format| if article.update(article_params) format.html { redirect_to account_article_url(article), notice: 'article updated.' } format.json { render :show, status: :ok, location: account_article_url(article) } else format.html { render :edit } format.json { render json: article.errors, status: :unprocessable_entity } end end end # delete /account/articles/1 # delete /account/articles/1.json def destroy respond_to |format| if article.destroy format.html { redirect_to account_articles_url, notice: 'article destroyed.' } format.json { head :no_content } else format.html { redirect_to account_articles_url, notice: 'article not destroyed.' } format.json { render json: article.errors, status: :unprocessable_entity } end end end private def article_params params.require(:article).permit(:title, :announce, :content, :is_published, :published_at) end end
and have view spec
require 'rails_helper' rspec.describe 'account/articles/new', type: :view before allow(view).to receive(:article).and_return(build(:article)) end 'renders new article form' render expect(rendered).to match %q{form[action=#{account_articles_path}][method=post]} end end
but raises error
failures: 1) account/articles/new renders new article form failure/error: allow(view).to receive(:article).and_return(build(:article)) #<#<class:0x007fe85c2c7620>:0x007fe85d161208 @_routes=nil, @_config={}, @view_renderer=#<actionview::renderer:0x007fe85d1613c0 @lookup_context=#<actionview::lookupcontext:0x007fe85d1615a0 @details_key=nil, @details={:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder, :haml]}, @skip_default_locale=false, @cache=true, @prefixes=["", "account/articles"], @rendered_format=nil, @view_paths=#<actionview::pathset:0x007fe85d1614d8 @paths=[#<actionview::optimizedfilesystemresolver:0x007fe85d37fb48 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<actionview::resolver::cache:0x007fe85d37fb20 @data=#<actionview::resolver::cache::smallcache:0x007fe85d37faf8 @backend={}, @default_proc=#<proc:0x007fe85f071198@/users/et/.rvm/gems/ruby-2.2.2/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/users/et/documents/projects/test-blog/app/views">, #<actionview::optimizedfilesystemresolver:0x007fe85d37feb8 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<actionview::resolver::cache:0x007fe85d37fe90 @data=#<actionview::resolver::cache::smallcache:0x007fe85d37fe68 @backend={}, @default_proc=#<proc:0x007fe85f071198@/users/et/.rvm/gems/ruby-2.2.2/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/users/et/.rvm/gems/ruby-2.2.2/gems/devise-3.5.3/app/views">]>>>, @request=#<actioncontroller::testrequest:0x007fe85c35e048 @env={"rack.version"=>[1, 3], "rack.input"=>#<stringio:0x007fe85f87eca0>, "rack.errors"=>#<stringio:0x007fe85f87ed40>, "rack.multithread"=>true, "rack.multiprocess"=>true, "rack.run_once"=>false, "request_method"=>"get", "server_name"=>"example.org", "server_port"=>"80", "query_string"=>"", "rack.url_scheme"=>"http", "https"=>"off", "script_name"=>"", "content_length"=>"0", "http_host"=>"test.host", "remote_addr"=>"0.0.0.0", "http_user_agent"=>"rails testing", "action_dispatch.routes"=>#<actiondispatch::routing::routeset:0x007fe85c6713e8>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", "action_dispatch.show_exceptions"=>false, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<activesupport::logger:0x007fe85d32d528 @progname=nil, @level=0, @default_formatter=#<logger::formatter:0x007fe85d32d4b0 @datetime_format=nil>, @formatter=#<activesupport::logger::simpleformatter:0x007fe85d2fc928 @datetime_format=nil>, @logdev=#<logger::logdevice:0x007fe85d32d460 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<file:/users/et/documents/projects/test-blog/log/test.log>, @mutex=#<logger::logdevice::logdevicemutex:0x007fe85d32d438 @mon_owner=nil, @mon_count=0, @mon_mutex=#<mutex:0x007fe85d32d3e8>>>>, "action_dispatch.backtrace_cleaner"=>#<rails::backtracecleaner:0x007fe85c2f4aa8 @filters=[#<proc:0x007fe85c2f4878@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:14>, #<proc:0x007fe85c2f4850@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:15>, #<proc:0x007fe85c2f47d8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:16>, #<proc:0x007fe85c2f5750@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:29>], @silencers=[#<proc:0x007fe85c2f59a8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:19>], @root="/users/et/documents/projects/test-blog/">, "action_dispatch.key_generator"=>#<activesupport::cachingkeygenerator:0x007fe85f4cc580 @key_generator=#<activesupport::keygenerator:0x007fe85f4cc5a8 @secret="eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", @iterations=1000>, @cache_keys=#<threadsafe::cache:0x007fe85f4cc558 @backend={"signed_global_ids64"=>"0\xf4/#*5\xf2\x0f\xb2\x101\v~\xc5\x89\xff\xdb\x11\xcb(u\xfa\xf87\x13evz:\xad\xd6\xa3r\x96\x9a\x82\x17\x84\tr\xf2a\xadv\x85u?^n\xbct\x84\x10\x11\xd9\xc9>n\xa1\f\x06\xaauu"}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "action_dispatch.cookies_serializer"=>:json, "action_dispatch.cookies_digest"=>nil, "rack.session"=>{}, "rack.session.options"=>{:key=>"rack.session", :path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :sidbits=>128, :cookie_only=>true, :secure_random=>securerandom, :id=>"8a8b5f8906289bb00109022394af0832"}, "action_dispatch.request.path_parameters"=>{:controller=>"account/articles", :action=>"new"}}, @filtered_parameters=nil, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil, @uuid=nil>, @response=#<actioncontroller::testresponse:0x007fe85c2cf0a0 @mon_owner=nil, @mon_count=0, @mon_mutex=#<mutex:0x007fe85c2cef38>, @stream=#<actiondispatch::response::buffer:0x007fe85c2cedd0 @response=#<actioncontroller::testresponse:0x007fe85c2cf0a0 ...>, @buf=[], @closed=false>, @header={"x-frame-options"=>"sameorigin", "x-xss-protection"=>"1; mode=block", "x-content-type-options"=>"nosniff"}, @status=200, @sending_file=false, @blank=false, @cv=#<monitormixin::conditionvariable:0x007fe85c2ced58 @monitor=#<actioncontroller::testresponse:0x007fe85c2cf0a0 ...>, @cond=#<thread::conditionvariable:0x007fe85c2ced30>>, @committed=false, @sending=false, @sent=false, @content_type=nil, @charset=nil, @cache_control={}, @etag=nil>, @params={}, @_assigns={"request"=>#<actioncontroller::testrequest:0x007fe85c35e048 @env={"rack.version"=>[1, 3], "rack.input"=>#<stringio:0x007fe85f87eca0>, "rack.errors"=>#<stringio:0x007fe85f87ed40>, "rack.multithread"=>true, "rack.multiprocess"=>true, "rack.run_once"=>false, "request_method"=>"get", "server_name"=>"example.org", "server_port"=>"80", "query_string"=>"", "rack.url_scheme"=>"http", "https"=>"off", "script_name"=>"", "content_length"=>"0", "http_host"=>"test.host", "remote_addr"=>"0.0.0.0", "http_user_agent"=>"rails testing", "action_dispatch.routes"=>#<actiondispatch::routing::routeset:0x007fe85c6713e8>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", "action_dispatch.show_exceptions"=>false, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<activesupport::logger:0x007fe85d32d528 @progname=nil, @level=0, @default_formatter=#<logger::formatter:0x007fe85d32d4b0 @datetime_format=nil>, @formatter=#<activesupport::logger::simpleformatter:0x007fe85d2fc928 @datetime_format=nil>, @logdev=#<logger::logdevice:0x007fe85d32d460 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<file:/users/et/documents/projects/test-blog/log/test.log>, @mutex=#<logger::logdevice::logdevicemutex:0x007fe85d32d438 @mon_owner=nil, @mon_count=0, @mon_mutex=#<mutex:0x007fe85d32d3e8>>>>, "action_dispatch.backtrace_cleaner"=>#<rails::backtracecleaner:0x007fe85c2f4aa8 @filters=[#<proc:0x007fe85c2f4878@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:14>, #<proc:0x007fe85c2f4850@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:15>, #<proc:0x007fe85c2f47d8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:16>, #<proc:0x007fe85c2f5750@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:29>], @silencers=[#<proc:0x007fe85c2f59a8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:19>], @root="/users/et/documents/projects/test-blog/">, "action_dispatch.key_generator"=>#<activesupport::cachingkeygenerator:0x007fe85f4cc580 @key_generator=#<activesupport::keygenerator:0x007fe85f4cc5a8 @secret="eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", @iterations=1000>, @cache_keys=#<threadsafe::cache:0x007fe85f4cc558 @backend={"signed_global_ids64"=>"0\xf4/#*5\xf2\x0f\xb2\x101\v~\xc5\x89\xff\xdb\x11\xcb(u\xfa\xf87\x13evz:\xad\xd6\xa3r\x96\x9a\x82\x17\x84\tr\xf2a\xadv\x85u?^n\xbct\x84\x10\x11\xd9\xc9>n\xa1\f\x06\xaauu"}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "action_dispatch.cookies_serializer"=>:json, "action_dispatch.cookies_digest"=>nil, "rack.session"=>{}, "rack.session.options"=>{:key=>"rack.session", :path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :sidbits=>128, :cookie_only=>true, :secure_random=>securerandom, :id=>"8a8b5f8906289bb00109022394af0832"}, "action_dispatch.request.path_parameters"=>{:controller=>"account/articles", :action=>"new"}}, @filtered_parameters=nil, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil, @uuid=nil>, "response"=>#<actioncontroller::testresponse:0x007fe85c2cf0a0 @mon_owner=nil, @mon_count=0, @mon_mutex=#<mutex:0x007fe85c2cef38>, @stream=#<actiondispatch::response::buffer:0x007fe85c2cedd0 @response=#<actioncontroller::testresponse:0x007fe85c2cf0a0 ...>, @buf=[], @closed=false>, @header={"x-frame-options"=>"sameorigin", "x-xss-protection"=>"1; mode=block", "x-content-type-options"=>"nosniff"}, @status=200, @sending_file=false, @blank=false, @cv=#<monitormixin::conditionvariable:0x007fe85c2ced58 @monitor=#<actioncontroller::testresponse:0x007fe85c2cf0a0 ...>, @cond=#<thread::conditionvariable:0x007fe85c2ced30>>, @committed=false, @sending=false, @sent=false, @content_type=nil, @charset=nil, @cache_control={}, @etag=nil>, "params"=>{}}, @_controller=#<actionview::testcase::testcontroller:0x007fe85c35e200 @_action_has_layout=true, @_routes=nil, @_headers={"content-type"=>"text/html"}, @_status=200, @_request=nil, @_response=nil, @request=#<actioncontroller::testrequest:0x007fe85c35e048 @env={"rack.version"=>[1, 3], "rack.input"=>#<stringio:0x007fe85f87eca0>, "rack.errors"=>#<stringio:0x007fe85f87ed40>, "rack.multithread"=>true, "rack.multiprocess"=>true, "rack.run_once"=>false, "request_method"=>"get", "server_name"=>"example.org", "server_port"=>"80", "query_string"=>"", "rack.url_scheme"=>"http", "https"=>"off", "script_name"=>"", "content_length"=>"0", "http_host"=>"test.host", "remote_addr"=>"0.0.0.0", "http_user_agent"=>"rails testing", "action_dispatch.routes"=>#<actiondispatch::routing::routeset:0x007fe85c6713e8>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", "action_dispatch.show_exceptions"=>false, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<activesupport::logger:0x007fe85d32d528 @progname=nil, @level=0, @default_formatter=#<logger::formatter:0x007fe85d32d4b0 @datetime_format=nil>, @formatter=#<activesupport::logger::simpleformatter:0x007fe85d2fc928 @datetime_format=nil>, @logdev=#<logger::logdevice:0x007fe85d32d460 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<file:/users/et/documents/projects/test-blog/log/test.log>, @mutex=#<logger::logdevice::logdevicemutex:0x007fe85d32d438 @mon_owner=nil, @mon_count=0, @mon_mutex=#<mutex:0x007fe85d32d3e8>>>>, "action_dispatch.backtrace_cleaner"=>#<rails::backtracecleaner:0x007fe85c2f4aa8 @filters=[#<proc:0x007fe85c2f4878@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:14>, #<proc:0x007fe85c2f4850@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:15>, #<proc:0x007fe85c2f47d8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:16>, #<proc:0x007fe85c2f5750@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:29>], @silencers=[#<proc:0x007fe85c2f59a8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:19>], @root="/users/et/documents/projects/test-blog/">, "action_dispatch.key_generator"=>#<activesupport::cachingkeygenerator:0x007fe85f4cc580 @key_generator=#<activesupport::keygenerator:0x007fe85f4cc5a8 @secret="eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", @iterations=1000>, @cache_keys=#<threadsafe::cache:0x007fe85f4cc558 @backend={"signed_global_ids64"=>"0\xf4/#*5\xf2\x0f\xb2\x101\v~\xc5\x89\xff\xdb\x11\xcb(u\xfa\xf87\x13evz:\xad\xd6\xa3r\x96\x9a\x82\x17\x84\tr\xf2a\xadv\x85u?^n\xbct\x84\x10\x11\xd9\xc9>n\xa1\f\x06\xaauu"}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "action_dispatch.cookies_serializer"=>:json, "action_dispatch.cookies_digest"=>nil, "rack.session"=>{}, "rack.session.options"=>{:key=>"rack.session", :path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :sidbits=>128, :cookie_only=>true, :secure_random=>securerandom, :id=>"8a8b5f8906289bb00109022394af0832"}, "action_dispatch.request.path_parameters"=>{:controller=>"account/articles", :action=>"new"}}, @filtered_parameters=nil, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil, @uuid=nil>, @response=#<actioncontroller::testresponse:0x007fe85c2cf0a0 @mon_owner=nil, @mon_count=0, @mon_mutex=#<mutex:0x007fe85c2cef38>, @stream=#<actiondispatch::response::buffer:0x007fe85c2cedd0 @response=#<actioncontroller::testresponse:0x007fe85c2cf0a0 ...>, @buf=[], @closed=false>, @header={"x-frame-options"=>"sameorigin", "x-xss-protection"=>"1; mode=block", "x-content-type-options"=>"nosniff"}, @status=200, @sending_file=false, @blank=false, @cv=#<monitormixin::conditionvariable:0x007fe85c2ced58 @monitor=#<actioncontroller::testresponse:0x007fe85c2cf0a0 ...>, @cond=#<thread::conditionvariable:0x007fe85c2ced30>>, @committed=false, @sending=false, @sent=false, @content_type=nil, @charset=nil, @cache_control={}, @etag=nil>, @params={}, @_view_context_class=#<class:0x007fe85c2c7620>, @_lookup_context=#<actionview::lookupcontext:0x007fe85d1615a0 @details_key=nil, @details={:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder, :haml]}, @skip_default_locale=false, @cache=true, @prefixes=["", "account/articles"], @rendered_format=nil, @view_paths=#<actionview::pathset:0x007fe85d1614d8 @paths=[#<actionview::optimizedfilesystemresolver:0x007fe85d37fb48 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<actionview::resolver::cache:0x007fe85d37fb20 @data=#<actionview::resolver::cache::smallcache:0x007fe85d37faf8 @backend={}, @default_proc=#<proc:0x007fe85f071198@/users/et/.rvm/gems/ruby-2.2.2/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/users/et/documents/projects/test-blog/app/views">, #<actionview::optimizedfilesystemresolver:0x007fe85d37feb8 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<actionview::resolver::cache:0x007fe85d37fe90 @data=#<actionview::resolver::cache::smallcache:0x007fe85d37fe68 @backend={}, @default_proc=#<proc:0x007fe85f071198@/users/et/.rvm/gems/ruby-2.2.2/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/users/et/.rvm/gems/ruby-2.2.2/gems/devise-3.5.3/app/views">]>>, @_view_renderer=#<actionview::renderer:0x007fe85d1613c0 @lookup_context=#<actionview::lookupcontext:0x007fe85d1615a0 @details_key=nil, @details={:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder, :haml]}, @skip_default_locale=false, @cache=true, @prefixes=["", "account/articles"], @rendered_format=nil, @view_paths=#<actionview::pathset:0x007fe85d1614d8 @paths=[#<actionview::optimizedfilesystemresolver:0x007fe85d37fb48 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<actionview::resolver::cache:0x007fe85d37fb20 @data=#<actionview::resolver::cache::smallcache:0x007fe85d37faf8 @backend={}, @default_proc=#<proc:0x007fe85f071198@/users/et/.rvm/gems/ruby-2.2.2/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/users/et/documents/projects/test-blog/app/views">, #<actionview::optimizedfilesystemresolver:0x007fe85d37feb8 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<actionview::resolver::cache:0x007fe85d37fe90 @data=#<actionview::resolver::cache::smallcache:0x007fe85d37fe68 @backend={}, @default_proc=#<proc:0x007fe85f071198@/users/et/.rvm/gems/ruby-2.2.2/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/users/et/.rvm/gems/ruby-2.2.2/gems/devise-3.5.3/app/views">]>>>, @_config={}>, @_request=#<actioncontroller::testrequest:0x007fe85c35e048 @env={"rack.version"=>[1, 3], "rack.input"=>#<stringio:0x007fe85f87eca0>, "rack.errors"=>#<stringio:0x007fe85f87ed40>, "rack.multithread"=>true, "rack.multiprocess"=>true, "rack.run_once"=>false, "request_method"=>"get", "server_name"=>"example.org", "server_port"=>"80", "query_string"=>"", "rack.url_scheme"=>"http", "https"=>"off", "script_name"=>"", "content_length"=>"0", "http_host"=>"test.host", "remote_addr"=>"0.0.0.0", "http_user_agent"=>"rails testing", "action_dispatch.routes"=>#<actiondispatch::routing::routeset:0x007fe85c6713e8>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", "action_dispatch.show_exceptions"=>false, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<activesupport::logger:0x007fe85d32d528 @progname=nil, @level=0, @default_formatter=#<logger::formatter:0x007fe85d32d4b0 @datetime_format=nil>, @formatter=#<activesupport::logger::simpleformatter:0x007fe85d2fc928 @datetime_format=nil>, @logdev=#<logger::logdevice:0x007fe85d32d460 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<file:/users/et/documents/projects/test-blog/log/test.log>, @mutex=#<logger::logdevice::logdevicemutex:0x007fe85d32d438 @mon_owner=nil, @mon_count=0, @mon_mutex=#<mutex:0x007fe85d32d3e8>>>>, "action_dispatch.backtrace_cleaner"=>#<rails::backtracecleaner:0x007fe85c2f4aa8 @filters=[#<proc:0x007fe85c2f4878@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:14>, #<proc:0x007fe85c2f4850@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:15>, #<proc:0x007fe85c2f47d8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:16>, #<proc:0x007fe85c2f5750@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:29>], @silencers=[#<proc:0x007fe85c2f59a8@/users/et/.rvm/gems/ruby-2.2.2/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:19>], @root="/users/et/documents/projects/test-blog/">, "action_dispatch.key_generator"=>#<activesupport::cachingkeygenerator:0x007fe85f4cc580 @key_generator=#<activesupport::keygenerator:0x007fe85f4cc5a8 @secret="eb526d7f4b0c06b367225a0d32ba8b3c3287ea6d6de798961e6fe33b975d44c2cd3ae9f314f0b96c73029f052d4670bc5a4db850ffc6a73586043089f57bdb3b", @iterations=1000>, @cache_keys=#<threadsafe::cache:0x007fe85f4cc558 @backend={"signed_global_ids64"=>"0\xf4/#*5\xf2\x0f\xb2\x101\v~\xc5\x89\xff\xdb\x11\xcb(u\xfa\xf87\x13evz:\xad\xd6\xa3r\x96\x9a\x82\x17\x84\tr\xf2a\xadv\x85u?^n\xbct\x84\x10\x11\xd9\xc9>n\xa1\f\x06\xaauu"}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "action_dispatch.cookies_serializer"=>:json, "action_dispatch.cookies_digest"=>nil, "rack.session"=>{}, "rack.session.options"=>{:key=>"rack.session", :path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :sidbits=>128, :cookie_only=>true, :secure_random=>securerandom, :id=>"8a8b5f8906289bb00109022394af0832"}, "action_dispatch.request.path_parameters"=>{:controller=>"account/articles", :action=>"new"}}, @filtered_parameters=nil, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil, @uuid=nil>, @view_flow=#<actionview::outputflow:0x007fe85a962d88 @content={}>, @output_buffer="", @virtual_path=nil, @rendered_views=#<actionview::testcase::behavior::renderedviewscollection:0x007fe85a962b30 @rendered_views={}>> not implement: article # ./spec/views/account/articles/new.html.haml_spec.rb:6:in `block (2 levels) in <top (required)>' finished in 1.11 seconds (files took 6.26 seconds load) 1 example, 1 failure failed examples: rspec ./spec/views/account/articles/new.html.haml_spec.rb:9 # account/articles/new renders new article form
require 'rails_helper' rspec.describe 'account/articles/new', type: :view 'renders new article form' stub_article { article.new } render expect(rendered).to match(%r{form.+id="new_article".+action=\"#{account_articles_path}".+accept-charset=\"utf-8\".+method=\"post\"}) end def stub_article(&block) controller.singleton_class.class_exec(block) helper_method :article define_method :article block.call end end end end
Comments
Post a Comment