minitest-around 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg
5
+ rdoc
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm @minitest-around --create
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - ree
4
+ - 1.9.3
5
+ - jruby-18mode
6
+ - jruby-19mode
7
+ - rbx-18mode
8
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+
5
+ # Specify your gem's dependencies in minitest-around.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Peter Suschlik
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,87 @@
1
+ = minitest-around {<img src="https://secure.travis-ci.org/splattael/minitest-around.png?branch=master" alt="Build Status" />}[http://travis-ci.org/splattael/minitest-around]
2
+
3
+ Around block for minitest.
4
+
5
+ Alternative for setup/teardown dance.
6
+
7
+ Gem[https://rubygems.org/gems/minitest-around] |
8
+ Source[https://github.com/splattael/minitest-around] |
9
+ RDoc[http://rubydoc.info/github/splattael/minitest-around/master/file/README.rdoc]
10
+
11
+ == Installation
12
+
13
+ gem install minitest-around
14
+
15
+ == Usage
16
+
17
+ === Unit tests
18
+
19
+ require 'minitest/autorun'
20
+ require 'minitest/around'
21
+
22
+ class MutexTest < MiniTest::Unit::TestCase
23
+ def around(&block)
24
+ Mutex.new.synchronize(&block)
25
+ end
26
+
27
+ def test_synchronized
28
+ # ...
29
+ end
30
+ end
31
+
32
+ class PassArgsTest < MiniTest::Unit::TestCase
33
+ def around
34
+ yield 1, 2
35
+ end
36
+
37
+ def test_passes_args(a, b)
38
+ assert_equal 3, a + b
39
+ end
40
+ end
41
+
42
+ === Spec
43
+
44
+ require 'minitest/autorun'
45
+ require 'minitest/around'
46
+
47
+ describe "Mutex" do
48
+ around do |test|
49
+ Mutex.new.synchronize(&test)
50
+ end
51
+
52
+ it "synchronized" do
53
+ # ...
54
+ end
55
+
56
+ describe "pass args" do
57
+ around do
58
+ # No block arg "test",
59
+ [ 1, 2 ]
60
+ end
61
+
62
+ it "passes args" do |a, b|
63
+ (a + b).must_equal 3
64
+ end
65
+ end
66
+ end
67
+
68
+ == Caveats
69
+
70
+ Test bodies won't be run if you don't *yield* inside +around+.
71
+
72
+ == Contributing
73
+
74
+ 1. Fork it
75
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
76
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
77
+ 4. Push to the branch (`git push origin my-new-feature`)
78
+ 5. Create new Pull Request
79
+
80
+ == Test
81
+
82
+ bundle exec rake test
83
+
84
+ == Release
85
+
86
+ edit lib/minitest/around/version.rb
87
+ rake release
@@ -0,0 +1,21 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ desc 'Default: run unit tests.'
4
+ task :default => :test
5
+
6
+ # Test
7
+ require 'rake/testtask'
8
+ Rake::TestTask.new(:test) do |test|
9
+ test.test_files = FileList.new('test/*_{test,spec}.rb')
10
+ test.libs << 'test'
11
+ test.verbose = true
12
+ end
13
+
14
+ # RDoc
15
+ require 'rdoc/task'
16
+ RDoc::Task.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'mintest-around'
19
+ rdoc.main = 'README.rdoc'
20
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'lib/**/*.rb')
21
+ end
@@ -0,0 +1,23 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/around'
3
+
4
+ describe "Mutex" do
5
+ around do |test|
6
+ Mutex.new.synchronize(&test)
7
+ end
8
+
9
+ it "synchronized" do
10
+ # ...
11
+ end
12
+
13
+ describe "pass args" do
14
+ around do
15
+ # No block arg "test",
16
+ [ 1, 2 ]
17
+ end
18
+
19
+ it "passes args" do |a, b|
20
+ (a + b).must_equal 3
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/around'
3
+
4
+ class MutexTest < MiniTest::Unit::TestCase
5
+ def around(&block)
6
+ Mutex.new.synchronize(&block)
7
+ end
8
+
9
+ def test_synchronized
10
+ # ...
11
+ end
12
+ end
13
+
14
+ class PassArgsTest < MiniTest::Unit::TestCase
15
+ def around
16
+ yield 1, 2
17
+ end
18
+
19
+ def test_passes_args(a, b)
20
+ assert_equal 3, a + b
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'minitest/around/version'
2
+
3
+ class MiniTest::Unit::TestCase
4
+ def run_test(name)
5
+ if defined?(around)
6
+ around { |*args| __send__(name, *args) }
7
+ else
8
+ __send__(name)
9
+ end
10
+ end
11
+ end
12
+
13
+ class MiniTest::Spec
14
+ def self.around(&outer)
15
+ define_method(:around) do |&inner|
16
+ if outer.arity == 1
17
+ outer.call(inner)
18
+ else
19
+ inner.call *outer.call
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module MiniTest
2
+ module Around
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'minitest/around/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "minitest-around"
7
+ s.version = MiniTest::Around::VERSION
8
+ s.authors = ["Peter Suschlik"]
9
+ s.email = ["peter-minitest-around@suschlik.de"]
10
+ s.homepage = ""
11
+ s.summary = %q{Around block for minitest.}
12
+ s.description = %q{Alternative for setup/teardown dance.}
13
+
14
+ s.rubyforge_project = "minitest-around"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'minitest', '>= 2.8.0'
22
+
23
+ s.add_development_dependency 'rdoc'
24
+ end
@@ -0,0 +1,45 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/around'
3
+
4
+ describe "MiniTest Around" do
5
+ describe "without around" do
6
+ it "works w/o defining parameters" do
7
+ assert true
8
+ end
9
+ end
10
+
11
+ describe "without args" do
12
+ around do |test|
13
+ $before = true
14
+ test.call
15
+ $before = false
16
+ end
17
+
18
+ it "runs around" do
19
+ $before.must_equal true
20
+ end
21
+ end
22
+
23
+ describe "with single arg" do
24
+ around { "string" }
25
+
26
+ it "passes string argument" do |name|
27
+ name.must_equal "string"
28
+ end
29
+
30
+ describe "nested" do
31
+ it "string is still around" do |name|
32
+ name.must_equal "string"
33
+ end
34
+ end
35
+
36
+ describe "with multiple args" do
37
+ around { [ 1, 2 ] }
38
+
39
+ it "passes multiple args" do |a, b|
40
+ a.must_equal 1
41
+ b.must_equal 2
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/around'
3
+
4
+ class TestWithoutAround < MiniTest::Unit::TestCase
5
+ def test_no_around_defined
6
+ assert true
7
+ end
8
+ end
9
+
10
+ class TestWithoutArgs < MiniTest::Unit::TestCase
11
+ def around
12
+ $before = true
13
+ yield
14
+ $before = false # hard to test?
15
+ end
16
+
17
+ def test_runs_around
18
+ assert_equal true, $before
19
+ end
20
+ end
21
+
22
+ class TestWithSingleArg < MiniTest::Unit::TestCase
23
+ def around
24
+ yield "string"
25
+ end
26
+
27
+ def test_around_passes_string(string)
28
+ assert_equal "string", string
29
+ end
30
+ end
31
+
32
+ class TestWithMultipleArgs < MiniTest::Unit::TestCase
33
+ def around
34
+ yield 1, 2
35
+ end
36
+
37
+ def test_passes_multiple_args(a, b)
38
+ assert_equal 1, a
39
+ assert_equal 2, b
40
+ end
41
+ end
42
+
43
+ class SpecWithAround < MiniTest::Spec
44
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-around
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Peter Suschlik
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.8.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.8.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Alternative for setup/teardown dance.
47
+ email:
48
+ - peter-minitest-around@suschlik.de
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rvmrc
55
+ - .travis.yml
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.rdoc
59
+ - Rakefile
60
+ - examples/mutex_spec.rb
61
+ - examples/mutex_test.rb
62
+ - lib/minitest/around.rb
63
+ - lib/minitest/around/version.rb
64
+ - minitest-around.gemspec
65
+ - test/around_spec.rb
66
+ - test/around_test.rb
67
+ homepage: ''
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project: minitest-around
87
+ rubygems_version: 1.8.24
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Around block for minitest.
91
+ test_files: []