Wincent Colaiuta
2007-May-24 06:56 UTC
[rspec-users] Specs for code stored in rails_app/lib/
Where should the specs go for code in the "lib" directory of a Rails app? I made a folder, "spec/lib/", for storing such specs, and RSpec automatically picks them up when run using "rake spec". Before I go ahead and patch rspec_on_rails/lib/autotest/ rails_rspec.rb so that autotest can monitor these specs I''d like to ask whether this is the "standard" location for such specs or not. Cheers, Wincent
David Chelimsky
2007-May-24 08:35 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, Wincent Colaiuta <win at wincent.com> wrote:> Where should the specs go for code in the "lib" directory of a Rails > app? > > I made a folder, "spec/lib/", for storing such specs, and RSpec > automatically picks them up when run using "rake spec". > > Before I go ahead and patch rspec_on_rails/lib/autotest/ > rails_rspec.rb so that autotest can monitor these specs I''d like to > ask whether this is the "standard" location for such specs or not.Seems reasonable. Can you get me that patch this AM? I want to do a 1.0.3 release today to fix a couple of bugs. FYI - how did you even find that file? We released it, but autotest is not using it yet. It will be after the next ZenTest release, but not yet.> > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-May-24 09:35 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 5/24/07, Wincent Colaiuta <win at wincent.com> wrote: > > Where should the specs go for code in the "lib" directory of a Rails > > app? > > > > I made a folder, "spec/lib/", for storing such specs, and RSpec > > automatically picks them up when run using "rake spec". > > > > Before I go ahead and patch rspec_on_rails/lib/autotest/ > > rails_rspec.rb so that autotest can monitor these specs I''d like to > > ask whether this is the "standard" location for such specs or not. > > Seems reasonable. Can you get me that patch this AM? I want to do a > 1.0.3 release today to fix a couple of bugs.Actually - I''ve got this covered - no patch necessary.> > FYI - how did you even find that file? We released it, but autotest is > not using it yet. It will be after the next ZenTest release, but not > yet. > > > > > Cheers, > > Wincent > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > >
Wincent Colaiuta
2007-May-24 09:48 UTC
[rspec-users] Specs for code stored in rails_app/lib/
El 24/5/2007, a las 10:35, David Chelimsky escribi?:> On 5/24/07, Wincent Colaiuta <win at wincent.com> wrote: >> Where should the specs go for code in the "lib" directory of a Rails >> app? >> >> I made a folder, "spec/lib/", for storing such specs, and RSpec >> automatically picks them up when run using "rake spec". >> >> Before I go ahead and patch rspec_on_rails/lib/autotest/ >> rails_rspec.rb so that autotest can monitor these specs I''d like to >> ask whether this is the "standard" location for such specs or not. > > Seems reasonable. Can you get me that patch this AM? I want to do a > 1.0.3 release today to fix a couple of bugs.Will paste one possible diff below; based on the convention that for file: lib/my_module.rb There will be a corresponding spec at: spec/lib/my_module_spec.rb This may be too simplistic given the possibility of nesting subfolders in lib, but as a first cut it might be ok.> FYI - how did you even find that file? We released it, but autotest is > not using it yet. It will be after the next ZenTest release, but not > yet.Just happened to notice it; after "script/plugin install" I did an "svn st" and "svn diff" to see what was new... Cheers, Wincent Index: rails_rspec.rb ==================================================================--- rails_rspec.rb (revision 2014) +++ rails_rspec.rb (working copy) @@ -33,7 +33,7 @@ %r%^(test|spec)/fixtures/(.*).yml% => proc { |_, m| ["spec/models/#{m[2].singularize}_spec.rb"] + files_matching (%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%) }, - %r%^spec/(models|controllers|views|helpers)/.*rb$% => proc { | filename, _| + %r%^spec/(models|controllers|views|helpers|lib)/.*rb$% => proc { |filename, _| filename }, %r%^app/models/(.*)\.rb$% => proc { |_, m| @@ -61,6 +61,9 @@ %r%^app/controllers/(.*)\.rb$% => proc { |_, m| ["spec/controllers/#{m[1]}_spec.rb"] }, + %r%^lib/(.*)\.rb$% => proc { |_, m| + ["spec/lib/#{m[1]}_spec.rb"] + }, %r%^config/routes.rb$% => proc { # FIX: files_matching %r%^spec/(controllers|views|helpers)/.*_spec \.rb$% }, @@ -68,7 +71,7 @@ files_matching %r%^spec/models/.*_spec\.rb$% }, %r%^spec/spec_helper.rb|config/((boot|environment(s/ test)?).rb)% => proc { - files_matching %r%^spec/(models|controllers|views| helpers)/.*_spec\.rb$% + files_matching %r%^spec/(models|controllers|views|helpers| lib)/.*_spec\.rb$% }, } end
David Chelimsky
2007-May-24 09:53 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, Wincent Colaiuta <win at wincent.com> wrote:> El 24/5/2007, a las 10:35, David Chelimsky escribi?: > > > On 5/24/07, Wincent Colaiuta <win at wincent.com> wrote: > >> Where should the specs go for code in the "lib" directory of a Rails > >> app? > >> > >> I made a folder, "spec/lib/", for storing such specs, and RSpec > >> automatically picks them up when run using "rake spec". > >> > >> Before I go ahead and patch rspec_on_rails/lib/autotest/ > >> rails_rspec.rb so that autotest can monitor these specs I''d like to > >> ask whether this is the "standard" location for such specs or not. > > > > Seems reasonable. Can you get me that patch this AM? I want to do a > > 1.0.3 release today to fix a couple of bugs. > > Will paste one possible diff below; based on the convention that for > file: > > lib/my_module.rb > > There will be a corresponding spec at: > > spec/lib/my_module_spec.rb > > This may be too simplistic given the possibility of nesting > subfolders in lib, but as a first cut it might be ok. > > > FYI - how did you even find that file? We released it, but autotest is > > not using it yet. It will be after the next ZenTest release, but not > > yet. > > Just happened to notice it; after "script/plugin install" I did an > "svn st" and "svn diff" to see what was new... > > Cheers, > Wincent > > > Index: rails_rspec.rb > ==================================================================> --- rails_rspec.rb (revision 2014) > +++ rails_rspec.rb (working copy) > @@ -33,7 +33,7 @@ > %r%^(test|spec)/fixtures/(.*).yml% => proc { |_, m| > ["spec/models/#{m[2].singularize}_spec.rb"] + files_matching > (%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%) > }, > - %r%^spec/(models|controllers|views|helpers)/.*rb$% => proc { | > filename, _| > + %r%^spec/(models|controllers|views|helpers|lib)/.*rb$% => proc > { |filename, _| > filename > }, > %r%^app/models/(.*)\.rb$% => proc { |_, m| > @@ -61,6 +61,9 @@ > %r%^app/controllers/(.*)\.rb$% => proc { |_, m| > ["spec/controllers/#{m[1]}_spec.rb"] > }, > + %r%^lib/(.*)\.rb$% => proc { |_, m| > + ["spec/lib/#{m[1]}_spec.rb"] > + }, > %r%^config/routes.rb$% => proc { # FIX: > files_matching %r%^spec/(controllers|views|helpers)/.*_spec > \.rb$% > }, > @@ -68,7 +71,7 @@ > files_matching %r%^spec/models/.*_spec\.rb$% > }, > %r%^spec/spec_helper.rb|config/((boot|environment(s/ > test)?).rb)% => proc { > - files_matching %r%^spec/(models|controllers|views| > helpers)/.*_spec\.rb$% > + files_matching %r%^spec/(models|controllers|views|helpers| > lib)/.*_spec\.rb$% > }, > } > endI don''t think this is too simplistic - as long as the nested dirs align in lib and spec/lib, then the regexp matcher will include the ''/''es, and all will be right with the world. In truth, I already implemented exactly what you have there (in a hurry to get a release out today), but if you file the above in the tracker I''ll be more than happy to add you to the contributor page. Cheers, David> _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Wincent Colaiuta
2007-May-24 10:24 UTC
[rspec-users] Specs for code stored in rails_app/lib/
El 24/5/2007, a las 11:53, David Chelimsky escribi?:> In truth, I already implemented exactly what you have there (in a > hurry to get a release out today), but if you file the above in the > tracker I''ll be more than happy to add you to the contributor page.Nah, I''m just happy to see RSpec constantly improving. If I come up with some more significant contributions in the future then I''ll go through the proper channels... Cheers, Wincent
David Chelimsky
2007-May-24 10:45 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, Wincent Colaiuta <win at wincent.com> wrote:> El 24/5/2007, a las 11:53, David Chelimsky escribi?: > > > In truth, I already implemented exactly what you have there (in a > > hurry to get a release out today), but if you file the above in the > > tracker I''ll be more than happy to add you to the contributor page. > > Nah, I''m just happy to see RSpec constantly improving. If I come up > with some more significant contributions in the futureIF???????? Looking forward to it WHEN.... Cheers, David then I''ll go> through the proper channels... > > Cheers, > Wincent > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote:> I don''t think this is too simplistic - as long as the nested dirs > align in lib and spec/lib, then the regexp matcher will include the > ''/''es, and all will be right with the world. > > In truth, I already implemented exactly what you have there (in a > hurry to get a release out today), but if you file the above in the > tracker I''ll be more than happy to add you to the contributor page.A related question -- where do spec support files go? For example, I''ve got more than a few one-off matchers and such, and having a 500-line spec_helper.rb doesn''t seem workable. I ended up putting mine in /spec/lib, and the specs for /lib files in /libraries. Any ideas? -- Coda Hale http://blog.codahale.com
David Chelimsky
2007-May-24 21:17 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote:> On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > I don''t think this is too simplistic - as long as the nested dirs > > align in lib and spec/lib, then the regexp matcher will include the > > ''/''es, and all will be right with the world. > > > > In truth, I already implemented exactly what you have there (in a > > hurry to get a release out today), but if you file the above in the > > tracker I''ll be more than happy to add you to the contributor page. > > A related question -- where do spec support files go? For example, > I''ve got more than a few one-off matchers and such, and having a > 500-line spec_helper.rb doesn''t seem workable. > > I ended up putting mine in /spec/lib, and the specs for /lib files in > /libraries.I''d definitely have the specs for lib in spec/lib. As for your helpers, how about spec/helpers????> > Any ideas? > > -- > Coda Hale > http://blog.codahale.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote: > > A related question -- where do spec support files go? For example, > > I''ve got more than a few one-off matchers and such, and having a > > 500-line spec_helper.rb doesn''t seem workable. > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > /libraries. > > I''d definitely have the specs for lib in spec/lib. As for your > helpers, how about spec/helpers????Thanks for the quick reply! I''m not sure if I was clear -- I''m not looking for a place to put the specs for my helpers. That''s obviously /sepc/helpers. I''m looking for a place to put the support classes for the specs -- custom matchers, etc. If I stuff them all in spec_helper.rb, it''ll grow to be unmanageably large. -- Coda Hale http://blog.codahale.com
David Chelimsky
2007-May-24 21:28 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote:> On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote: > > > A related question -- where do spec support files go? For example, > > > I''ve got more than a few one-off matchers and such, and having a > > > 500-line spec_helper.rb doesn''t seem workable. > > > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > > /libraries. > > > > I''d definitely have the specs for lib in spec/lib. As for your > > helpers, how about spec/helpers???? > > Thanks for the quick reply! > > I''m not sure if I was clear -- I''m not looking for a place to put the > specs for my helpers. That''s obviously /sepc/helpers. I''m looking for > a place to put the support classes for the specs -- custom matchers, > etc. If I stuff them all in spec_helper.rb, it''ll grow to be > unmanageably large.Right - I understood the question. I spaced for a second that we already have spec/helpers - sorry. Pick any name you like other than lib, models, views, controllers, helpers, etc. But definitely in a subdirectory there. How about support, or common, or inc, or something like that?> > -- > Coda Hale > http://blog.codahale.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote:> On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote: > > > A related question -- where do spec support files go? For example, > > > I''ve got more than a few one-off matchers and such, and having a > > > 500-line spec_helper.rb doesn''t seem workable. > > > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > > /libraries. > > > > I''d definitely have the specs for lib in spec/lib. As for your > > helpers, how about spec/helpers???? > > Thanks for the quick reply! > > I''m not sure if I was clear -- I''m not looking for a place to put the > specs for my helpers. That''s obviously /sepc/helpers. I''m looking for > a place to put the support classes for the specs -- custom matchers, > etc. If I stuff them all in spec_helper.rb, it''ll grow to be > unmanageably large. >I''m using spec/lib for that, and spec/libraries for exampling code at RAILS_ROOT/lib -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi
David Chelimsky
2007-May-24 21:31 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, Luis Lavena <luislavena at gmail.com> wrote:> On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote: > > On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > > On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote: > > > > A related question -- where do spec support files go? For example, > > > > I''ve got more than a few one-off matchers and such, and having a > > > > 500-line spec_helper.rb doesn''t seem workable. > > > > > > > > I ended up putting mine in /spec/lib, and the specs for /lib files in > > > > /libraries. > > > > > > I''d definitely have the specs for lib in spec/lib. As for your > > > helpers, how about spec/helpers???? > > > > Thanks for the quick reply! > > > > I''m not sure if I was clear -- I''m not looking for a place to put the > > specs for my helpers. That''s obviously /sepc/helpers. I''m looking for > > a place to put the support classes for the specs -- custom matchers, > > etc. If I stuff them all in spec_helper.rb, it''ll grow to be > > unmanageably large. > > > > I''m using spec/lib for that, and spec/libraries for exampling code at > RAILS_ROOT/libThat''s two for two, but it won''t work if you want to use autotest.> > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote: [...]> > I''m using spec/lib for that, and spec/libraries for exampling code at > > RAILS_ROOT/lib > > That''s two for two, but it won''t work if you want to use autotest. >Er, not a fan of autotest/zentest :-P -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi
David Chelimsky
2007-May-24 21:38 UTC
[rspec-users] Specs for code stored in rails_app/lib/
On 5/24/07, Luis Lavena <luislavena at gmail.com> wrote:> On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote: > [...] > > > I''m using spec/lib for that, and spec/libraries for exampling code at > > > RAILS_ROOT/lib > > > > That''s two for two, but it won''t work if you want to use autotest. > > > > Er, not a fan of autotest/zentest :-PWhat don''t you like about autotest?> > -- > Luis Lavena > Multimedia systems > - > Leaders are made, they are not born. They are made by hard effort, > which is the price which all of us must pay to achieve any goal that > is worthwhile. > Vince Lombardi > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
nicholas a. evans
2007-May-27 21:58 UTC
[rspec-users] Specs for code stored in rails_app/lib/
I''ve been putting mine directly in the RAILS_ROOT/spec directory: e.g. spec/user_spec_helper.rb, spec/patient_spec_helper.rb. I usually put the require statements into spec/spec_helper.rb. I suppose a case could be made for that being a little bit messy. Perhaps spec/support would be my first choice. -- Nick On 5/24/07, Coda Hale <coda.hale at gmail.com> wrote:> On 5/24/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > I don''t think this is too simplistic - as long as the nested dirs > > align in lib and spec/lib, then the regexp matcher will include the > > ''/''es, and all will be right with the world. > > > > In truth, I already implemented exactly what you have there (in a > > hurry to get a release out today), but if you file the above in the > > tracker I''ll be more than happy to add you to the contributor page. > > A related question -- where do spec support files go? For example, > I''ve got more than a few one-off matchers and such, and having a > 500-line spec_helper.rb doesn''t seem workable. > > I ended up putting mine in /spec/lib, and the specs for /lib files in > /libraries. > > Any ideas?