minitest-great_expectations 0.0.2 → 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.
data/README.md CHANGED
@@ -13,7 +13,7 @@ These may make it into minitest proper, someday.
13
13
 
14
14
  ## Installation
15
15
 
16
- Add this line to your application's Gemfile:
16
+ Add this line to your application's Gemfile (in your "test" gem group, if you have one):
17
17
 
18
18
  ``` ruby
19
19
  gem 'minitest-great_expectations'
@@ -22,7 +22,6 @@ gem 'minitest-great_expectations'
22
22
  Add this to your ```minitest_helper.rb```:
23
23
 
24
24
  ``` ruby
25
- require 'minitest/autorun'
26
25
  require 'minitest/great_expectations'
27
26
  ```
28
27
 
@@ -40,10 +39,14 @@ And then execute:
40
39
 
41
40
  ## Changelog
42
41
 
42
+ ### 0.0.3
43
+
44
+ * Added ```assert_includes_none```/```wont_include_any```
45
+
43
46
  ### 0.0.2
44
47
 
45
48
  * Added proper require, and moved into correct subdirectories
46
49
 
47
50
  ### 0.0.1
48
51
 
49
- * First whack
52
+ * First whack
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module GreatExpectations
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -32,6 +32,14 @@ module MiniTest::Assertions
32
32
  end
33
33
  end
34
34
 
35
+ def assert_includes_none(expected, actual, message = nil)
36
+ unexpected = expected.to_a & actual.to_a
37
+ unless unexpected.empty?
38
+ message ||= "Expected:\n #{mu_pp actual}\nnot to contain any element in:\n #{mu_pp expected}."
39
+ flunk("#{message}\nUnexpected elements:\n #{mu_pp unexpected.sort}")
40
+ end
41
+ end
42
+
35
43
  # The first parameter must be ```true```, not coercible to true.
36
44
  def assert_true(obj, msg = nil)
37
45
  msg = message(msg) { "<true> expected but was #{mu_pp obj}" }
@@ -58,6 +66,7 @@ end
58
66
  module MiniTest::Expectations
59
67
  infect_an_assertion :assert_equal_contents, :must_equal_contents
60
68
  infect_an_assertion :assert_includes_all, :must_include_all
69
+ infect_an_assertion :assert_includes_none, :wont_include_any
61
70
  infect_an_assertion :assert_true, :must_be_true, :unary
62
71
  infect_an_assertion :assert_truthy, :must_be_truthy, :unary
63
72
  infect_an_assertion :assert_false, :must_be_false, :unary
@@ -76,15 +76,52 @@ describe "must_include_all" do
76
76
  end
77
77
  end
78
78
 
79
+ describe "assert_includes_none" do
80
+ it "passes on empty expected" do
81
+ assert_includes_none([], [])
82
+ assert_includes_none([], [1, 2, 3])
83
+ end
84
+ it "passes on empty actual" do
85
+ assert_includes_none([1, 2, 3], [])
86
+ end
87
+ it "passes on non-empty exptected" do
88
+ assert_includes_none([1, 2], [3, 4])
89
+ end
90
+ it "fails with expected" do
91
+ l = lambda { assert_includes_none([3, 2], [1, 2, 3]) }
92
+ error = assert_raises(MiniTest::Assertion, &l)
93
+ error.message.must_match /unexpected elements.*\[2\, 3\]/im
94
+ end
95
+ end
96
+
97
+ describe "wont_include_any" do
98
+ it "passes on empty expected" do
99
+ [].wont_include_any []
100
+ [].wont_include_any [1, 2, 3]
101
+ end
102
+ it "passes on empty actual" do
103
+ [1, 2, 3].wont_include_any []
104
+ end
105
+ it "passes on non-empty exptected" do
106
+ [1, 2].wont_include_any [3, 4]
107
+ end
108
+ it "fails with expected" do
109
+ l = lambda { [3, 2].wont_include_any [1, 2, 3] }
110
+ error = assert_raises(MiniTest::Assertion, &l)
111
+ error.message.must_match /unexpected elements.*\[2\, 3\]/im
112
+ end
113
+ end
114
+
115
+
79
116
  describe "assert_true" do
80
- #it "passes for true" do
81
- # assert_true(true)
82
- #end
83
- #it "fails for truthy" do
84
- # l = lambda { assert_true(1) }
85
- # error = assert_raises(MiniTest::Assertion, &l)
86
- # error.message.must_match /<true> expected/im
87
- #end
117
+ it "passes for true" do
118
+ assert_true(true)
119
+ end
120
+ it "fails for truthy" do
121
+ l = lambda { assert_true(1) }
122
+ error = assert_raises(MiniTest::Assertion, &l)
123
+ error.message.must_match /<true> expected/im
124
+ end
88
125
  end
89
126
 
90
127
  describe "must_be_true" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-great_expectations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: 4394966027857673618
95
+ hash: -246921461347167831
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  segments:
103
103
  - 0
104
- hash: 4394966027857673618
104
+ hash: -246921461347167831
105
105
  requirements: []
106
106
  rubyforge_project:
107
107
  rubygems_version: 1.8.23