Skip to content

Instantly share code, notes, and snippets.

@minghz
Created January 1, 2020 04:39
Show Gist options
  • Select an option

  • Save minghz/572ea510a514c0f0bcecd4f30307f18b to your computer and use it in GitHub Desktop.

Select an option

Save minghz/572ea510a514c0f0bcecd4f30307f18b to your computer and use it in GitHub Desktop.

Revisions

  1. minghz created this gist Jan 1, 2020.
    25 changes: 25 additions & 0 deletions minitest_quack_rspec_pt2.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # you actually need the "minitest-hooks" gem to get this lib =_="
    require 'minitest/hooks'

    require 'minitest/autorun'

    class ExtendedMinitest < Minitest::Test
    extend MiniTest::Spec::DSL
    include Minitest::Hooks # You need to add this to your test classes
    end

    class MyTest < ExtendedMinitest

    before(:all) do
    Heavy = Struct.new(:something, :takes, :of, :to)
    @heavy_variable = Heavy.new('that', 'a lot', 'time', 'setup')

    puts 'gets printed once only'
    end

    it { assert_equal 'that', @heavy_variable.something }
    it { assert_equal 'a lot', @heavy_variable.takes }
    it { assert_equal 'time', @heavy_variable.of }
    it { assert_equal 'setup', @heavy_variable.to }

    end