Module: FunWith::Testing::TestCaseExtensions

Included in:
TestCase
Defined in:
lib/fun_with/testing/test_case_extensions.rb

Instance Method Summary collapse

Instance Method Details

#_context(*args, &block) ⇒ Object

Convenience methods for disappearing a set of tests. Useful for focusing on one or two tests.



31
32
33
# File 'lib/fun_with/testing/test_case_extensions.rb', line 31

def _context(*args, &block)
  puts "<<< WARNING >>> IGNORING TEST SET #{args.inspect}. Remove leading _ from '_context()' to reactivate."
end

#_should(*args, &block) ⇒ Object



35
36
37
# File 'lib/fun_with/testing/test_case_extensions.rb', line 35

def _should(*args, &block)
  puts "<<< WARNING >>> IGNORING TEST #{args.inspect}. Remove leading _ from '_should()' to reactivate."
end

#_test(*args, &block) ⇒ Object



39
40
41
# File 'lib/fun_with/testing/test_case_extensions.rb', line 39

def _test(*args, &block)
  puts "<<< WARNING >>> IGNORING TEST #{args.inspect}. Remove leading _ from '_test()' to reactivate."
end

#add_factorybot_supportObject

assumes the gem has a test/factories folder, just requir's everything from that directory.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fun_with/testing/test_case_extensions.rb', line 18

def add_factorybot_support
  unless defined?( FactoryBot )
    begin
      require 'factory_bot'
    rescue LoadError
      puts "Error: FactoryBot support requested, but FactoryBot could not be loaded.  make sure the factory_bot gem is listed in your Gemfile, then run `bundle install`."
    end
  end
  
  FactoryBot.find_definitions if defined?( FactoryBot )   # loads factories, test/factories, and spec/factories if they exist (directory or .rb file) 
end

#install_basic_assertionsObject



12
13
14
# File 'lib/fun_with/testing/test_case_extensions.rb', line 12

def install_basic_assertions
  include Assertions::Basics
end

#install_test_modeObject



8
9
10
# File 'lib/fun_with/testing/test_case_extensions.rb', line 8

def install_test_mode
  include TestModeMethods
end

#install_verbosityObject



4
5
6
# File 'lib/fun_with/testing/test_case_extensions.rb', line 4

def install_verbosity
  include VerbosityMethods
end