Hi All, I have a question about the rspec_scaffold and if it''s compatible with other mocking frameworks. I just created a blank application and a scaffold of a very basic model. The specs run fine untill I choose to use mocha in the spec_helper. Can somebody please tell me if this is ment to be and if so if there''s an easy way to make the scaffold work with mocha ? Thanks in advance! Jeroen
Hi all, Sorry if this get''s posted several times but I got a message that my previous post wasn''t allowed because I''m not a member. I think I am now though. The problem I have is fairly simple. I have some plugins who use rspec and mocha and I want to make use of the rspec_scaffold generator. Unfortunately this doesn''t work, the tests fail as soon as I set mocha as my prefered mocking framework. Is this by design or should it work out of the box. If anybody knows about a generator that does work, please let me know All the best! Jeroen
On Thu, May 7, 2009 at 7:40 AM, jevado <jeroenvdoorn at gmail.com> wrote:> Hi All, > > I have a question about the rspec_scaffold and if it''s compatible with > other mocking frameworks. > I just created a blank application and a scaffold of a very basic > model. The specs run fine untill I choose to use mocha in the > spec_helper. > > Can somebody please tell me if this is ment to be and if so if there''s > an easy way to make the scaffold work with mocha ?RSpec scaffold is not set up produce scaffold for all of the various mocking libraries. It does so just for what comes with RSpec. I do not know of a way to simply replace scaffolding w/o providing more scaffolding (ones for each mocking library) and then adding a flag to the "script/generate" command to produce scaffolding for rspec+default, rspec+mocha, rspec+rr, etc. Also, in addition to this the normal "script/generate rspec" command could be used to take the same options so it would configure your spec_helper to run with the appropriate libraries. I think your idea for scaffolding with different mocking libraries is a good one. Please open a ticket on lighthouse and let''s see if we can get some more input from others in the community as well as the core team. http://rspec.lighthouseapp.com/> > Thanks in advance! > Jeroen > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) @zachdennis (twitter)
On Fri, May 8, 2009 at 9:11 PM, Zach Dennis <zach.dennis at gmail.com> wrote:> On Thu, May 7, 2009 at 7:40 AM, jevado <jeroenvdoorn at gmail.com> wrote: >> Hi All, >> >> I have a question about the rspec_scaffold and if it''s compatible with >> other mocking frameworks. >> I just created a blank application and a scaffold of a very basic >> model. The specs run fine untill I choose to use mocha in the >> spec_helper. >> >> Can somebody please tell me if this is ment to be and if so if there''s >> an easy way to make the scaffold work with mocha ? > > RSpec scaffold is not set up produce scaffold for all of the various > mocking libraries. It does so just for what comes with RSpec. I do not > know of a way to simply replace scaffolding w/o providing more > scaffolding (ones for each mocking library) and then adding a flag to > the "script/generate" command to produce scaffolding for > rspec+default, rspec+mocha, rspec+rr, etc. > > Also, in addition to this the normal "script/generate rspec" command > could be used to take the same options so it would configure your > spec_helper to run with the appropriate libraries. > > I think your idea for scaffolding with different mocking libraries is > a good one. Please open a ticket on lighthouse and let''s see if we can > get some more input from others in the community as well as the core > team. > > http://rspec.lighthouseapp.com/You can go ahead and file a feature request if you like, but given that there is a GSOC project to deal with rails generators, including support for rspec, I''m not going to be making any significant changes to the rspec generators in the short term. Cheers, David> > >> >> Thanks in advance! >> Jeroen >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com (personal) > http://www.mutuallyhuman.com (hire me) > @zachdennis (twitter) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Wow, thanks for all the replies ... The rspec scaffold generates more tests than the nifty_scaffold. I didn''t look into it in detail yet cause some of the nifty tests where failing too. What I did to get it workin is map the missing methods (used by respec) to methods in mocha. I also use the mislav-rspec-rails-mocha plugin. example: module Mocha class Expectation def and_return(*values) returns(*values) end end end On May 11, 3:17?am, Nicholas Van Weerdenburg <vanwe... at gmail.com> wrote:> On Thu, May 7, 2009 at 1:21 PM, jevado <jeroenvdo... at gmail.com> wrote: > > Hi all, > > > Sorry if this get''s posted several times but I got a message that my > > previous post wasn''t allowed because I''m not a member. I think I am > > now though. > > > The problem I have is fairly simple. I have some plugins who use rspec > > and mocha and I want to make use of the rspec_scaffold generator. > > Unfortunately this doesn''t work, the tests fail as soon as I set mocha > > as my prefered mocking framework. > > > Is this by design or should it work out of the box. > > > If anybody knows about a generator that does work, please let me know > > > All the best! > > Jeroen > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > As far as I can tell, Nifty_Generators nifty_scaffold (http://github.com/ryanb/nifty-generators/tree/master) generates rspec + > mocha scaffolding. ?I wasn''t using Mocha so I didn''t look in detail. > > e.g. here is a controller spec generated with nifty_scaffold for some work I > was doing with the authlogic plugin: > > describe UserSessionsController do > ? fixtures :all > ? integrate_views > > ? it "new action should render new template" do > ? ? get :new > ? ? response.should render_template(:new) > ? end > > ? it "create action should render new template when model is invalid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(false) > ? ? post :create > ? ? response.should render_template(:new) > ? end > > ? it "create action should redirect when model is valid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(true) > ? ? post :create > ? ? response.should redirect_to(root_url) > ? end > > ? it "destroy action should destroy model and redirect to index action" do > ? ? user_session = UserSession.first > ? ? delete :destroy, :id => user_session > ? ? response.should redirect_to(root_url) > ? ? UserSession.exists?(user_session.id).should be_false > ? end > end > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
post wasn''t finished yet ... I know that it''s not very clean but since it''s just for scaffolding and I''ll probably rewrite most of the tests later on anyway it''s acceptable for now. Thanks again and I''ll monitor the GSOC project :) Kind regards, Jeroen On May 11, 3:17?am, Nicholas Van Weerdenburg <vanwe... at gmail.com> wrote:> On Thu, May 7, 2009 at 1:21 PM, jevado <jeroenvdo... at gmail.com> wrote: > > Hi all, > > > Sorry if this get''s posted several times but I got a message that my > > previous post wasn''t allowed because I''m not a member. I think I am > > now though. > > > The problem I have is fairly simple. I have some plugins who use rspec > > and mocha and I want to make use of the rspec_scaffold generator. > > Unfortunately this doesn''t work, the tests fail as soon as I set mocha > > as my prefered mocking framework. > > > Is this by design or should it work out of the box. > > > If anybody knows about a generator that does work, please let me know > > > All the best! > > Jeroen > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > As far as I can tell, Nifty_Generators nifty_scaffold (http://github.com/ryanb/nifty-generators/tree/master) generates rspec + > mocha scaffolding. ?I wasn''t using Mocha so I didn''t look in detail. > > e.g. here is a controller spec generated with nifty_scaffold for some work I > was doing with the authlogic plugin: > > describe UserSessionsController do > ? fixtures :all > ? integrate_views > > ? it "new action should render new template" do > ? ? get :new > ? ? response.should render_template(:new) > ? end > > ? it "create action should render new template when model is invalid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(false) > ? ? post :create > ? ? response.should render_template(:new) > ? end > > ? it "create action should redirect when model is valid" do > ? ? UserSession.any_instance.stubs(:valid?).returns(true) > ? ? post :create > ? ? response.should redirect_to(root_url) > ? end > > ? it "destroy action should destroy model and redirect to index action" do > ? ? user_session = UserSession.first > ? ? delete :destroy, :id => user_session > ? ? response.should redirect_to(root_url) > ? ? UserSession.exists?(user_session.id).should be_false > ? end > end > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users