Skip to content
This repository was archived by the owner on Jul 22, 2018. It is now read-only.

The RSpec Toolbox

Benjamin Oakes edited this page Sep 7, 2012 · 46 revisions

From WindyCityRails 2012

Presenter: David Chelimsky

Notes

From @benjaminoakes:

  • DRW Trading Group (hiring)
  • Rspec2
    • Micronaut: Each example has its own metadata
    • New basis for Rspec

Basically the Command pattern:

example_group = describe Something { }
example = it 'does something' { }
  • Used in output at command line, etc.
  • rspec has formatter methods (there's an protocol with an interface)
    • Example formatters:
      • Documentation
      • HTML
      • 3rd party
        • Instafail: shows you error messages early
        • Fuubar
        • nyan cat
  • Focusing tools
    • autotest, guard -- monitor changes to files and re-run specs
    • Sometimes you don't want it to rerun everything again (e.g., if you TDD)... so, focus!
# FIXME: there's a config line that goes with this

it 'something', :focus => true do
end

Or exclude stuff:

config.filter_run_excluding :slow => true

it 'something', :slow => true do
end

Shorthand:

# Will be default in the future...
config.treat_symbols_as_metadata_keys_with_true_values = true

it 'something', :slow do
end

it 'something', :focus do
end

conditional filters

describe Thing, :if => RUBY_VERSON >= "1.9" do
end
describe Thing, :if => ENV['GENERATE'] do
end

A crowd-sourced conference wiki!
Working together is better. :)




Clone this wiki locally