minitest-context 0.2.0 → 0.3.0
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.
- data/.travis.yml +5 -0
- data/README.md +6 -6
- data/Rakefile +5 -13
- data/lib/minitest/context.rb +9 -11
- data/lib/minitest/context/version.rb +1 -1
- data/lib/minitest/ext/spec.rb +6 -5
- data/{spec → test}/contexts/before_block_context.rb +0 -0
- data/{spec → test}/contexts/stacked_context.rb +0 -0
- data/{spec/minitest_context_spec.rb → test/minitest_context_test.rb} +8 -8
- data/{spec/spec_helper.rb → test/setup.rb} +1 -1
- metadata +16 -16
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -10,10 +10,10 @@ __OVERVIEW__
|
|
10
10
|
|
11
11
|
__DESCRIPTION__
|
12
12
|
|
13
|
-
minitest
|
13
|
+
minitest-context can define contexts for code reuse in minitest specs that share common expectations.
|
14
14
|
The idea orginated from the `shared_context()` and `include_context()` methods distributed with RSpec.
|
15
15
|
|
16
|
-
|
16
|
+
minitest supports code re-use in minitest specs already, via a subclass of MiniTest::Spec.
|
17
17
|
You might want to look at that option, if you didn't know about it already.
|
18
18
|
|
19
19
|
__EXAMPLES__
|
@@ -28,8 +28,8 @@ __EXAMPLES__
|
|
28
28
|
inherit_context :operand
|
29
29
|
|
30
30
|
it "should perform addition on the operand." do
|
31
|
-
|
32
|
-
|
31
|
+
result = @operand + 10
|
32
|
+
result.must_equal(50)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -37,8 +37,8 @@ __EXAMPLES__
|
|
37
37
|
inherit_context :operand
|
38
38
|
|
39
39
|
it "should perform subtraction on the operand." do
|
40
|
-
|
41
|
-
|
40
|
+
result = @operand - 10
|
41
|
+
result.must_equal(30)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
data/Rakefile
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
namespace :gem do
|
10
|
-
desc "Release a new version"
|
11
|
-
task :release do
|
12
|
-
`gem build minitest-context.gemspec`
|
13
|
-
`gem push minitest-context-#{MiniTest::Context::VERSION}.gem`
|
14
|
-
end
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.name = :test
|
6
|
+
t.test_files = FileList["test/*.rb"]
|
15
7
|
end
|
16
8
|
|
17
9
|
task :default => :test
|
data/lib/minitest/context.rb
CHANGED
@@ -9,30 +9,28 @@ module MiniTest::Context
|
|
9
9
|
# @private
|
10
10
|
attr_reader :list
|
11
11
|
|
12
|
-
# Define a context for re-use in a subclass of MiniTest::Spec.
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
13
|
+
# Defines a context.
|
14
|
+
#
|
15
|
+
# @example
|
16
16
|
# MiniTest::Context.define(:example) do
|
17
|
-
# before
|
18
|
-
# puts "Hello, world!"
|
19
|
-
# end
|
17
|
+
# before { puts "Hello, world!" }
|
20
18
|
# end
|
21
19
|
#
|
22
20
|
# @param [Symbol] name
|
23
21
|
# The name of the context to define.
|
24
22
|
#
|
25
|
-
# @param [Proc]
|
26
|
-
#
|
27
|
-
# through {MiniTest::Spec.inherit_context inherit_context}.
|
23
|
+
# @param [Proc] block
|
24
|
+
# Evaluated in a subclass of MiniTest::Spec through {MiniTest::Spec.inherit_context}.
|
28
25
|
#
|
29
26
|
# @raise [ArgumentError]
|
30
|
-
# Raises an ArgumentError if
|
27
|
+
# Raises an ArgumentError if block is missing.
|
31
28
|
#
|
32
29
|
# @return [void]
|
30
|
+
#
|
33
31
|
def define name, &block
|
34
32
|
raise ArgumentError, "Block expected." unless block_given?
|
35
|
-
@list
|
33
|
+
@list = @list || Hash.new { |h,k| h[k] = [] }
|
36
34
|
@list[name] << block
|
37
35
|
end
|
38
36
|
|
data/lib/minitest/ext/spec.rb
CHANGED
@@ -2,21 +2,22 @@ class MiniTest::Spec
|
|
2
2
|
|
3
3
|
class << self
|
4
4
|
|
5
|
-
# Evaluates a context by _name_ in the scope of a MiniTest::Spec subclass.
|
6
5
|
#
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# Evaluates a context by name.
|
7
|
+
#
|
8
|
+
# @example
|
9
9
|
# describe ExampleClass do
|
10
10
|
# inherit_context :example
|
11
11
|
# end
|
12
12
|
#
|
13
13
|
# @param [Symbol] name
|
14
|
-
# The name of a context
|
14
|
+
# The name of a context defined by {MiniTest::Context.define define}.
|
15
15
|
#
|
16
16
|
# @raise [ArgumentError]
|
17
|
-
# Raises an ArgumentError if a context by
|
17
|
+
# Raises an ArgumentError if a context by name does not exist.
|
18
18
|
#
|
19
19
|
# @return [void]
|
20
|
+
#
|
20
21
|
def inherit_context name
|
21
22
|
if MiniTest::Context.list.has_key?(name)
|
22
23
|
MiniTest::Context.list[name].each do |context|
|
File without changes
|
File without changes
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require File.expand_path("setup.rb", File.dirname(__FILE__))
|
2
2
|
|
3
3
|
describe "Contexts" do
|
4
|
-
describe "
|
4
|
+
describe "An inherited context." do
|
5
5
|
inherit_context :before_block
|
6
6
|
|
7
|
-
it "
|
7
|
+
it "must assign an Array to @example." do
|
8
8
|
@example.must_be_instance_of(Array)
|
9
9
|
end
|
10
10
|
end
|
@@ -13,13 +13,13 @@ describe "Contexts" do
|
|
13
13
|
inherit_context :before_block
|
14
14
|
|
15
15
|
describe "Suite 1" do
|
16
|
-
it "
|
16
|
+
it "must the inherit context from the parent suite." do
|
17
17
|
@example.must_be_instance_of(Array)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "Suite 2" do
|
22
|
-
it "
|
22
|
+
it "must the inherit context from the parent suite." do
|
23
23
|
@example.must_be_instance_of(Array)
|
24
24
|
end
|
25
25
|
end
|
@@ -28,20 +28,20 @@ describe "Contexts" do
|
|
28
28
|
describe "A stacked context." do
|
29
29
|
inherit_context :stacked_context
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "must execute all stacked contexts." do
|
32
32
|
@number.must_equal(2)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "MiniTest::Context.define" do
|
38
|
-
it "
|
38
|
+
it "must raise an ArgumentError when no block is recieved." do
|
39
39
|
proc { MiniTest::Context.define(:fail) }.must_raise(ArgumentError)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "MiniTest::Spec.inherit_context" do
|
44
|
-
it "
|
44
|
+
it "must raise an ArgumentError when no context by given name can be found." do
|
45
45
|
proc { MiniTest::Spec.inherit_context(:fail) }.must_raise(ArgumentError)
|
46
46
|
end
|
47
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &70313064995720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70313064995720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70313064994960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.9.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70313064994960
|
36
36
|
description: Defines contexts for code reuse in MiniTest specs that share common expectations.
|
37
37
|
email:
|
38
38
|
- rob@flowof.info
|
@@ -51,10 +51,10 @@ files:
|
|
51
51
|
- lib/minitest/context/version.rb
|
52
52
|
- lib/minitest/ext/spec.rb
|
53
53
|
- minitest-context.gemspec
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
54
|
+
- test/contexts/before_block_context.rb
|
55
|
+
- test/contexts/stacked_context.rb
|
56
|
+
- test/minitest_context_test.rb
|
57
|
+
- test/setup.rb
|
58
58
|
homepage: https://github.com/robgleeson/minitest-context
|
59
59
|
licenses: []
|
60
60
|
post_install_message:
|
@@ -69,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
segments:
|
71
71
|
- 0
|
72
|
-
hash: -
|
72
|
+
hash: -2902589455045483768
|
73
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
segments:
|
80
80
|
- 0
|
81
|
-
hash: -
|
81
|
+
hash: -2902589455045483768
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
84
|
rubygems_version: 1.8.10
|
@@ -86,7 +86,7 @@ signing_key:
|
|
86
86
|
specification_version: 3
|
87
87
|
summary: Defines contexts for code reuse in MiniTest specs that share common expectations.
|
88
88
|
test_files:
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
89
|
+
- test/contexts/before_block_context.rb
|
90
|
+
- test/contexts/stacked_context.rb
|
91
|
+
- test/minitest_context_test.rb
|
92
|
+
- test/setup.rb
|