Getting RSpec into RDoc - ruby

In Ioke doc, the ISpec tests are included in the documentation, see ioke.org/dok/index.html
How can this be done with Ruby's RSpec and RDoc (or SDoc)? I can't find any commandline switches or external libs to do so. Any ideas (not including implementing it all by myself ;-) )?

Time helps: Now there's a plugin for YARD doing exactly what I want: http://github.com/lsegal/yard-spec-plugin

Related

Ruby minitest-ci gem

The documentation for the minitest-ci gem (seemingly the only option for producing test results for a CI tool such as Jenkins) has the extremely annoying habit of not preserving the results of rake minitest:models when invoked as rake minitest - the test results from running minitest:models are deleted prior to running the rest of the tests. minitest-ci's barely-extant documentation claims adding this to test_helper.rb will disable the troublesome auto-clean behavior, but it doesn't:
# Why do SO and GitHub have to use completely different ways of indicating inline code?
# test/helper.rb
MiniTest::Ci.auto_clean = false
Has anyone out there managed to get minitest-ci to preserve all the test result files? I'm reaching wits' end here.
I think ci_reporter gem supports miniTest. This could be another option.

Cucumber with Ruby: Can it be used from a gem?

I'd like to develop some reusable step definitions and scenario outlines for Cucumber in Ruby.
I've scoured the Cucumber wiki but there seems to be no info on use of Cucumber with Ruby gems.
Is there support for execution of a feature from an installed Gem?
Or would a user have to manually change to the gem installation directory and explicitly referenced the feature(s) to run from there?
If I understood your question correctly, all you need is to create some lib for reusable definitions and steps, and then require this lib(or gem) in features/support/env.rb
Here is a gem does exactly the same as you need, you can use it as a reference: https://github.com/jayzes/cucumber-api-steps
Look at the features this gem provide: https://github.com/jayzes/cucumber-api-steps/blob/master/features/request.feature The gem created some reusable parts.
Turns out cucumber --help shows the way:
cucumber -r gem-name feature-name.feature
UPDATE: This doesn't work. Any other suggestions?
There is a cucumber gem which installs the binary cucumber.
Running this command, will assume default settings. This means it will look under ./features relative to the current path for files with the .feature extension. It will expect ./features/step_definitions to hold files with *_step.rb, where it will search for steps.
Edit: never mind, I misread your question and thought you wanted to know about the cucumber gem and its default paths.

All Ruby documentation offline with yard

If I want see documentation on my gems I can do:
yard server --gems
How can I see the documentation of Ruby's standard library?
You have to
download the Ruby code archive and extract it into a directory,
run yardoc *.c (that will generate the core documentation),
2a. run yardoc . (that will generate the stdlib documentation but will take a lot of time),
run yard server.
(from http://gnuu.org/2010/10/13/local-copies-of-documentation/)

How can I profile Ruby code in 1.9.2?

What can I use to profile code in 1.9.2? All of the versions of ruby-prof I've found segfault against 1.9.2.
For instance, when I add
gem "ruby-prof"
to my Rails project's Gemfile and run
bundle
bundle exec ruby-prof config/environment.rb
I get a segfault.
Is there a new profiling gem in town? Is there a way to make ruby-prof play nice?
Not sure it helps but I stumbled on this which may add a bit more clarity or lead you down a different path: http://www.devheads.net/development/ruby/core/segmentation-fault-when-using-ruby-prof-and-ruby-192.htm. You may want to check out wycats' fork based on that thread: https://github.com/wycats/ruby-prof
Also, I have not tried it out myself and it may not be exactly what you are looking for but Aman of Github fame has a port of google-perftools for Ruby:
https://github.com/tmm1/perftools.rb
As #chris.baglieri suggested, you can use the perftools.rb gem for profiling Ruby 1.9 code.
gem install perftools.rb
Then
require 'perftools'
PerfTools::CpuProfiler.start('profile_data') do
# something cpu-intensive
end
`pprof.rb --text profile_data profile.txt`
`pprof.rb --pdf profile_data profile.pdf`
You can use another popular profiler tool - MethodProfiler
It's very handy to find slow method in the target class.

rcov outside rails

This may seem obvious but I don't find a way to run Rcov or coverMe outside a Rails project.
I would like to use it with Rspec 2.5
I am using Ruby 1.9.2 so I guess this may be the problem.
I also would like not to use rake tasks but a command on the command line. I have tried several things and the best result I got is Rcov report for :
/var/lib/gems/1.9.1/gems/rcov-0.9.9/lib/rcov/code_coverage_analyzer.rb
and
/var/lib/gems/1.9.1/gems/rcov-0.9.9/lib/rcov/code_coverage_analyzer.rb
No idea why
Check out http://ruby-toolbox.com/categories/code_metrics.html for some alternatives to RCov if using Ruby 1.9 is the problem.
SimpleCov, it runs awesome outside the Rails box.
http://rubydoc.info/gems/simplecov/0.5.4/frames
The latest available version of rcov (0.9.8) still doesn't have good support for 1.9.2. You can try to run it on your project by doing:
rcov spec/*.rb
But you'll most likely get something like:
** WARNING: Ruby 1.9 Support is experimental at best. Don't expect correct results! **
And then some errors after that.

Resources