minitest-matchers 1.1.0.rc2 → 1.1.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -7,14 +7,15 @@
7
7
  minitest-matchers adds support for RSpec/Shoulda-style matchers to
8
8
  minitest/unit and minitest/spec.
9
9
 
10
- A matcher is a class that must implement #description, #matches?,
11
- #failure_message and #negative_failure_message methods.
12
- Expactations are then builded using these methods.
10
+ More information about matchers can be found here:
11
+ * https://www.relishapp.com/rspec/rspec-expectations
12
+ * http://railscasts.com/episodes/157-rspec-matchers-macros
13
13
 
14
14
  == FEATURES/PROBLEMS:
15
15
 
16
16
  * Enables you to use existing matcher classes from projects like
17
- valid_attribute, (with some additional work) shoulda-matchers and remarkable.
17
+ valid_attribute and in the future shoulda-matchers and maybe even remarkable.
18
+ * Can be used both in MiniTest::Unit::TestCase & MiniTest::Spec
18
19
 
19
20
  == SYNOPSIS:
20
21
 
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ require "rubygems"
4
4
  require "hoe"
5
5
 
6
6
  Hoe.plugin :minitest
7
+ Hoe.plugin :gemspec
7
8
 
8
9
  Hoe.spec "minitest-matchers" do
9
10
  developer "Ryan Davis", "ryand-ruby@zenspider.com"
@@ -1,22 +1,7 @@
1
1
  require "minitest/spec"
2
2
 
3
3
  module MiniTest::Matchers
4
- VERSION = "1.1.0.rc2" # :nodoc:
5
-
6
- ##
7
- # Every matcher must respond to following methods:
8
- # - #description
9
- # - #matches?
10
- # - #failure_message
11
- # - #negative_failure_message
12
-
13
- def self.check_matcher matcher
14
- [:description, :matches?, :failure_message, :negative_failure_message].each do |m|
15
- unless matcher.respond_to? m
16
- fail "Matcher must respond to #{m}."
17
- end
18
- end
19
- end
4
+ VERSION = "1.1.0.rc3" # :nodoc:
20
5
  end
21
6
 
22
7
  module MiniTest
@@ -31,10 +16,15 @@ module MiniTest
31
16
  # end
32
17
 
33
18
  def assert_must matcher, subject, msg = nil
34
- MiniTest::Matchers.check_matcher matcher
35
19
  result = matcher.matches? subject
36
20
 
37
- msg = message(msg) { matcher.failure_message }
21
+ msg = message(msg) do
22
+ if matcher.respond_to? :negative_failure_message
23
+ matcher.negative_failure_message
24
+ else
25
+ matcher.failure_message_for_should
26
+ end
27
+ end
38
28
 
39
29
  assert result, msg
40
30
  end
@@ -49,10 +39,15 @@ module MiniTest
49
39
  # end
50
40
 
51
41
  def assert_wont matcher, subject, msg = nil
52
- MiniTest::Matchers.check_matcher matcher
53
42
  result = matcher.matches? subject
54
43
 
55
- msg = message(msg) { matcher.negative_failure_message }
44
+ msg = message(msg) do
45
+ if matcher.respond_to? :negative_failure_message
46
+ matcher.negative_failure_message
47
+ else
48
+ matcher.failure_message_for_should_not
49
+ end
50
+ end
56
51
 
57
52
  refute result, msg
58
53
  end
@@ -15,14 +15,14 @@ class KindOfMatcher
15
15
  end
16
16
 
17
17
  def matches? subject
18
- subject.kind_of? @klass
18
+ subject.kind_of? @klass
19
19
  end
20
20
 
21
- def failure_message
21
+ def failure_message_for_should
22
22
  "expected to " + description
23
23
  end
24
24
 
25
- def negative_failure_message
25
+ def failure_message_for_should_not
26
26
  "expected not to " + description
27
27
  end
28
28
  end
@@ -32,10 +32,6 @@ def be_kind_of klass
32
32
  end
33
33
 
34
34
  describe MiniTest::Unit::TestCase do
35
- it "needs to verify matcher has #description and #matches?" do
36
- proc { assert_must BadMatcher.new, [] }.must_raise RuntimeError
37
- end
38
-
39
35
  it "needs to verify assert_must" do
40
36
  assert_must(be_kind_of(Array), []).must_equal true
41
37
  proc { assert_must be_kind_of(String), [] }.must_raise MiniTest::Assertion
@@ -48,10 +44,6 @@ describe MiniTest::Unit::TestCase do
48
44
  end
49
45
 
50
46
  describe MiniTest::Spec do
51
- it "needs to verify matcher has #description and #matches?" do
52
- proc { [].must BadMatcher.new, [] }.must_raise RuntimeError
53
- end
54
-
55
47
  it "needs to verify must" do
56
48
  [].must(be_kind_of(Array)).must_equal true
57
49
  proc { [].must be_kind_of(String) }.must_raise MiniTest::Assertion
@@ -66,27 +58,23 @@ describe MiniTest::Spec do
66
58
  spec_class = Class.new(MiniTest::Spec) do
67
59
  subject { [1, 2, 3] }
68
60
 
69
- it("1") { must be_kind_of(Array) }
70
- it("2") { must be_kind_of(String) }
61
+ it { must be_kind_of(String) }
71
62
  end
72
63
 
73
64
  spec = spec_class.new("A spec")
74
65
 
75
- spec.send "test_0001_1"
76
- proc { spec.send "test_0002_2"}.must_raise MiniTest::Assertion
66
+ proc { spec.send spec_class.test_methods.first}.must_raise MiniTest::Assertion
77
67
  end
78
68
 
79
69
  it "needs to verify wont with implicit subject" do
80
70
  spec_class = Class.new(MiniTest::Spec) do
81
71
  subject { [1, 2, 3] }
82
72
 
83
- it("1") { wont be_kind_of(String) }
84
- it("2") { wont be_kind_of(Array) }
73
+ it { wont be_kind_of(Array) }
85
74
  end
86
75
 
87
76
  spec = spec_class.new("A spec")
88
77
 
89
- spec.send "test_0001_1"
90
- proc { spec.send "test_0002_2"}.must_raise MiniTest::Assertion
78
+ proc { spec.send spec_class.test_methods.first}.must_raise MiniTest::Assertion
91
79
  end
92
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.rc2
4
+ version: 1.1.0.rc3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-03 00:00:00.000000000Z
13
+ date: 2011-11-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
17
- requirement: &70279503203140 !ruby/object:Gem::Requirement
17
+ requirement: &70336486719080 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,21 +22,21 @@ dependencies:
22
22
  version: 2.5.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70279503203140
25
+ version_requirements: *70336486719080
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: minitest
28
- requirement: &70279503202320 !ruby/object:Gem::Requirement
28
+ requirement: &70336486718660 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '2.7'
33
+ version: '2.8'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70279503202320
36
+ version_requirements: *70336486718660
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: hoe
39
- requirement: &70279503201140 !ruby/object:Gem::Requirement
39
+ requirement: &70336486718240 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,8 +44,17 @@ dependencies:
44
44
  version: '2.12'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70279503201140
48
- description: methods.
47
+ version_requirements: *70336486718240
48
+ description: ! 'minitest-matchers adds support for RSpec/Shoulda-style matchers to
49
+
50
+ minitest/unit and minitest/spec.
51
+
52
+
53
+ More information about matchers can be found here:
54
+
55
+ * https://www.relishapp.com/rspec/rspec-expectations
56
+
57
+ * http://railscasts.com/episodes/157-rspec-matchers-macros'
49
58
  email:
50
59
  - ryand-ruby@zenspider.com
51
60
  - wojtek@wojtekmach.pl
@@ -89,6 +98,7 @@ rubyforge_project: minitest-matchers
89
98
  rubygems_version: 1.8.10
90
99
  signing_key:
91
100
  specification_version: 3
92
- summary: methods.
101
+ summary: minitest-matchers adds support for RSpec/Shoulda-style matchers to minitest/unit
102
+ and minitest/spec
93
103
  test_files:
94
104
  - test/test_minitest_matchers.rb