fun_with_testing 0.0.4 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ module FunWith
2
+ module Testing
3
+ # For adding to a TestCase class
4
+ module VerbosityMethods
5
+ def self.included( base )
6
+ base.extend( ClassMethods )
7
+ base.send( :include, InstanceMethods )
8
+ end
9
+
10
+ module ClassMethods
11
+ def set_verbose( mode = true )
12
+ self.const_set( :FWT_TEST_VERBOSITY, mode )
13
+ end
14
+
15
+ def verbose?
16
+ return self::FWT_TEST_VERBOSITY if self.constants.include?( :FWT_TEST_VERBOSITY )
17
+ return self.superclass.verbose? if self.superclass.respond_to?(:verbose)
18
+ return false
19
+ end
20
+ end
21
+
22
+ module InstanceMethods
23
+ def verbose?
24
+ self.class.verbose?
25
+ end
26
+
27
+ def puts_if_verbose( msg, stream = $stdout )
28
+ stream.puts( msg ) if self.verbose?
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,29 +1,27 @@
1
- require 'bundler'
2
- require 'debugger'
1
+ puts __FILE__
2
+
3
3
  require 'minitest'
4
4
  require 'minitest/autorun'
5
5
  require 'shoulda'
6
- require 'jeweler'
7
6
 
8
- begin
9
- Bundler.setup(:default, :development)
10
- rescue Bundler::BundlerError => e
11
- $stderr.puts e.message
12
- $stderr.puts "Run `bundle install` to install missing gems"
13
- exit e.status_code
14
- end
7
+ puts "loaded gems"
15
8
 
9
+ # begin
10
+ # Bundler.setup(:default, :development)
11
+ # rescue Bundler::BundlerError => e
12
+ # $stderr.puts e.message
13
+ # $stderr.puts "Run `bundle install` to install missing gems"
14
+ # exit e.status_code
15
+ # end
16
16
 
17
- files = Dir.glob( File.join( File.dirname(__FILE__), "fun_with", "testing", "**", "*.rb" ) )
18
17
 
19
- for file in files.map{ |f| f.gsub(/\.rb$/, '') }
20
- require file
21
- end
18
+ require_relative "fun_with/testing/test_case_extensions"
19
+ require_relative "fun_with/testing/test_case"
20
+ require_relative "fun_with/testing/assertions/basics"
21
+ require_relative "fun_with/testing/assertions_test_case"
22
+ require_relative "fun_with/testing/assertions_test_mocker"
23
+ require_relative "fun_with/testing/verbosity_methods"
22
24
 
23
25
 
24
- # FunWith::Testing.extend( FunWith::Testing::FwtExtensions )
25
- # FunWith::Testing.assertion_modules << FunWith::Testing::Assertions::ActiveRecord
26
- # FunWith::Testing.assertion_modules << FunWith::Testing::Assertions::Basics
27
26
 
28
27
  FunWith::Testing.send( :include, FunWith::Testing::Assertions::Basics )
29
- FunWith::Testing.send( :include, FunWith::Testing::Assertions::ActiveRecord )
data/test/helper.rb CHANGED
@@ -1,6 +1,6 @@
1
- # require 'rubygems'
2
1
  require 'bundler'
3
- require 'debugger'
2
+ require 'debug'
3
+
4
4
 
5
5
  begin
6
6
  Bundler.setup(:default, :development)
@@ -10,45 +10,11 @@ rescue Bundler::BundlerError => e
10
10
  exit e.status_code
11
11
  end
12
12
 
13
- # require 'test/unit'
14
- # require 'minitest'
15
- # require 'minitest/autorun'
16
- # require 'shoulda'
17
-
18
13
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
19
14
  $LOAD_PATH.unshift(File.dirname(__FILE__))
20
15
 
21
-
22
16
  require 'fun_with_testing'
23
17
 
24
- # class Minitest::Test
25
- # end
26
-
27
- # Any subclass of Test::Unit::TestCase seems to automatically hook into the test suite.
28
- # Therefore, calling a test to see if it returns false makes the suite fail. Including
29
- # to this class instead prevents that. I may need to more closely mimic Test::Unit::TestCase
30
- # in order to test messages properly.
31
- class MockUnitTest < FunWith::Testing::TestCase
32
- def build_message( m, m2, obj = nil)
33
- "#{m} #{m2} #{obj}"
34
- end
35
-
36
- def safe_assert_block( *args, &block )
37
- yield
38
- end
39
- end
40
-
41
- class FunWith::Testing::MyTestCase < FunWith::Testing::TestCase
42
- def extended_test_case( &block )
43
- @case_class = Class.new( MockUnitTest )
44
- @case_class.send( :include, FunWith::Testing )
45
- @case = @case_class.new( "MockUnitTest" )
46
-
47
- assert @case_class.methods.include?( :_should )
48
- assert @case_class.methods.include?( :_context )
49
- assert @case.methods.include?( :in_test_mode? )
50
-
51
- yield if block_given?
52
- end
18
+ class FunTestCase < FunWith::Testing::TestCase
53
19
  end
54
20