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.
- checksums.yaml +5 -13
- data/CHANGELOG.markdown +38 -0
- data/Gemfile +33 -11
- data/README.rdoc +3 -6
- data/Rakefile +38 -17
- data/VERSION +1 -1
- data/lib/fun_with/testing/assertions/basics.rb +250 -138
- data/lib/fun_with/testing/assertions_test_case.rb +67 -0
- data/lib/fun_with/testing/assertions_test_mocker.rb +15 -0
- data/lib/fun_with/testing/test_case.rb +1 -71
- data/lib/fun_with/testing/test_case_extensions.rb +47 -0
- data/lib/fun_with/testing/verbosity_methods.rb +33 -0
- data/lib/fun_with_testing.rb +16 -18
- data/test/helper.rb +3 -37
- data/test/test_assertions.rb +609 -14
- data/test/test_fun_with_testing.rb +3 -7
- data/test/test_verbosity.rb +2 -1
- metadata +19 -134
- data/lib/fun_with/testing/assertions/active_record.rb +0 -108
- data/lib/fun_with/testing/assertions/fun_with_files.rb +0 -109
- data/test/test_test_mode.rb +0 -28
|
@@ -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
|
data/lib/fun_with_testing.rb
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
puts __FILE__
|
|
2
|
+
|
|
3
3
|
require 'minitest'
|
|
4
4
|
require 'minitest/autorun'
|
|
5
5
|
require 'shoulda'
|
|
6
|
-
require 'jeweler'
|
|
7
6
|
|
|
8
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 '
|
|
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
|
-
|
|
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
|
|