Module: KickTheTires
- Defined in:
- lib/kick_the_tires.rb
Constant Summary collapse
- SOURCE =
Pathname.new(required_by_filename).readlines.map{|a_line| a_line.chomp.strip}
Instance Method Summary collapse
- #assert(a_thing) ⇒ Object
- #assert_equal(expected_this, got_that) ⇒ Object
- #give_the_keys_back ⇒ Object
- #out_for_a_drive? ⇒ Boolean
- #refute(a_thing) ⇒ Object
- #show(a_thing) ⇒ Object
- #show_source ⇒ Object
-
#take_it_for_a_spin ⇒ Object
disable the asserts and shows.
Instance Method Details
#assert(a_thing) ⇒ Object
39 40 41 42 |
# File 'lib/kick_the_tires.rb', line 39 def assert(a_thing) return if @ktt_disabled assert_equal true, a_thing end |
#assert_equal(expected_this, got_that) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kick_the_tires.rb', line 49 def assert_equal(expected_this, got_that) return if @ktt_disabled unless expected_this.to_s == got_that.to_s show_source puts 'Result #=>' puts "Expected This: #{expected_this}" puts "But Got That: #{got_that}" puts end end |
#give_the_keys_back ⇒ Object
65 66 67 |
# File 'lib/kick_the_tires.rb', line 65 def give_the_keys_back @ktt_disabled = false end |
#out_for_a_drive? ⇒ Boolean
69 70 71 |
# File 'lib/kick_the_tires.rb', line 69 def out_for_a_drive? @ktt_disabled end |
#refute(a_thing) ⇒ Object
44 45 46 47 |
# File 'lib/kick_the_tires.rb', line 44 def refute(a_thing) return if @ktt_disabled assert_equal false, a_thing end |
#show(a_thing) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/kick_the_tires.rb', line 32 def show(a_thing) return if @ktt_disabled show_source puts "Showing #{a_thing.class} #=>" ap a_thing, {indent: 2, raw: true} end |
#show_source ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/kick_the_tires.rb', line 23 def show_source return if @ktt_disabled puts puts "-"*75 a_string = caller.last source_line = a_string.split(' ').first.split(':')[1].to_i puts "Source #=> #{SOURCE[source_line-1]}" # MAGIC: zero-based index end |
#take_it_for_a_spin ⇒ Object
disable the asserts and shows
61 62 63 |
# File 'lib/kick_the_tires.rb', line 61 def take_it_for_a_spin @ktt_disabled = true end |