fun_with_testing 0.0.7 → 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 -5
- data/CHANGELOG.markdown +16 -5
- data/Gemfile +27 -16
- data/README.rdoc +3 -6
- data/Rakefile +27 -22
- data/VERSION +1 -1
- data/lib/fun_with/testing/assertions/basics.rb +35 -0
- data/lib/fun_with/testing/assertions_test_case.rb +13 -11
- data/lib/fun_with/testing/assertions_test_mocker.rb +15 -0
- data/lib/fun_with/testing/test_case.rb +1 -23
- data/lib/fun_with/testing/test_case_extensions.rb +47 -0
- data/lib/fun_with/testing/verbosity_methods.rb +1 -11
- data/lib/fun_with_testing.rb +21 -29
- data/test/helper.rb +3 -8
- data/test/test_assertions.rb +35 -4
- data/test/test_fun_with_testing.rb +3 -4
- data/test/test_verbosity.rb +1 -1
- metadata +8 -169
- data/lib/fun_with/testing/test_mode_methods.rb +0 -32
- data/test/test_test_mode.rb +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ef7ef2d783645269b6d95fae227851df1adf436d0afd48edd7bfdfa1426da282
|
|
4
|
+
data.tar.gz: ec76fa0100ad69d2a83e2f9ae30b9213a40a2671e3d5c24964559149716a11a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b9baec42232166fdd0587e4a5f4f64192c31e4cbde053aeae8cb6a43485d0360af68fca8067dcfe54b80fd75ac5d7ae07eb9206fb80b3d8b9d1930a02084ce9
|
|
7
|
+
data.tar.gz: 98580befc0b52da3259ac7020b55bd15b1395072a3b0848e2f8a27ec016a52b7e08d6a36e8cdb72373690cc3fb9f0eba3557dede1c48f9a4d04509766c96a3e8
|
data/CHANGELOG.markdown
CHANGED
|
@@ -5,13 +5,24 @@ v0.0.?+
|
|
|
5
5
|
------
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
v0.0.
|
|
9
|
-
|
|
8
|
+
v0.0.9
|
|
9
|
+
------
|
|
10
|
+
|
|
11
|
+
* Cleaning up documentation.
|
|
12
|
+
* Better rdoc coverage
|
|
13
|
+
* Moving TestMode into separate gem (FunWith::TestMode)
|
|
14
|
+
* What to do with "Verbosity"?
|
|
15
|
+
* added `.add_factorybot_support()` to TestCase... # conflicted about this, maybe should go in FunWith::Rails?
|
|
16
|
+
*
|
|
17
|
+
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
v0.0.8 (current)
|
|
20
|
+
------------------
|
|
12
21
|
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
* Mucked with the gemfile dependencies.
|
|
23
|
+
|
|
24
|
+
v0.0.7
|
|
25
|
+
------
|
|
15
26
|
|
|
16
27
|
* Moving everything related to FunWith::Files into that gem.
|
|
17
28
|
* Removing ActiveRecord stuff in preparation for Glorious FunWith::Rails Future!
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
source "
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
3
|
# Add dependencies required to use your gem here.
|
|
4
4
|
# Example:
|
|
@@ -16,21 +16,32 @@ group :development do
|
|
|
16
16
|
# gem "fun_with_testing", "~> 0.0", ">= 0.0.4"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
#
|
|
20
|
-
#
|
|
19
|
+
# 3.6.0 => 2019-10 # most of its functionality is is shoulda-context and shoulda-matchers, which are more up to date
|
|
20
|
+
# 2020-06 # removing it seems to be causing problems. Which only started showing up now?
|
|
21
|
+
gem "shoulda", ">= 4" # 2024-11 curently at 4.0.0 (been ages since it was updated, I guess.)
|
|
22
|
+
# gem "shoulda-matchers" # 2024-11 currently at
|
|
23
|
+
gem "shoulda-context" # 2024-11 currently at 2.0
|
|
24
|
+
gem "rdoc", ">= 6" # 6.7 as of 2024-11
|
|
21
25
|
|
|
22
|
-
ruby_major, ruby_minor, ruby_patch = RUBY_VERSION.split(".").map(&:to_i)
|
|
23
26
|
|
|
24
|
-
if ruby_major < 2 || ruby_minor < 2 || ruby_minor == 2 && ruby_patch <= 1
|
|
25
|
-
gem "rack", "~> 1"
|
|
26
|
-
else
|
|
27
|
-
gem "rack", "~> 2"
|
|
28
|
-
end
|
|
29
27
|
|
|
30
|
-
gem
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
gem
|
|
36
|
-
|
|
28
|
+
# 2021-06 : I've run into this issue where newer versions of the TTY gem are blocking on newer bundler versions. I'm first going to try dropping the "~>2"
|
|
29
|
+
# and if that doesn't work, delete the dependency entirely.
|
|
30
|
+
# 2025-03 : I'm getting a weird message about a method redefinition. Gonna try nailing this to the absolute most recent
|
|
31
|
+
# version and seeing what happens.
|
|
32
|
+
#
|
|
33
|
+
# I guess I solved the default bundler problem by doing gem update --system 3.3.6 (apparently the latest version)
|
|
34
|
+
# ... and also remove all the old versions of bundler
|
|
35
|
+
# gem "bundler", ">= 2.7" # RVM comes with its own version of Bundler that's taking precedence, so can't really nail down a version
|
|
36
|
+
|
|
37
|
+
gem "juwelier", ">= 2" # 2.4.9 => 2019-10
|
|
38
|
+
# gem "simplecov", ">= 0" # 0.22 as of 2024-11
|
|
39
|
+
# gem 'byebug', "~> 10" # 9.0.6 => 2016-09-30
|
|
40
|
+
gem 'minitest', ">= 6" # 6.0.1 (2025-12-30)
|
|
41
|
+
|
|
42
|
+
# making some of the dependencies more specific than the previously listed gems demand
|
|
43
|
+
# okay, Past Bryce. Thanks for telling me you did that. But screw you for not trying to explain why.
|
|
44
|
+
# gem 'json', "~> 2", ">= 2.0.3"
|
|
45
|
+
# gem 'nokogiri', ">= 1.16"
|
|
46
|
+
|
|
47
|
+
gem 'debug'
|
data/README.rdoc
CHANGED
|
@@ -5,16 +5,13 @@ A bunch of useful assertions, and a subclass of Test::Unit::TestCase for my gems
|
|
|
5
5
|
Usage:
|
|
6
6
|
|
|
7
7
|
# This might go in test/helper.rb, for example
|
|
8
|
-
class GemTestCase <
|
|
9
|
-
|
|
10
|
-
# include FunWith::Testing::Assertions::Basics # alternately, just include tests piecemeal
|
|
11
|
-
# include FunWith::Testing::Assertions::ActiveRecord # alternately, just include tests piecemeal
|
|
12
|
-
# include FunWith::Testing::Assertions::FunWithFiles # alternately, just include tests piecemeal
|
|
8
|
+
class GemTestCase < FunWith::Testing::TestCase
|
|
9
|
+
install_basic_assertions
|
|
13
10
|
end
|
|
14
11
|
|
|
15
12
|
Then in test/test_gem.rb:
|
|
16
13
|
|
|
17
|
-
class
|
|
14
|
+
class MyUnitTest < GemTestCase
|
|
18
15
|
def test_my_thing
|
|
19
16
|
assert_zero( 0 )
|
|
20
17
|
assert_not_zero( 1 )
|
data/Rakefile
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'bundler'
|
|
5
|
+
|
|
5
6
|
begin
|
|
6
7
|
Bundler.setup(:default, :development)
|
|
7
8
|
rescue Bundler::BundlerError => e
|
|
@@ -9,21 +10,20 @@ rescue Bundler::BundlerError => e
|
|
|
9
10
|
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
11
|
exit e.status_code
|
|
11
12
|
end
|
|
12
|
-
require 'rake'
|
|
13
13
|
|
|
14
|
+
require 'rake'
|
|
14
15
|
require 'juwelier'
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
Gem::Specification.new do |gem|
|
|
16
18
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
17
19
|
gem.name = "fun_with_testing"
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
# gem.version = (File.exist?('VERSION') ? File.read('VERSION') : "0.0.0")
|
|
21
|
-
|
|
21
|
+
gem.version = File.read('VERSION') if File.exist?('VERSION')
|
|
22
22
|
|
|
23
23
|
gem.homepage = "http://github.com/darthschmoo/fun_with_testing"
|
|
24
24
|
gem.licenses = ["MIT"]
|
|
25
25
|
gem.summary = "A place to stash Test::Unit assertions I've found handy."
|
|
26
|
-
gem.description = "A place to stash Test::Unit assertions I've found handy. Use at your own risk"
|
|
26
|
+
gem.description = "A place to stash Test::Unit assertions I've found handy. Use at your own risk."
|
|
27
27
|
gem.email = "keeputahweird@gmail.com"
|
|
28
28
|
gem.authors = ["Bryce Anderson"]
|
|
29
29
|
|
|
@@ -36,6 +36,10 @@ Juwelier::Tasks.new do |gem|
|
|
|
36
36
|
# dependencies defined in Gemfile
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
require 'bundler/gem_tasks'
|
|
39
43
|
Juwelier::RubygemsDotOrgTasks.new
|
|
40
44
|
|
|
41
45
|
require 'rake/testtask'
|
|
@@ -54,21 +58,22 @@ end
|
|
|
54
58
|
# end
|
|
55
59
|
|
|
56
60
|
# Adding this to see if it's making any difference
|
|
57
|
-
desc "Code coverage detail"
|
|
58
|
-
task :simplecov do
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
61
|
+
# desc "Code coverage detail"
|
|
62
|
+
# task :simplecov do
|
|
63
|
+
# ENV['COVERAGE'] = "true"
|
|
64
|
+
# Rake::Task['test'].execute
|
|
65
|
+
# end
|
|
66
|
+
#
|
|
63
67
|
|
|
64
68
|
task :default => :test
|
|
65
|
-
|
|
66
|
-
require 'rdoc/task'
|
|
67
|
-
Rake::RDocTask.new do |rdoc|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
end
|
|
69
|
+
#
|
|
70
|
+
# require 'rdoc/task'
|
|
71
|
+
# Rake::RDocTask.new do |rdoc|
|
|
72
|
+
# version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
73
|
+
#
|
|
74
|
+
# rdoc.rdoc_dir = 'rdoc'
|
|
75
|
+
# rdoc.title = "fun_with_testing #{version}"
|
|
76
|
+
# rdoc.rdoc_files.include('README*')
|
|
77
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
|
78
|
+
# end
|
|
79
|
+
#
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.10
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
# A namespace module that acts as an umbrella for a
|
|
2
|
+
# collection of gems I'm maintaining. (rdoc)
|
|
3
|
+
#
|
|
4
|
+
# I seem to be trying to write an entire ecosystem
|
|
5
|
+
# single-handed. It's not going well.
|
|
1
6
|
module FunWith
|
|
7
|
+
|
|
8
|
+
# A gem that adds a collection of custom assertions to a test suite.
|
|
9
|
+
#
|
|
10
|
+
# Also includes some infrastructure for testing the assertions themselves.
|
|
11
|
+
#
|
|
12
|
+
# Other FunWith- gems will contain extensions with their own custom assertions.
|
|
13
|
+
# For example, FunWith::Files adds in things like `assert_directory()`, etc.
|
|
2
14
|
module Testing
|
|
15
|
+
|
|
16
|
+
# Modules full of custom assertions should go under this namespace.
|
|
3
17
|
module Assertions
|
|
4
18
|
module Basics
|
|
5
19
|
# Interesting thing about message() : returns a proc that, when called, returns
|
|
@@ -272,6 +286,27 @@ module FunWith
|
|
|
272
286
|
assert false, msg
|
|
273
287
|
end
|
|
274
288
|
end
|
|
289
|
+
|
|
290
|
+
def assert_constant_defined( const, msg = nil )
|
|
291
|
+
begin
|
|
292
|
+
Object.const_get( const )
|
|
293
|
+
assert true
|
|
294
|
+
rescue NameError
|
|
295
|
+
assert false, message(msg){ "expected constant is not defined: #{const}" }
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Which order makes more sense for the arguments
|
|
300
|
+
# Assert that the first argument includes the module specified in the second argument
|
|
301
|
+
def assert_includes_module( mod_or_class, mod, msg = nil )
|
|
302
|
+
# Make sure we've been passed the proper sort of objects
|
|
303
|
+
assert mod_or_class.respond_to?( :included_modules, "#{mod_or_class} doesn't respond to included_modules()" )
|
|
304
|
+
raise ArgumentError.new( "#{mod} is not a module" ) unless mod.kind_of?( Module )
|
|
305
|
+
|
|
306
|
+
msg = message(msg){ "#{mod_or_class} should have included module #{mod}" }
|
|
307
|
+
|
|
308
|
+
assert mod_or_class.included_modules.include?(mod), msg
|
|
309
|
+
end
|
|
275
310
|
end
|
|
276
311
|
end
|
|
277
312
|
end
|
|
@@ -3,19 +3,20 @@ module FunWith
|
|
|
3
3
|
# Class is designed specifically for testing custom assertions.
|
|
4
4
|
# See test/test_assertions.rb for how it's supposed to work.
|
|
5
5
|
class AssertionsTestCase < FunWith::Testing::TestCase
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# to this class instead prevents that.
|
|
9
|
-
#
|
|
10
|
-
# I may need to more closely mimic Test::Unit::TestCase
|
|
11
|
-
# in order to test messages properly.
|
|
12
|
-
def safe_assert_block( *args, &block )
|
|
13
|
-
yield
|
|
6
|
+
def self.fwt_install_mock_safe_assert_block
|
|
7
|
+
include AssertionTestMocker
|
|
14
8
|
end
|
|
15
|
-
|
|
9
|
+
|
|
10
|
+
# After @case_class is created, you can include the methods you want to test
|
|
11
|
+
#
|
|
16
12
|
def extended_test_case( &block )
|
|
17
13
|
@case_class = Class.new( FunWith::Testing::AssertionsTestCase )
|
|
18
|
-
|
|
14
|
+
|
|
15
|
+
# Unhook from some of the test harness stuff to
|
|
16
|
+
# make it possible to run the assertion methods
|
|
17
|
+
# without causing the test suite to topple over.
|
|
18
|
+
@case_class.fwt_install_mock_safe_assert_block
|
|
19
|
+
|
|
19
20
|
@case = @case_class.new( "MockUnitTest" ) # what does name arg do?
|
|
20
21
|
|
|
21
22
|
assert @case_class.methods.include?( :_should )
|
|
@@ -45,7 +46,8 @@ module FunWith
|
|
|
45
46
|
puts "should fail: #{@current_method_sym}( #{ args.map(&:inspect).join(", ")})"
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
|
-
|
|
49
|
+
|
|
50
|
+
#
|
|
49
51
|
def oops( *args )
|
|
50
52
|
assert_raises( StandardError ) do
|
|
51
53
|
@case.send( @current_method_sym, *args, &block )
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module FunWith
|
|
2
|
+
module Testing
|
|
3
|
+
module AssertionTestMocker
|
|
4
|
+
# Any subclass of Test::Unit::TestCase seems to automatically hook into the test suite.
|
|
5
|
+
# Therefore, calling a test to see if it returns false makes the suite fail. Including
|
|
6
|
+
# to this class instead prevents that.
|
|
7
|
+
#
|
|
8
|
+
# I may need to more closely mimic Test::Unit::TestCase
|
|
9
|
+
# in order to test messages properly.
|
|
10
|
+
def safe_assert_block( *args, &block )
|
|
11
|
+
yield
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
module FunWith
|
|
2
2
|
module Testing
|
|
3
3
|
class TestCase < Minitest::Test
|
|
4
|
-
|
|
5
|
-
include VerbosityMethods
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.install_test_mode
|
|
9
|
-
include TestModeMethods
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.install_basic_assertions
|
|
13
|
-
include Assertions::Basics
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Convenience methods for disappearing a set of tests. Useful for focusing on one or two tests.
|
|
17
|
-
def self._context(*args, &block)
|
|
18
|
-
puts "<<< WARNING >>> IGNORING TEST SET #{args.inspect}. Remove leading _ from '_context()' to reactivate."
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def self._should(*args, &block)
|
|
22
|
-
puts "<<< WARNING >>> IGNORING TEST #{args.inspect}. Remove leading _ from '_should()' to reactivate."
|
|
23
|
-
end
|
|
24
|
-
# def build_message( *args )
|
|
25
|
-
# args.map(&:inspect).join(" ")
|
|
26
|
-
# end
|
|
4
|
+
extend TestCaseExtensions
|
|
27
5
|
end
|
|
28
6
|
end
|
|
29
7
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module FunWith
|
|
2
|
+
module Testing
|
|
3
|
+
module TestCaseExtensions
|
|
4
|
+
def install_verbosity
|
|
5
|
+
include VerbosityMethods
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def install_test_mode
|
|
9
|
+
include TestModeMethods
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def install_basic_assertions
|
|
13
|
+
include Assertions::Basics
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# assumes the gem has a test/factories folder, just requir's everything
|
|
17
|
+
# from that directory.
|
|
18
|
+
def add_factorybot_support
|
|
19
|
+
unless defined?( FactoryBot )
|
|
20
|
+
begin
|
|
21
|
+
require 'factory_bot'
|
|
22
|
+
rescue LoadError
|
|
23
|
+
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`."
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
FactoryBot.find_definitions if defined?( FactoryBot ) # loads factories, test/factories, and spec/factories if they exist (directory or .rb file)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Convenience methods for disappearing a set of tests. Useful for focusing on one or two tests.
|
|
31
|
+
def _context(*args, &block)
|
|
32
|
+
puts "<<< WARNING >>> IGNORING TEST SET #{args.inspect}. Remove leading _ from '_context()' to reactivate."
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def _should(*args, &block)
|
|
36
|
+
puts "<<< WARNING >>> IGNORING TEST #{args.inspect}. Remove leading _ from '_should()' to reactivate."
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def _test(*args, &block)
|
|
40
|
+
puts "<<< WARNING >>> IGNORING TEST #{args.inspect}. Remove leading _ from '_test()' to reactivate."
|
|
41
|
+
end
|
|
42
|
+
# def build_message( *args )
|
|
43
|
+
# args.map(&:inspect).join(" ")
|
|
44
|
+
# end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -4,7 +4,7 @@ module FunWith
|
|
|
4
4
|
module VerbosityMethods
|
|
5
5
|
def self.included( base )
|
|
6
6
|
base.extend( ClassMethods )
|
|
7
|
-
base.send( :include, InstanceMethods)
|
|
7
|
+
base.send( :include, InstanceMethods )
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
module ClassMethods
|
|
@@ -31,13 +31,3 @@ module FunWith
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
module FunWith
|
|
38
|
-
module Testing
|
|
39
|
-
module VerbosityMethods
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
data/lib/fun_with_testing.rb
CHANGED
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
puts __FILE__
|
|
2
|
+
|
|
3
3
|
require 'minitest'
|
|
4
4
|
require 'minitest/autorun'
|
|
5
5
|
require 'shoulda'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
file = files.shift
|
|
26
|
-
require file
|
|
27
|
-
rescue NameError => e # if the class/module depends on a not-yet-defined class/module
|
|
28
|
-
warn "#{e.class}: #{e.message}"
|
|
29
|
-
files << file
|
|
30
|
-
raise "Too many errors!\n\t" + error_messages.join( "\n\t" ) if error_messages.length >= 100
|
|
31
|
-
end
|
|
32
|
-
end
|
|
6
|
+
|
|
7
|
+
puts "loaded gems"
|
|
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
|
+
|
|
17
|
+
|
|
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"
|
|
24
|
+
|
|
33
25
|
|
|
34
26
|
|
|
35
27
|
FunWith::Testing.send( :include, FunWith::Testing::Assertions::Basics )
|
data/test/helper.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
|
+
require 'debug'
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
begin
|
|
4
6
|
Bundler.setup(:default, :development)
|
|
@@ -8,18 +10,11 @@ rescue Bundler::BundlerError => e
|
|
|
8
10
|
exit e.status_code
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
# require 'test/unit'
|
|
12
|
-
# require 'minitest'
|
|
13
|
-
# require 'minitest/autorun'
|
|
14
|
-
# require 'shoulda'
|
|
15
|
-
|
|
16
13
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
17
14
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
18
15
|
|
|
19
|
-
|
|
20
16
|
require 'fun_with_testing'
|
|
21
|
-
# require_relative File.join( "classes", "mock_unit_test" )
|
|
22
17
|
|
|
23
|
-
class
|
|
18
|
+
class FunTestCase < FunWith::Testing::TestCase
|
|
24
19
|
end
|
|
25
20
|
|
data/test/test_assertions.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
module FunWith
|
|
4
4
|
module Testing
|
|
5
|
-
class TestAssertions <
|
|
5
|
+
class TestAssertions < AssertionsTestCase
|
|
6
6
|
def modded_object( &block )
|
|
7
7
|
m = Module.new(&block)
|
|
8
8
|
o = Object.new
|
|
@@ -10,6 +10,8 @@ module FunWith
|
|
|
10
10
|
o
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
debugger unless self.respond_to?(:context)
|
|
14
|
+
|
|
13
15
|
context "testing assertions" do
|
|
14
16
|
setup do
|
|
15
17
|
extended_test_case # sets @case, which is used to access to assertions
|
|
@@ -366,7 +368,7 @@ module FunWith
|
|
|
366
368
|
|
|
367
369
|
context "testing :assert_less_than()" do
|
|
368
370
|
should "pass all tests" do
|
|
369
|
-
testing_method
|
|
371
|
+
testing_method :assert_less_than do
|
|
370
372
|
yep 5, 4
|
|
371
373
|
yep "b", "a"
|
|
372
374
|
yep 100, 7.1
|
|
@@ -553,7 +555,7 @@ module FunWith
|
|
|
553
555
|
should "assure us that classes have methods" do
|
|
554
556
|
instance_methods = {
|
|
555
557
|
Integer => [:to_s, :odd?, :even?, :times, :ceil],
|
|
556
|
-
|
|
558
|
+
Float => [:to_f],
|
|
557
559
|
Array => [:length, :each, :sort, :map],
|
|
558
560
|
Object => [:hash, :tap, :is_a?, :to_s]
|
|
559
561
|
}
|
|
@@ -570,7 +572,7 @@ module FunWith
|
|
|
570
572
|
should "assure us that classes don't have hinkey instance methods" do
|
|
571
573
|
instance_methods = {
|
|
572
574
|
Integer => [:to_p, :old?, :seven?, :timey, :seal],
|
|
573
|
-
|
|
575
|
+
Numeric => [:to_g],
|
|
574
576
|
Array => [:lanth, :eech, :sorta, :nap, :way_too_long?],
|
|
575
577
|
Object => [:hashbrown, :tarp, :is_also_a?, :to_sting]
|
|
576
578
|
}
|
|
@@ -592,6 +594,35 @@ module FunWith
|
|
|
592
594
|
@case.assert_equal_length [], []
|
|
593
595
|
end
|
|
594
596
|
end
|
|
597
|
+
|
|
598
|
+
context "testing assert_constant_defined" do
|
|
599
|
+
should "acknowledge the existence of the mighty Float class!" do
|
|
600
|
+
testing_method :assert_constant_defined do
|
|
601
|
+
yep "Float"
|
|
602
|
+
yep "FunWith::Testing"
|
|
603
|
+
yep "FunWith::Testing::TestAssertions"
|
|
604
|
+
yep "::Array"
|
|
605
|
+
yep "Enumerator::Lazy"
|
|
606
|
+
|
|
607
|
+
nope "Hippopotamus"
|
|
608
|
+
nope "FunWith::SpringLoaded::Walrus"
|
|
609
|
+
|
|
610
|
+
oops nil
|
|
611
|
+
oops
|
|
612
|
+
end
|
|
613
|
+
end
|
|
614
|
+
end
|
|
615
|
+
|
|
616
|
+
context "testing assert_included_module" do
|
|
617
|
+
should "recognize modules as included or not" do
|
|
618
|
+
testing_method :assert_includes_module do
|
|
619
|
+
yep File, Kernel
|
|
620
|
+
yep Numeric, Comparable
|
|
621
|
+
yep SyntaxError, Kernel
|
|
622
|
+
oops nil, 3
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
end
|
|
595
626
|
end
|
|
596
627
|
end
|
|
597
628
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class TestFunWithTesting < FunWith::Testing::MyTestCase
|
|
3
|
+
class TestFunWithTesting < FunTestCase
|
|
5
4
|
should "be plumbed properly" do
|
|
6
5
|
assert defined?( FunWith::Testing::Assertions )
|
|
7
6
|
assert defined?( FunWith::Testing::Assertions::Basics )
|
|
@@ -14,7 +13,7 @@ class TestFunWithTesting < FunWith::Testing::MyTestCase
|
|
|
14
13
|
|
|
15
14
|
should "have test/unit on board" do
|
|
16
15
|
assert( defined?( Minitest ), "problem loading Minitest" )
|
|
17
|
-
assert( defined?( Minitest::Test ), "problem loading Minitest" )
|
|
16
|
+
assert( defined?( Minitest::Test ), "problem loading Minitest::Test" )
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
should "access a listing of assertion modules" do
|
|
@@ -22,7 +21,7 @@ class TestFunWithTesting < FunWith::Testing::MyTestCase
|
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
should "successfully get included in a subclass" do
|
|
25
|
-
klass = Class.new( Minitest::
|
|
24
|
+
klass = Class.new( Minitest::Test )
|
|
26
25
|
|
|
27
26
|
imethods = klass.instance_methods.select{|sym| sym.to_s =~ /^(assert|refute)_/ }
|
|
28
27
|
|
data/test/test_verbosity.rb
CHANGED
metadata
CHANGED
|
@@ -1,189 +1,31 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fun_with_testing
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryce Anderson
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: rack
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: shoulda
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '3.5'
|
|
34
|
-
- - "~>"
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: '3'
|
|
37
|
-
type: :runtime
|
|
38
|
-
prerelease: false
|
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
-
requirements:
|
|
41
|
-
- - ">="
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
version: '3.5'
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '3'
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: rdoc
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - ">="
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: 4.2.2
|
|
54
|
-
- - "~>"
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: '4'
|
|
57
|
-
type: :runtime
|
|
58
|
-
prerelease: false
|
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
60
|
-
requirements:
|
|
61
|
-
- - ">="
|
|
62
|
-
- !ruby/object:Gem::Version
|
|
63
|
-
version: 4.2.2
|
|
64
|
-
- - "~>"
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: '4'
|
|
67
|
-
- !ruby/object:Gem::Dependency
|
|
68
|
-
name: bundler
|
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
|
70
|
-
requirements:
|
|
71
|
-
- - ">="
|
|
72
|
-
- !ruby/object:Gem::Version
|
|
73
|
-
version: '1.10'
|
|
74
|
-
- - "~>"
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: '1'
|
|
77
|
-
type: :runtime
|
|
78
|
-
prerelease: false
|
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
-
requirements:
|
|
81
|
-
- - ">="
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
version: '1.10'
|
|
84
|
-
- - "~>"
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: '1'
|
|
87
|
-
- !ruby/object:Gem::Dependency
|
|
88
|
-
name: juwelier
|
|
89
|
-
requirement: !ruby/object:Gem::Requirement
|
|
90
|
-
requirements:
|
|
91
|
-
- - ">="
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
version: '2.1'
|
|
94
|
-
- - "~>"
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '2'
|
|
97
|
-
type: :runtime
|
|
98
|
-
prerelease: false
|
|
99
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - ">="
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '2.1'
|
|
104
|
-
- - "~>"
|
|
105
|
-
- !ruby/object:Gem::Version
|
|
106
|
-
version: '2'
|
|
107
|
-
- !ruby/object:Gem::Dependency
|
|
108
|
-
name: simplecov
|
|
109
|
-
requirement: !ruby/object:Gem::Requirement
|
|
110
|
-
requirements:
|
|
111
|
-
- - ">="
|
|
112
|
-
- !ruby/object:Gem::Version
|
|
113
|
-
version: '0.11'
|
|
114
|
-
- - "~>"
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '0'
|
|
117
|
-
type: :runtime
|
|
118
|
-
prerelease: false
|
|
119
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - ">="
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '0.11'
|
|
124
|
-
- - "~>"
|
|
125
|
-
- !ruby/object:Gem::Version
|
|
126
|
-
version: '0'
|
|
127
|
-
- !ruby/object:Gem::Dependency
|
|
128
|
-
name: byebug
|
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
|
130
|
-
requirements:
|
|
131
|
-
- - ">="
|
|
132
|
-
- !ruby/object:Gem::Version
|
|
133
|
-
version: '9.0'
|
|
134
|
-
- - "~>"
|
|
135
|
-
- !ruby/object:Gem::Version
|
|
136
|
-
version: '9'
|
|
137
|
-
type: :runtime
|
|
138
|
-
prerelease: false
|
|
139
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
140
|
-
requirements:
|
|
141
|
-
- - ">="
|
|
142
|
-
- !ruby/object:Gem::Version
|
|
143
|
-
version: '9.0'
|
|
144
|
-
- - "~>"
|
|
145
|
-
- !ruby/object:Gem::Version
|
|
146
|
-
version: '9'
|
|
147
|
-
- !ruby/object:Gem::Dependency
|
|
148
|
-
name: minitest
|
|
149
|
-
requirement: !ruby/object:Gem::Requirement
|
|
150
|
-
requirements:
|
|
151
|
-
- - ">="
|
|
152
|
-
- !ruby/object:Gem::Version
|
|
153
|
-
version: '5.9'
|
|
154
|
-
- - "~>"
|
|
155
|
-
- !ruby/object:Gem::Version
|
|
156
|
-
version: '5'
|
|
157
|
-
type: :runtime
|
|
158
|
-
prerelease: false
|
|
159
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
160
|
-
requirements:
|
|
161
|
-
- - ">="
|
|
162
|
-
- !ruby/object:Gem::Version
|
|
163
|
-
version: '5.9'
|
|
164
|
-
- - "~>"
|
|
165
|
-
- !ruby/object:Gem::Version
|
|
166
|
-
version: '5'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
167
12
|
description: A place to stash Test::Unit assertions I've found handy. Use at your
|
|
168
|
-
own risk
|
|
13
|
+
own risk.
|
|
169
14
|
email: keeputahweird@gmail.com
|
|
170
15
|
executables: []
|
|
171
16
|
extensions: []
|
|
172
|
-
extra_rdoc_files:
|
|
173
|
-
- CHANGELOG.markdown
|
|
174
|
-
- LICENSE.txt
|
|
175
|
-
- README.rdoc
|
|
17
|
+
extra_rdoc_files: []
|
|
176
18
|
files:
|
|
177
19
|
- "./lib/fun_with/testing/assertions/basics.rb"
|
|
178
20
|
- "./lib/fun_with/testing/assertions_test_case.rb"
|
|
21
|
+
- "./lib/fun_with/testing/assertions_test_mocker.rb"
|
|
179
22
|
- "./lib/fun_with/testing/test_case.rb"
|
|
180
|
-
- "./lib/fun_with/testing/
|
|
23
|
+
- "./lib/fun_with/testing/test_case_extensions.rb"
|
|
181
24
|
- "./lib/fun_with/testing/verbosity_methods.rb"
|
|
182
25
|
- "./lib/fun_with_testing.rb"
|
|
183
26
|
- "./test/helper.rb"
|
|
184
27
|
- "./test/test_assertions.rb"
|
|
185
28
|
- "./test/test_fun_with_testing.rb"
|
|
186
|
-
- "./test/test_test_mode.rb"
|
|
187
29
|
- "./test/test_verbosity.rb"
|
|
188
30
|
- CHANGELOG.markdown
|
|
189
31
|
- Gemfile
|
|
@@ -195,7 +37,6 @@ homepage: http://github.com/darthschmoo/fun_with_testing
|
|
|
195
37
|
licenses:
|
|
196
38
|
- MIT
|
|
197
39
|
metadata: {}
|
|
198
|
-
post_install_message:
|
|
199
40
|
rdoc_options: []
|
|
200
41
|
require_paths:
|
|
201
42
|
- lib
|
|
@@ -210,9 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
210
51
|
- !ruby/object:Gem::Version
|
|
211
52
|
version: '0'
|
|
212
53
|
requirements: []
|
|
213
|
-
|
|
214
|
-
rubygems_version: 2.6.6
|
|
215
|
-
signing_key:
|
|
54
|
+
rubygems_version: 4.0.14
|
|
216
55
|
specification_version: 4
|
|
217
56
|
summary: A place to stash Test::Unit assertions I've found handy.
|
|
218
57
|
test_files: []
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module FunWith
|
|
2
|
-
module Testing
|
|
3
|
-
# For adding to a TestCase class
|
|
4
|
-
module TestModeMethods
|
|
5
|
-
def self.included( base )
|
|
6
|
-
base.extend( TestModeMethods::ClassMethods )
|
|
7
|
-
base.send( :include, TestModeMethods::InstanceMethods)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def ClassMethods
|
|
11
|
-
def set_test_mode( mode = true )
|
|
12
|
-
self.const_set( :FWT_TEST_MODE, mode )
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Originally named test_mode?(), but Test::Unit::TestCase picked up on the fact that it started with "test"
|
|
16
|
-
# and tried to run it as a test in its own right
|
|
17
|
-
def in_test_mode?
|
|
18
|
-
return self::FWT_TEST_MODE if self.constants.include?( :FWT_TEST_MODE )
|
|
19
|
-
return self.superclass.in_test_mode? if self.superclass.respond_to?(:in_test_mode?)
|
|
20
|
-
return false
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def InstanceMethods
|
|
25
|
-
def in_test_mode?
|
|
26
|
-
self.class.in_test_mode?
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
data/test/test_test_mode.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# require 'helper'
|
|
2
|
-
#
|
|
3
|
-
# module FunWith
|
|
4
|
-
# module Testing
|
|
5
|
-
# class TestTestMode < FunWith::Testing::MyTestCase
|
|
6
|
-
# # TODO: "test mode" applies to gems, not to TestCases so this whole concept needs to be moved to FW::Gems
|
|
7
|
-
# _context "testing in_test_mode?" do
|
|
8
|
-
# setup do
|
|
9
|
-
# extended_test_case
|
|
10
|
-
# @gem_to_test = Module.new
|
|
11
|
-
# end
|
|
12
|
-
#
|
|
13
|
-
# should "set into test mode by default" do
|
|
14
|
-
# @case_class.set_test_mode
|
|
15
|
-
# assert @case.in_test_mode?
|
|
16
|
-
# end
|
|
17
|
-
#
|
|
18
|
-
# should "explicitly set to false" do
|
|
19
|
-
# @case_class.set_test_mode( false )
|
|
20
|
-
# assert @case.in_test_mode? == false
|
|
21
|
-
# end
|
|
22
|
-
#
|
|
23
|
-
# should "return false when no gem is set" do
|
|
24
|
-
# assert @case.in_test_mode? == false
|
|
25
|
-
# end
|
|
26
|
-
# end
|
|
27
|
-
# end
|
|
28
|
-
# end
|
|
29
|
-
# end
|