Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Conociendo Minitest

Conociendo Minitest

Introducción básica a Minitest, la librería de pruebas estándar desde Ruby 1.9

Mario Alberto Chávez

July 11, 2013
Tweet

More Decks by Mario Alberto Chávez

Other Decks in Technology

Transcript

  1. require 'minitest/autorun' describe Tea do describe ‘Green tea’ do subject

    { Tea.new :green } it ‘temperature should be right’ do subject.temperature.must_equal 150 end  end end
  2. require 'minitest/autorun' describe Tea do context ‘Green tea’ do subject

    { Tea.new :green } it ‘temperature should be right’ do subject.temperature.must_equal 150 end  end end
  3. require 'minitest/assertions' module Minitest::Assertions def assert_include(expected, actual) expected.is_a?(Enumerable) && expected.include?(actual)

    end end require 'minitest/autorun' class TeaTest < Minitest::Test def test_available_teas_include_green teas = [:camomille, :green] assert_include teas, :green end end
  4. require 'minitest/spec' module Minitest::Expectations Enumerable.infect_an_assertion :assert_inclu de, :must_include end require

    'minitest/autorun' describe Tea do it 'available teas include green' do teas = [:camomile, :green] teas.must_include :green end end
  5. $ ruby minitest.rb -v Run options: -v --seed 58567 #

    Running tests: Tea::Green tea#test_0001_temperature should be right = 0.00 s = . TeaTest#test_green_tea_temperature = 0.00 s = . Finished tests in 0.000986s, 2028.3976 tests/s, 2028.3976 assertions/s. 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
  6. $ ruby minitest.rb Run options: --seed 36590 # Running: .

    Finished in 0.001162s, 860.5852 runs/s, 0.0000 assertions/s. $ ruby minitest.rb -p Run options: -p --seed 8992 # Running: . Fabulous run in 0.001219s, 820.3445 runs/ s, 0.0000 assertions/s.