Help specing simple controller

I’m new to TDD/BDD and rspec. I have a simple example controller I was
hoping someone could help me out with.

class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user_session

private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
end

Any help is appreciated.

Anthony S. wrote in post #967733:

I’m new to TDD/BDD and rspec. I have a simple example controller I was
hoping someone could help me out with.

Well, if you already have the application code, then you’re not doing
TDD yet. But you knew that. :slight_smile:

class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user_session

private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
end

Any help is appreciated.

Don’t use plain RSpec for controllers. That’s a job for Cucumber.
Old-style controller specs (i.e., without Cucumber) are painful to
write.

As far as what to write in the Cucumber story…well, that depends on
what you consider to be the core functionality of the controller.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

So use rspec for models and cucumber for controllers and views?