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.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Anthony Smith 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. :)> > 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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
So use rspec for models and cucumber for controllers and views? On Dec 10, 2010, at 3:48 PM, Marnen Laibow-Koser wrote:> Anthony Smith 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. :) > >> >> 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 > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.