ngauthier / tubesock

Websocket interface on Rack Hijack w/ Rails support
MIT License
620 stars 43 forks source link

Test controller that uses Tubesock with RSpec #41

Closed dchacke closed 9 years ago

dchacke commented 9 years ago

It appears that controller specs fail because Puma is not running in RSpec controller tests:

Failure/Error: get :index Tubesock::HijackNotAvailable: Tubesock::HijackNotAvailable

How can one get around this so as to test controllers that use Tubesock?

ngauthier commented 9 years ago

Hi,

An RSpec controller test tests a controller as a unit in isolation. That means that collaborators of the controller should be faked/mocked/stubbed. So you should apply the appropriate technique to the Tubesock class (or wrap it yourself and fake/mock/stub your wrapper, which is recommended) so that the tubesock code is not exercised during the controller test.

Please share your results as I expect others are interested in this as well.

Nick