Comments (4)
That's odd. We have similar tests in our own code base without trouble. Can you share the stack trace?
from focused_controller.
The issue comes from the association with RSpec helper render_views
(i'm using RABL to render JSON). Here's the backtrace on a dummy app with a Post model and a create method, just calling subject.call
PostsController PostsController::Create should render JSON
Failure/Error: controller.call
RuntimeError:
ActionController::RackDelegation#status= delegated to @_response.status=, but @_response is nil: #<PostsController::Create:0x00000100ae10e0 @_routes=nil, @_action_has_layout=true, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_request=#<ActionController::TestRequest:0x00000100acac00 @env={"rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x00000105e14000>, "rack.errors"=>#<StringIO:0x00000105e140a0>, "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", "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x00000105dcf8b0>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.secret_token"=>"e5048ed1d5ee25b988533437f6a1981a146b33f63165a9241953ad72585bae990875b8b9f689e91bd2370fdccc4b57f3727c6802a162ffbfee341566097cbf9a", "action_dispatch.show_exceptions"=>false, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<ActiveSupport::TaggedLogging:0x00000105f0f9f0 @logger=#<ActiveSupport::BufferedLogger:0x00000105f0fb80 @log_dest=#<File:/Users/Coki/code/test_app/log/test.log>, @log=#<Logger:0x00000105f0fb58 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x00000105f0fb08 @datetime_format=nil>, @formatter=#<Logger::SimpleFormatter:0x00000105f0fa18 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x00000105f0fab8 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/Users/Coki/code/test_app/log/test.log>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x00000105f0fa90 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x00000105f0fa40>>>>>, @tags={#<Thread:0x00000100887290 run>=>[]}>, "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x00000100ae2828 @filters=[#<Proc:0x00000100ae2760@/Users/Coki/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/backtrace_cleaner.rb:10>, #<Proc:0x00000100ae26c0@/Users/Coki/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/backtrace_cleaner.rb:11>, #<Proc:0x00000100ae2698@/Users/Coki/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/backtrace_cleaner.rb:12>, #<Proc:0x00000100ae1950@/Users/Coki/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/backtrace_cleaner.rb:26>], @silencers=[#<Proc:0x00000100ae18b0@/Users/Coki/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/backtrace_cleaner.rb:15>]>, "HTTP_HOST"=>"test.host", "REMOTE_ADDR"=>"0.0.0.0", "HTTP_USER_AGENT"=>"Rails Testing", "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=>"137ec1137dc4962221d22288dd578cb5"}}>, @_response=nil, @_params={:post=>{:title=>"Foo"}, :format=>:json}, @post=#<Post id: nil, title: nil, body: nil>, @_prefixes=["posts", "posts", "application", "application"]>
# ./app/controllers/posts_controller.rb:10:in `call'
# ./spec/posts_controller_spec.rb:9:in `block (3 levels) in <top (required)>'
Don't know if it is the "normal" behavior not to render views inside a unit controller test. Tell me if you want me to put the dummy app online, i'll will try to look at RSpec render_views
to find a way to fix this.
from focused_controller.
@ccocchi are you writing a unit test or a functional test? if the former, you cannot render views, which would take the test outside the realm of unit testing.
from focused_controller.
Yes that's what I've been saying myself after re-reading what I wrote.
Thank you for your help !
from focused_controller.
Related Issues (20)
- Consider removing custom assertions HOT 3
- Consider removing `#req`
- Named routes HOT 7
- Routing rspec matcher doesn't works HOT 1
- Controller params not fill HOT 3
- Readme improvement HOT 1
- undefined method `expose' HOT 1
- Consider action/fragment caching HOT 1
- Weird path bug that displays wrong error HOT 3
- Rabl support? HOT 1
- DSL syntax HOT 9
- RSpec and included member routes in a resource HOT 2
- Session values accessible, Cookies private? HOT 2
- assert_template only works when explicitly calling render
- Tests don't run HOT 4
- Rails 4? HOT 4
- Rails 4.1 support?
- Instance variables not available in template HOT 2
- Rails 4.2 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from focused_controller.