Peter Marklund
2007-Jul-26 16:24 UTC
[rspec-users] Canonical way to generate RSpec HTML report in Rails app
Hi! I was just wondering how you typically generate a spec HTML report in a Rails app. Currently I''m doing something like this: spec spec -f h:spec/spec_report.html But that seems sort of clumsy and I would have thought that there was a rake task for it. Have I overlooked something? Thanks! Peter ---------------------------- Peter Marklund Garvar Lundins Gr?nd 7 11220 Stockholm Sweden Mobile Phone: +46-(0)70-4164857 Home Phone: +46-(0)8-50091315 Skype: peter_marklund IM: AIM - petermarklund, MSN - peter_marklund at hotmail.com, Yahoo - peter_marklund2002 http://marklunds.com ----------------------------
Don Petersen
2007-Jul-26 16:37 UTC
[rspec-users] Canonical way to generate RSpec HTML report in Rails app
There might be a "better" way to do it, but I basically ripped off the builtin spec:doc Rake task almost verbatim and made a custom task in my Rails app for generating the HTML report. This isn''t anything magical, but you should be able to drop a file called "whatever_you_want.rake" in your lib/tasks with the contents provided, and it''ll give you a "spec doc:html_doc" task that will generate the report and save it to "spec/report.html". Here''s the task code: http://pastie.textmate.org/82520 Like a said, complete rip off of another builtin task. Notice that it''s executing as a dry-run, so it''s not actually executing the specs, just generating the report of what specs you have. Take that out and it will actually run them and report accordingly... Don On Jul 26, 2007, at 11:24 AM, Peter Marklund wrote:> Hi! > I was just wondering how you typically generate a spec HTML report in > a Rails app. Currently I''m doing something like this: > > spec spec -f h:spec/spec_report.html > > But that seems sort of clumsy and I would have thought that there was > a rake task for it. Have I overlooked something? > > Thanks! > > Peter > > > > ---------------------------- > Peter Marklund > Garvar Lundins Gr?nd 7 > 11220 Stockholm > Sweden > > Mobile Phone: +46-(0)70-4164857 > Home Phone: +46-(0)8-50091315 > Skype: peter_marklund > > IM: AIM - petermarklund, MSN - peter_marklund at hotmail.com, Yahoo - > peter_marklund2002 > > http://marklunds.com > ---------------------------- > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Peter Marklund
2007-Jul-26 16:54 UTC
[rspec-users] Canonical way to generate RSpec HTML report in Rails app
Hi Don! Thanks, that looks nice. For now I''m just using this bash alias: alias specdoc=''spec spec -f h:spec/spec_report.html; open spec/ spec_report.html'' However, I guess it''s nicer to have this be a Rake task so that it can be used by the whole development team. I was looking for an easy way to pass options on from rake to the spec command, but I''m sort of starting to get the feeling that sometimes it''s better to invoke the spec command directly instead of going via rake just as is the case with Capistrano and the cap command. Cheers Peter On Jul 26, 2007, at 6:37 PM, Don Petersen wrote:> There might be a "better" way to do it, but I basically ripped off > the builtin spec:doc Rake task almost verbatim and made a custom task > in my Rails app for generating the HTML report. This isn''t anything > magical, but you should be able to drop a file called > "whatever_you_want.rake" in your lib/tasks with the contents > provided, and it''ll give you a "spec doc:html_doc" task that will > generate the report and save it to "spec/report.html". > > Here''s the task code: http://pastie.textmate.org/82520 > > Like a said, complete rip off of another builtin task. Notice that > it''s executing as a dry-run, so it''s not actually executing the > specs, just generating the report of what specs you have. Take that > out and it will actually run them and report accordingly... > > Don > > On Jul 26, 2007, at 11:24 AM, Peter Marklund wrote: > >> Hi! >> I was just wondering how you typically generate a spec HTML report in >> a Rails app. Currently I''m doing something like this: >> >> spec spec -f h:spec/spec_report.html >> >> But that seems sort of clumsy and I would have thought that there was >> a rake task for it. Have I overlooked something? >> >> Thanks! >> >> Peter >> >> >> >> ---------------------------- >> Peter Marklund >> Garvar Lundins Gr?nd 7 >> 11220 Stockholm >> Sweden >> >> Mobile Phone: +46-(0)70-4164857 >> Home Phone: +46-(0)8-50091315 >> Skype: peter_marklund >> >> IM: AIM - petermarklund, MSN - peter_marklund at hotmail.com, Yahoo - >> peter_marklund2002 >> >> http://marklunds.com >> ---------------------------- >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users---------------------------- Peter Marklund Garvar Lundins Gr?nd 7 11220 Stockholm Sweden Mobile Phone: +46-(0)70-4164857 Home Phone: +46-(0)8-50091315 Skype: peter_marklund IM: AIM - petermarklund, MSN - peter_marklund at hotmail.com, Yahoo - peter_marklund2002 http://marklunds.com ----------------------------
Johan Sørensen
2007-Jul-26 17:06 UTC
[rspec-users] Canonical way to generate RSpec HTML report in Rails app
On Jul 26, 2007, at 6:54 PM, Peter Marklund wrote:> Hi Don! > Thanks, that looks nice. For now I''m just using this bash alias: > > alias specdoc=''spec spec -f h:spec/spec_report.html; open spec/ > spec_report.html'' > > However, I guess it''s nicer to have this be a Rake task so that it > can be used by the whole development team. I was looking for an easy > way to pass options on from rake to the spec command, but I''m sort of > starting to get the feeling that sometimes it''s better to invoke the > spec command directly instead of going via rake just as is the case > with Capistrano and the cap command. >Maybe something like (untested, but it''s along the lines of my other SpecTask''s): require "spec/rake/spectask" Spec::Rake::SpecTask.new("htmlspecdocs") do |t| t.spec_files = FileList["spec/**/*_spec.rb"] t.spec_opts = [ "--require", File.dirname(__FILE__) + "/../../spec/spec_helper", # maybe just "h" is enough instead of the classpath here "--format", "Spec::Runner::Formatter::HtmlFormatter:doc/ spec_report.html" ] end JS