matchbox 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ # Gem-specific
21
+ Gemfile.lock
@@ -0,0 +1,7 @@
1
+ script: 'rake test'
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - ree
6
+ - rbx
7
+ - jruby
@@ -0,0 +1,6 @@
1
+ --readme README.md
2
+ --markup markdown
3
+ --markup-provider maruku
4
+ --default-return ""
5
+ --title "Matchbox Documentation"
6
+ --hide-void-return
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Alexander Kern
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # matchbox - use RSpec and Shoulda matchers in Test::Unit [![StillMaintained Status](http://stillmaintained.com/CapnKernul/matchbox.png)](http://stillmaintained.com/CapnKernul/matchbox) [![Build Status](http://travis-ci.org/CapnKernul/matchbox.png)](http://travis-ci.org/CapnKernul/matchbox) #
2
+
3
+ Matchbox allows you to use RSpec and Shoulda matchers as regular, old
4
+ `Test::Unit` assertions.
5
+
6
+ ## Installation ##
7
+
8
+ Without bundler:
9
+
10
+ gem install matchbox
11
+
12
+ With bundler:
13
+
14
+ gem 'matchbox'
15
+
16
+ ## Usage ##
17
+
18
+ Just include the RSpec matchers into the `TestCase` and they can be used as seen
19
+ below. This example uses methods found in
20
+ [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers).
21
+
22
+ class PostTest < Test::Unit::TestCase
23
+ def test_active_record_relations
24
+ post = Post.new
25
+ assert_accepts belong_to(:topic), post
26
+ end
27
+ end
28
+
29
+ ## Note on Patches/Pull Requests ##
30
+
31
+ * Fork the project.
32
+ * Make your feature addition or bug fix.
33
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
34
+ * Commit, but do not mess with the `Rakefile`. If you want to have your own version, that is fine but bump the version in a commit by itself in another branch so I can ignore it when I pull.
35
+ * Send me a pull request. Bonus points for git flow feature branches.
36
+
37
+ ## Resources ##
38
+
39
+ * [GitHub Repository](https://github.com/CapnKernul/matchbox)
40
+ * [Documentation](http://rubydoc.info/github/CapnKernul/matchbox)
41
+
42
+ ## License ##
43
+
44
+ Matchbox is licensed under the MIT License. See `LICENSE` for details.
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ task :default => 'test:unit'
5
+
6
+ require 'rake/testtask'
7
+ Rake::TestTask.new('test:unit') do |t|
8
+ t.ruby_opts += ['-rubygems']
9
+ t.libs << 'test'
10
+ t.pattern = 'test/test_*.rb'
11
+ end
@@ -0,0 +1,43 @@
1
+ # Test::Unit assertions for RSpec and Shoulda matchers.
2
+ #
3
+ # I created this since:
4
+ #
5
+ # * I like assertions, not the Shoulda "should" statements.
6
+ # * I want to use `shoulda-matchers` in my Rails project.
7
+ # * I'm in love with the simplicity of the contest gem.
8
+ #
9
+ # These methods are based upon those found in shoulda-context.
10
+ #
11
+ # With shoulda-matchers, it can be used like so:
12
+ #
13
+ # class PostTest < Test::Unit::TestCase
14
+ # def test_active_record_relations
15
+ # post = Post.new
16
+ # assert_accepts belong_to(:topic), post
17
+ # end
18
+ # end
19
+ module Matchbox
20
+ # Asserts that a matcher matches a given target.
21
+ #
22
+ # @param [#failure_message && #matches?] matcher
23
+ # @param [Object] target
24
+ # @raises [Test::Unit::AssertionFailedError] if the assertion fails
25
+ def assert_accepts(matcher, target)
26
+ matched = matcher.matches?(target)
27
+ assert_block(matcher.failure_message) { matched }
28
+ end
29
+
30
+ # Asserts that a matcher does not match a given target.
31
+ #
32
+ # @param [#negative_failure_message && #matches?] matcher
33
+ # @param [Object] target
34
+ # @raises [Test::Unit::AssertionFailedError] if the assertion fails
35
+ def assert_rejects(matcher, target)
36
+ matched = matcher.matches?(target)
37
+ assert_block(matcher.negative_failure_message) { !matched }
38
+ end
39
+ end
40
+
41
+ class Test::Unit::TestCase
42
+ include Matchbox
43
+ end
@@ -0,0 +1,3 @@
1
+ module Matchbox
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'matchbox/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'matchbox'
7
+ s.version = Matchbox::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Alexander Kern']
10
+ s.email = ['alex@kernul.com']
11
+ s.homepage = 'https://github.com/CapnKernul/matchbox'
12
+ s.summary = %q{Use RSpec and Shoulda matchers in Test::Unit}
13
+ s.description = %q{Adds Test::Unit assertions for RSpec and Shoulda matchers}
14
+
15
+ s.rubyforge_project = 'matchbox'
16
+
17
+ s.add_development_dependency 'test-unit'
18
+ s.add_development_dependency 'contest'
19
+ s.add_development_dependency 'mocha'
20
+ s.add_development_dependency 'yard'
21
+ s.add_development_dependency 'maruku'
22
+
23
+ s.files = `git ls-files`.split("\n")
24
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
+ s.require_paths = ['lib']
27
+ end
@@ -0,0 +1,5 @@
1
+ require 'bundler/setup'
2
+ require 'test/unit'
3
+ require 'contest'
4
+ require 'mocha'
5
+ require 'matchbox'
@@ -0,0 +1,55 @@
1
+ require 'test_helper'
2
+
3
+ class TestMatchbox < Test::Unit::TestCase
4
+ context '#assert_accepts' do
5
+ test 'successful assertion' do
6
+ target = mock('target')
7
+ matcher = mock('matcher') do
8
+ expects(:matches?).with(target).returns(true)
9
+ expects(:failure_message).returns('bad failure message')
10
+ end
11
+
12
+ assert_nothing_raised do
13
+ assert_accepts matcher, target
14
+ end
15
+ end
16
+
17
+ test 'unsuccessful assertion' do
18
+ target = mock('target')
19
+ matcher = mock('matcher') do
20
+ expects(:matches?).with(target).returns(false)
21
+ expects(:failure_message).returns('bad failure message')
22
+ end
23
+
24
+ assert_raise Test::Unit::AssertionFailedError do
25
+ assert_accepts matcher, target
26
+ end
27
+ end
28
+ end
29
+
30
+ context '#assert_rejects' do
31
+ test 'successful assertion' do
32
+ target = mock('target')
33
+ matcher = mock('matcher') do
34
+ expects(:matches?).with(target).returns(false)
35
+ expects(:negative_failure_message).returns('bad failure message')
36
+ end
37
+
38
+ assert_nothing_raised do
39
+ assert_rejects matcher, target
40
+ end
41
+ end
42
+
43
+ test 'unsuccessful assertion' do
44
+ target = mock('target')
45
+ matcher = mock('matcher') do
46
+ expects(:matches?).with(target).returns(true)
47
+ expects(:negative_failure_message).returns('bad failure message')
48
+ end
49
+
50
+ assert_raise Test::Unit::AssertionFailedError do
51
+ assert_rejects matcher, target
52
+ end
53
+ end
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: matchbox
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Alexander Kern
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-09 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: test-unit
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: contest
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: mocha
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: yard
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: maruku
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ version_requirements: *id005
70
+ description: Adds Test::Unit assertions for RSpec and Shoulda matchers
71
+ email:
72
+ - alex@kernul.com
73
+ executables: []
74
+
75
+ extensions: []
76
+
77
+ extra_rdoc_files: []
78
+
79
+ files:
80
+ - .gitignore
81
+ - .travis.yml
82
+ - .yardopts
83
+ - Gemfile
84
+ - LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - lib/matchbox.rb
88
+ - lib/matchbox/version.rb
89
+ - matchbox.gemspec
90
+ - test/test_helper.rb
91
+ - test/test_matchbox.rb
92
+ homepage: https://github.com/CapnKernul/matchbox
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options: []
97
+
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ requirements: []
113
+
114
+ rubyforge_project: matchbox
115
+ rubygems_version: 1.8.1
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: Use RSpec and Shoulda matchers in Test::Unit
119
+ test_files:
120
+ - test/test_helper.rb
121
+ - test/test_matchbox.rb