Re: [rspec-users] Setting use_transactional_fixtures=false for a single spec - a bad idea?
> I'd set up a separate folder for these specs and tweak the rake tasks > to run those specs in a separate process, w/ its own spec_helper that > sets config.use_transactional_fixtures to false. Thanks for the quick reply David! Sounds like your solution would be fairly easy to set up. For now though I'm running all my specs with use_transactional_fixtures=false. Slowed my specs down from about 6 to 12 seconds. Cheers peter ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Deprecating the mocking framework?
I saw in one of Dave C.'s comments to a ticket that "our current plan is to deprecate the mocking framework." I hadn't heard anything about that, but then again I haven't paid super close attention to the list. Are we planning on dumping the mock framework in favor of using Mocha (or any other framework one might want to plug in?). Pat ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] How to spec routes for a resource nested in multiples resources?
Hi, I got the resource "Llamadas" nested in: - Operadores - Productos - Centros Here is part of my routes http://pastie.caboo.se/92767 I want to spec that the routes for Llamadas, I tried several approachs: - route_for(:controller => "llamadas", :action => "exitosas", :operador_id => 1).should == "/operador/1/llamadas;exitosas" - controller.send(:operador_exitosas_llamadas_path,@operador).should == "/operador/22/llamadas;exitosas" but nothing works. any clue? thanks in advance -- Edgar González González E-mail: [EMAIL PROTECTED] http://www.hasmanydevelopers.com http://www.rubycorner.com http://www.to2blogs.com http://www.lacaraoscura.com -- ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Setting use_transactional_fixtures=false for a single spec - a bad idea?
On 8/31/07, Peter Marklund <[EMAIL PROTECTED]> wrote: > Hi! > I would really like to find a way to allow me to write RSpec > specifications for code that use database transactions. I know I can set > > config.use_transactional_fixtures = false > > in my spec_helper.rb. That works, and that's great, but it will (I > think) slow down my specs quite a bit. I would like to turn off > transactional fixtures for just a single spec (describe), or even > better, just a single example (it). I tried this: > >before(:all) do > Spec::Runner.configure do |config| >config.use_transactional_fixtures = false > end >end > >after(:all) do > Spec::Runner.configure do |config| >config.use_transactional_fixtures = true > end >end > > but that didn't work. > > Or is setting use_transactional_fixtures=false on a global level > really the way to go even if it slows you down? It certainly feels a > lot cleaner and solid to me. Maybe I need more db stubbing. > > Thanks in advance for any pointers! I'd set up a separate folder for these specs and tweak the rake tasks to run those specs in a separate process, w/ its own spec_helper that sets config.use_transactional_fixtures to false. > > Cheers > > Peter > http://marklunds.com > > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Setting use_transactional_fixtures=false for a single spec - a bad idea?
On 8/31/07, Peter Marklund <[EMAIL PROTECTED]> wrote: > Hi! > I would really like to find a way to allow me to write RSpec > specifications for code that use database transactions. I know I can set > > config.use_transactional_fixtures = false > > in my spec_helper.rb. That works, and that's great, but it will (I > think) slow down my specs quite a bit. I would like to turn off > transactional fixtures for just a single spec (describe), or even > better, just a single example (it). I tried this: > >before(:all) do > Spec::Runner.configure do |config| >config.use_transactional_fixtures = false > end >end > >after(:all) do > Spec::Runner.configure do |config| >config.use_transactional_fixtures = true > end >end > > but that didn't work. > > Or is setting use_transactional_fixtures=false on a global level > really the way to go even if it slows you down? It certainly feels a > lot cleaner and solid to me. Maybe I need more db stubbing. > > Thanks in advance for any pointers! I'd set up a separate folder for these specs and tweak the rake tasks to run those specs in a separate process, w/ its own spec_helper that sets config.use_transactional_fixtures to false. > > Cheers > > Peter > http://marklunds.com > > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Setting use_transactional_fixtures=false for a single spec - a bad idea?
Hi! I would really like to find a way to allow me to write RSpec specifications for code that use database transactions. I know I can set config.use_transactional_fixtures = false in my spec_helper.rb. That works, and that's great, but it will (I think) slow down my specs quite a bit. I would like to turn off transactional fixtures for just a single spec (describe), or even better, just a single example (it). I tried this: before(:all) do Spec::Runner.configure do |config| config.use_transactional_fixtures = false end end after(:all) do Spec::Runner.configure do |config| config.use_transactional_fixtures = true end end but that didn't work. Or is setting use_transactional_fixtures=false on a global level really the way to go even if it slows you down? It certainly feels a lot cleaner and solid to me. Maybe I need more db stubbing. Thanks in advance for any pointers! Cheers Peter http://marklunds.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Testing for confidence - is this a spec at all?
On 8/31/07, Tom Locke <[EMAIL PROTECTED]> wrote: > Hi BDDers > > Quick background: I'm working on the Hobo plugin for Rails which, > amongst many things, automates a great deal of controller code for you. > > Hobo has a built in security mechanism, and the generic controller > uses this to ensure that POSTs and PUTs only change the DB in ways > you've permitted. > > I'm writing some rspec examples that test for holes in this security > mechanism. My feeling is that this really is testing rather than > specifying. I don't want to use mocks/stubs because I want to be > absolutely sure that changes have not happened to the DB. > > For example, with stubs, I might say "Post.save should not be > called", but there are other paths through AR that can result in that > post being inserted into the DB. So I really want to say > >Post.find_by_title("test post").should == nil > > (where Post is the real thing, not a mock/stub) > > And my questions are. > > This is clearly not a spec as such, or a unit test. What is it? A > functional test? An integration test? > > Where then does it belong? > > Should I be using rspec at all? (I want to because I spec other parts > of Hobo and the whole rspec environment is step up and ready to go) > > (Note that I don't have any problems here as such - I'm writing these > tests in rspec style and it's all working fine. I'm just fearful of > what the BDDPD might say if they catch me! Well really I'm just > curious as to what "good form" would be) The subject of this thread says it all: 'testing for confidence'. That's what all of this is about. It's all about YOU, the developer, feeling confidence to take the next step. Driving with examples, if done with discipline, means you automatically get 100% code coverage. That gives you a lot of confidence to make a change, because you're sure to get feedback if you screw it up. Since these have a different feel in your mind, I'd certainly consider moving them to their own directory. You might consider the new Story Runner (trunk only, so far), that is designed to be more customer facing and in direct support of requirements, running things end to end (no mocks). The Story Runner comes from RBehave - so you can see what it looks like here: http://dannorth.net/2007/06/introducing-rbehave. If you were doing a BDD project (kind of like an XP project), you'd have User Stories that say specific things about security, and you'd represent them in Story Runner. Then you'd deal with the individual objects using the Example Runner (i.e. describe it). In that world, you'd use mocks to isolate things. Although, even that tends to be abused. The most visible model is Rails, which couples everything together so much that you have to use mock models to avoid hitting the DB from your view specs. But in non-rails projects, it's quite common for mocks to appear and disappear in process - using them as discovery tools, but then using the real objects as they appear. You can read more about that at http://mockobjects.com. Hope this all helps. Cheers, David co-Captain BDDPD > > Thanks muchly > > -Tom > > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Testing for confidence - is this a spec at all?
Hi BDDers Quick background: I'm working on the Hobo plugin for Rails which, amongst many things, automates a great deal of controller code for you. Hobo has a built in security mechanism, and the generic controller uses this to ensure that POSTs and PUTs only change the DB in ways you've permitted. I'm writing some rspec examples that test for holes in this security mechanism. My feeling is that this really is testing rather than specifying. I don't want to use mocks/stubs because I want to be absolutely sure that changes have not happened to the DB. For example, with stubs, I might say "Post.save should not be called", but there are other paths through AR that can result in that post being inserted into the DB. So I really want to say Post.find_by_title("test post").should == nil (where Post is the real thing, not a mock/stub) And my questions are. This is clearly not a spec as such, or a unit test. What is it? A functional test? An integration test? Where then does it belong? Should I be using rspec at all? (I want to because I spec other parts of Hobo and the whole rspec environment is step up and ready to go) (Note that I don't have any problems here as such - I'm writing these tests in rspec style and it's all working fine. I'm just fearful of what the BDDPD might say if they catch me! Well really I'm just curious as to what "good form" would be) Thanks muchly -Tom ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Can module spec "behave like" controller spec?
On 8/31/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > On 8/31/07, Shaker <[EMAIL PROTECTED]> wrote: > > > > Hello everyone: > > Right now I am writing spec on modules, which are provided by my > > colleagues. Some of the modules actually contain action methods. I tried > > very hard to spec those action methods in modules. But it seems that the > > rspec does not allow module spec to 'get' action like controller does. After > > I saw the documentation, I then used :behaviour_type=>:controller. However, > > it failed again. It reported an error for me. For illustration, I'd like a > > simple example. > > module MyModule > > def copy #an action method > > render :partial=>"/index", :layout=>false > > end > > end > > > > describe MyModule, :behaviour_type=>:controller do > > it "should render partial index" do > > get 'copy' #test code not provided yet, just want to get the action > > end > > end > > The error reported was: undefined method 'new' for MyModule:Module. Do you > > guys have any idea of the error? And how should I test the action methods in > > modules? > > The ControllerBehaviour is trying to instantiate MyModule. What you'd > need to do is something like this: > > class ControllerThatUsesMyModule > include MyModule > end > > describe ControllerThatUsesMyModule, :behaviour_type=>:controller do >it "should render partial index" do >get 'copy' #test code not provided yet, just want to get the action >end > end > > I haven't tried it, but it seems like it should work. Give it a whirl > and report back please. Of course, the subject of this thread should smack us all in the face and point in a different direction: describe "any controller", :shared => true do it "should render partial index" do get 'copy' #test code not provided yet, just want to get the action end end # an actual controller - not just for specs class FooController include AnyController end # in spec/controllers/foo_controller_spec.rb describe FooController do it_should_behave_like "any controller" ... #more stuff specific to FooController end > > Cheers, > David > > > Cheers! > > > > > > -- > > View this message in context: > > http://www.nabble.com/Can-module-spec-%22behave-like%22-controller-spec--tf4358891.html#a12422548 > > Sent from the rspec-users mailing list archive at Nabble.com. > > > > ___ > > rspec-users mailing list > > rspec-users@rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Can module spec "behave like" controller spec?
On 8/31/07, Shaker <[EMAIL PROTECTED]> wrote: > > Hello everyone: > Right now I am writing spec on modules, which are provided by my > colleagues. Some of the modules actually contain action methods. I tried > very hard to spec those action methods in modules. But it seems that the > rspec does not allow module spec to 'get' action like controller does. After > I saw the documentation, I then used :behaviour_type=>:controller. However, > it failed again. It reported an error for me. For illustration, I'd like a > simple example. > module MyModule > def copy #an action method > render :partial=>"/index", :layout=>false > end > end > > describe MyModule, :behaviour_type=>:controller do > it "should render partial index" do > get 'copy' #test code not provided yet, just want to get the action > end > end > The error reported was: undefined method 'new' for MyModule:Module. Do you > guys have any idea of the error? And how should I test the action methods in > modules? The ControllerBehaviour is trying to instantiate MyModule. What you'd need to do is something like this: class ControllerThatUsesMyModule include MyModule end describe ControllerThatUsesMyModule, :behaviour_type=>:controller do it "should render partial index" do get 'copy' #test code not provided yet, just want to get the action end end I haven't tried it, but it seems like it should work. Give it a whirl and report back please. Cheers, David > Cheers! > > > -- > View this message in context: > http://www.nabble.com/Can-module-spec-%22behave-like%22-controller-spec--tf4358891.html#a12422548 > Sent from the rspec-users mailing list archive at Nabble.com. > > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Can module spec "behave like" controller spec?
Hello everyone: Right now I am writing spec on modules, which are provided by my colleagues. Some of the modules actually contain action methods. I tried very hard to spec those action methods in modules. But it seems that the rspec does not allow module spec to 'get' action like controller does. After I saw the documentation, I then used :behaviour_type=>:controller. However, it failed again. It reported an error for me. For illustration, I'd like a simple example. module MyModule def copy #an action method render :partial=>"/index", :layout=>false end end describe MyModule, :behaviour_type=>:controller do it "should render partial index" do get 'copy' #test code not provided yet, just want to get the action end end The error reported was: undefined method 'new' for MyModule:Module. Do you guys have any idea of the error? And how should I test the action methods in modules? Cheers! -- View this message in context: http://www.nabble.com/Can-module-spec-%22behave-like%22-controller-spec--tf4358891.html#a12422548 Sent from the rspec-users mailing list archive at Nabble.com. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users