fun_with_testing 0.0.1 → 0.0.3
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 +8 -8
- data/Gemfile +15 -5
- data/README.rdoc +10 -1
- data/VERSION +1 -1
- data/lib/fun_with/testing/assertions/active_record.rb +1 -1
- data/lib/fun_with/testing/assertions/fun_with_files.rb +2 -1
- data/lib/fun_with/testing/test_case.rb +73 -0
- data/lib/fun_with_testing.rb +2 -0
- data/test/helper.rb +19 -8
- data/test/test_assertions.rb +1 -1
- data/test/test_fun_with_testing.rb +10 -4
- data/test/test_test_mode.rb +28 -0
- data/test/test_verbosity.rb +27 -0
- metadata +43 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Mzk5MWIxMzYyMzAzMWMzNDIyN2Y3ZTQzMWIxNGFiYTZhMzQxNWVhNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTA2ZDQ4MzlhZjAxNGU2ZDg1N2VkNjBiMDc3YTNkOGE3OGE4MjBhZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWZlNTNiZGVjZDQ5ZjllZDVhYmJjNmVlYmEyY2ZhNThjNTI5NjViZTQyMmNl
|
10
|
+
YzUxOTQ5NDNmZTM4OTY1YTliZDE4ZWUzZGYzNGZhNDAyODMxMTdmMjYwNDdh
|
11
|
+
ZDIyYmQ2MGM3NmQ4NTkxYmNlNmFiYjIxNmFjNWRjMWI3MGU1YjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWFlYzZlNDQ4YzM5Y2JiMmJkNzJkMTUzZDQ0MDM0Y2EyMmIxZDc4OWRmNjg1
|
14
|
+
N2IzYTEzNzI2MzE3MTJiNmQ1YzljMGVmMzBmZDMwY2UwYjFiNjZhOWQ1ODE4
|
15
|
+
MTBkMjQwNzdjZWE2YjY5ZTAyYjA4Nzg3NWM0MzljMDM3Y2NhZGY=
|
data/Gemfile
CHANGED
@@ -6,9 +6,19 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem "shoulda", ">= 3.5"
|
10
|
-
gem "rdoc", "~> 3.12"
|
11
|
-
gem "bundler", "~> 1.0"
|
12
|
-
gem "jeweler", "~> 2.0"
|
13
|
-
# gem "rcov", ">= 0"
|
9
|
+
# gem "shoulda", "~> 3", ">= 3.5"
|
10
|
+
# gem "rdoc", "~> 3.12"
|
11
|
+
# gem "bundler", "~> 1.0"
|
12
|
+
# gem "jeweler", "~> 2.0"
|
13
|
+
# # gem "rcov", ">= 0"
|
14
|
+
# gem 'debugger', "~> 1.6"
|
15
|
+
# gem 'minitest'
|
14
16
|
end
|
17
|
+
|
18
|
+
gem "shoulda", "~> 3", ">= 3.5"
|
19
|
+
gem "rdoc", "~> 3.12"
|
20
|
+
gem "bundler", "~> 1.0"
|
21
|
+
gem "jeweler", "~> 2.0"
|
22
|
+
# gem "rcov", ">= 0"
|
23
|
+
gem 'debugger', "~> 1.6"
|
24
|
+
gem 'minitest', "~> 5"
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= fun_with_testing
|
2
2
|
|
3
|
-
A bunch of useful assertions.
|
3
|
+
A bunch of useful assertions, and a subclass of Test::Unit::TestCase for my gems to derive from.
|
4
4
|
|
5
5
|
Usage:
|
6
6
|
|
@@ -24,6 +24,15 @@ Then in test/test_gem.rb:
|
|
24
24
|
end
|
25
25
|
|
26
26
|
|
27
|
+
In the FunWith gems, gem tests use a subclass of FunWith::Testing::TestCase, a subclass of Test::Unit::TestCase
|
28
|
+
with some helpful methods.
|
29
|
+
|
30
|
+
#_should() : ignores the inner block, instead prints a message warning that the test is being skipped
|
31
|
+
#_context() : ignores the inner block, instead prints a message warning that the set of tests is being skipped.
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
27
36
|
== Contributing to fun_with_testing
|
28
37
|
|
29
38
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -23,7 +23,7 @@ module FunWith
|
|
23
23
|
if @response.error?
|
24
24
|
puts @response.body
|
25
25
|
elsif @response.redirect?
|
26
|
-
raise
|
26
|
+
raise Minitest::Unit::AssertionFailedError.new( "Expected success, was redirect to #{@response.redirected_to} with flash #{flash}" )
|
27
27
|
end
|
28
28
|
|
29
29
|
assert_response :success
|
@@ -57,7 +57,6 @@ module FunWith
|
|
57
57
|
|
58
58
|
message = build_message( message, "Empty file should exist at <#{file}>." )
|
59
59
|
|
60
|
-
|
61
60
|
assert_block message do
|
62
61
|
file.exist? && file.empty?
|
63
62
|
end
|
@@ -82,6 +81,8 @@ module FunWith
|
|
82
81
|
file.exist? && !file.empty?
|
83
82
|
end
|
84
83
|
end
|
84
|
+
|
85
|
+
alias :assert_file_not_empty :assert_file_has_content
|
85
86
|
|
86
87
|
def assert_file_contents( file, content, message = "" )
|
87
88
|
assert_file( file )
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module FunWith
|
2
|
+
module Testing
|
3
|
+
class TestCase < Minitest::Test
|
4
|
+
# I may eventually decide that there's a reason to specify which
|
5
|
+
# gem is being tested, but this really wasn't it.
|
6
|
+
#
|
7
|
+
# Okay, that was stupid. The point was to allow verbosity to be specified in the gem's code,
|
8
|
+
# not just in the test suite. What would that be... MyGem.test_mode? MyGem.verbose_gem? MyGem.say
|
9
|
+
def self.gem_to_test( gem_const = nil, test_mode = true )
|
10
|
+
if @fwt_gem_to_test
|
11
|
+
return @fwt_gem_to_test
|
12
|
+
elsif self.superclass.respond_to?( :gem_to_test )
|
13
|
+
self.superclass.gem_to_test
|
14
|
+
else
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.gem_to_test=( gem_const )
|
20
|
+
@fwt_gem_to_test = gem_const
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.set_test_mode( mode = true )
|
24
|
+
self.const_set( :FWT_TEST_MODE, mode )
|
25
|
+
end
|
26
|
+
|
27
|
+
# Originally named test_mode?(), but Test::Unit::TestCase picked up on the fact that it started with "test"
|
28
|
+
# and tried to run it as a test in its own right
|
29
|
+
def self.in_test_mode?
|
30
|
+
return self::FWT_TEST_MODE if self.constants.include?( :FWT_TEST_MODE )
|
31
|
+
return self.superclass.in_test_mode? if self.superclass.respond_to?(:in_test_mode?)
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
|
35
|
+
def in_test_mode?
|
36
|
+
self.class.in_test_mode?
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.set_verbose( mode = true )
|
40
|
+
self.const_set( :FWT_TEST_VERBOSITY, mode )
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.verbose?
|
44
|
+
return self::FWT_TEST_VERBOSITY if self.constants.include?( :FWT_TEST_VERBOSITY )
|
45
|
+
return self.superclass.verbose? if self.superclass.respond_to?(:verbose)
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
|
49
|
+
def verbose?
|
50
|
+
self.class.verbose?
|
51
|
+
end
|
52
|
+
|
53
|
+
def puts_if_verbose( msg, stream = $stdout )
|
54
|
+
stream.puts( msg ) if self.verbose?
|
55
|
+
end
|
56
|
+
|
57
|
+
# Convenience methods for disappearing a set of tests. Useful for focusing on one or two tests.
|
58
|
+
def self._context(*args, &block)
|
59
|
+
puts "<<< WARNING >>> IGNORING TEST SET #{args.inspect}. Remove leading _ from '_context()' to reactivate."
|
60
|
+
end
|
61
|
+
|
62
|
+
def self._should(*args, &block)
|
63
|
+
puts "<<< WARNING >>> IGNORING TEST #{args.inspect}. Remove leading _ from '_should()' to reactivate."
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_gem_validity
|
67
|
+
if self.class.gem_to_test
|
68
|
+
assert self.class.gem_to_test.gem_valid?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/fun_with_testing.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require 'rubygems'
|
1
|
+
# require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
+
require 'debugger'
|
3
4
|
|
4
5
|
begin
|
5
6
|
Bundler.setup(:default, :development)
|
@@ -8,35 +9,45 @@ rescue Bundler::BundlerError => e
|
|
8
9
|
$stderr.puts "Run `bundle install` to install missing gems"
|
9
10
|
exit e.status_code
|
10
11
|
end
|
11
|
-
|
12
|
+
|
13
|
+
# require 'test/unit'
|
14
|
+
require 'minitest'
|
15
|
+
require 'minitest/autorun'
|
12
16
|
require 'shoulda'
|
13
17
|
|
14
18
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
19
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
|
+
|
21
|
+
|
16
22
|
require 'fun_with_testing'
|
17
23
|
|
18
|
-
class Test
|
19
|
-
end
|
24
|
+
# class Minitest::Test
|
25
|
+
# end
|
20
26
|
|
21
27
|
# Any subclass of Test::Unit::TestCase seems to automatically hook into the test suite.
|
22
28
|
# Therefore, calling a test to see if it returns false makes the suite fail. Including
|
23
29
|
# to this class instead prevents that. I may need to more closely mimic Test::Unit::TestCase
|
24
30
|
# in order to test messages properly.
|
25
|
-
class MockUnitTest
|
31
|
+
class MockUnitTest < FunWith::Testing::TestCase
|
26
32
|
def build_message( m, m2, obj = nil)
|
27
33
|
"#{m} #{m2} #{obj}"
|
28
34
|
end
|
29
35
|
|
30
|
-
def assert_block(
|
36
|
+
def assert_block( *args, &block )
|
31
37
|
yield
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
35
|
-
class FunWith::Testing::
|
41
|
+
class FunWith::Testing::MyTestCase < FunWith::Testing::TestCase
|
36
42
|
def extended_test_case( &block )
|
37
43
|
@case_class = Class.new( MockUnitTest )
|
38
44
|
@case_class.send( :include, FunWith::Testing )
|
39
|
-
@case = @case_class.new
|
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
|
+
|
40
51
|
yield if block_given?
|
41
52
|
end
|
42
53
|
end
|
data/test/test_assertions.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
|
4
|
-
class TestFunWithTesting < FunWith::Testing::
|
4
|
+
class TestFunWithTesting < FunWith::Testing::MyTestCase
|
5
5
|
should "be plumbed properly" do
|
6
6
|
assert defined?( FunWith::Testing::Assertions )
|
7
7
|
assert defined?( FunWith::Testing::Assertions::ActiveRecord )
|
@@ -14,18 +14,24 @@ class TestFunWithTesting < FunWith::Testing::TestCase
|
|
14
14
|
assert_includes( FunWith::Testing::Assertions::ActiveRecord.instance_methods, :assert_no_errors_on )
|
15
15
|
end
|
16
16
|
|
17
|
+
should "have test/unit on board" do
|
18
|
+
assert( defined?( Minitest ), "problem loading Minitest" )
|
19
|
+
assert( defined?( Minitest::Test ), "problem loading Minitest" )
|
20
|
+
end
|
21
|
+
|
17
22
|
should "access a listing of assertion modules" do
|
18
23
|
assert_includes( FunWith::Testing.included_modules, FunWith::Testing::Assertions::ActiveRecord )
|
19
24
|
assert_includes( FunWith::Testing.included_modules, FunWith::Testing::Assertions::Basics )
|
20
25
|
end
|
21
26
|
|
22
27
|
should "successfully get included in a subclass" do
|
23
|
-
klass = Class.new(
|
28
|
+
klass = Class.new( Minitest::Unit )
|
24
29
|
|
25
30
|
imethods = klass.instance_methods.select{|sym| sym.to_s =~ /^(assert|refute)_/ }
|
26
|
-
|
31
|
+
|
32
|
+
refute_includes imethods, :assert_zero
|
27
33
|
klass.send( :include, FunWith::Testing )
|
28
34
|
imethods = klass.instance_methods.select{|sym| sym.to_s =~ /^(assert|refute)_/ }
|
29
|
-
|
35
|
+
assert_includes( imethods, :assert_zero )
|
30
36
|
end
|
31
37
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module FunWith
|
4
|
+
module Testing
|
5
|
+
class TestTestMode < FunWith::Testing::MyTestCase
|
6
|
+
context "testing in_test_mode?" do
|
7
|
+
setup do
|
8
|
+
extended_test_case
|
9
|
+
@gem_to_test = Module.new
|
10
|
+
end
|
11
|
+
|
12
|
+
should "set into test mode by default" do
|
13
|
+
@case_class.set_test_mode
|
14
|
+
assert @case.in_test_mode?
|
15
|
+
end
|
16
|
+
|
17
|
+
should "explicitly set to false" do
|
18
|
+
@case_class.set_test_mode( false )
|
19
|
+
assert @case.in_test_mode? == false
|
20
|
+
end
|
21
|
+
|
22
|
+
should "return false when no gem is set" do
|
23
|
+
assert @case.in_test_mode? == false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module FunWith
|
4
|
+
module Testing
|
5
|
+
class TestVerbosity < FunWith::Testing::MyTestCase
|
6
|
+
context "testing in_test_mode?" do
|
7
|
+
setup do
|
8
|
+
extended_test_case
|
9
|
+
end
|
10
|
+
|
11
|
+
should "set into verbose by default" do
|
12
|
+
@case_class.set_verbose
|
13
|
+
assert @case.verbose?
|
14
|
+
end
|
15
|
+
|
16
|
+
should "explicitly set to false" do
|
17
|
+
@case_class.set_verbose( false )
|
18
|
+
assert @case.verbose? == false
|
19
|
+
end
|
20
|
+
|
21
|
+
should "return false when set_verbose() hasn't been called" do
|
22
|
+
assert @case.verbose? == false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|
@@ -17,13 +17,19 @@ dependencies:
|
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.5'
|
20
|
-
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
23
|
+
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.5'
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rdoc
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,7 +37,7 @@ dependencies:
|
|
31
37
|
- - ~>
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '3.12'
|
34
|
-
type: :
|
40
|
+
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
@@ -45,7 +51,7 @@ dependencies:
|
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '1.0'
|
48
|
-
type: :
|
54
|
+
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
@@ -59,13 +65,41 @@ dependencies:
|
|
59
65
|
- - ~>
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '2.0'
|
62
|
-
type: :
|
68
|
+
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - ~>
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '2.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: debugger
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.6'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.6'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: minitest
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '5'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '5'
|
69
103
|
description: A place to stash Test::Unit assertions I've found handy. Use at your
|
70
104
|
own risk
|
71
105
|
email: keeputahweird@gmail.com
|
@@ -78,10 +112,13 @@ files:
|
|
78
112
|
- ./lib/fun_with/testing/assertions/active_record.rb
|
79
113
|
- ./lib/fun_with/testing/assertions/basics.rb
|
80
114
|
- ./lib/fun_with/testing/assertions/fun_with_files.rb
|
115
|
+
- ./lib/fun_with/testing/test_case.rb
|
81
116
|
- ./lib/fun_with_testing.rb
|
82
117
|
- ./test/helper.rb
|
83
118
|
- ./test/test_assertions.rb
|
84
119
|
- ./test/test_fun_with_testing.rb
|
120
|
+
- ./test/test_test_mode.rb
|
121
|
+
- ./test/test_verbosity.rb
|
85
122
|
- CHANGELOG.markdown
|
86
123
|
- Gemfile
|
87
124
|
- LICENSE.txt
|