wrong 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/lib/predicated/lib/predicated/sexp_patch.rb +39 -0
- data/lib/wrong.rb +0 -2
- data/lib/wrong/adapters/minitest.rb +18 -0
- data/lib/wrong/assert.rb +2 -1
- data/lib/wrong/version.rb +1 -1
- data/test/adapters/minitest_test.rb +27 -0
- metadata +30 -13
data/README.markdown
CHANGED
@@ -10,7 +10,7 @@ Wrong is alpha-quality. We'd very much appreciate feedback and bug reports. Ther
|
|
10
10
|
|
11
11
|
It relies on [Predicated](http://github.com/sconover/predicated) for its main failure message.
|
12
12
|
|
13
|
-
Inspired by [assert { 2.0 }](http://assert2.rubyforge.org/) but rewritten from scratch. Compatible with Ruby 1.8 and 1.
|
13
|
+
Inspired by [assert { 2.0 }](http://assert2.rubyforge.org/) but rewritten from scratch. Compatible with Ruby (MRI) 1.8, 1.9, and JRuby 1.5.
|
14
14
|
|
15
15
|
## Usage ##
|
16
16
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
#see http://gist.github.com/321038
|
4
|
+
# # Monkey-patch to have Ruby2Ruby#translate with r2r >= 1.2.3, from
|
5
|
+
# # http://seattlerb.rubyforge.org/svn/ruby2ruby/1.2.2/lib/ruby2ruby.rb
|
6
|
+
class ::Ruby2Ruby < ::SexpProcessor
|
7
|
+
def self.translate(klass_or_str, method = nil)
|
8
|
+
sexp = ParseTree.translate(klass_or_str, method)
|
9
|
+
unifier = Unifier.new
|
10
|
+
unifier.processors.each do |p|
|
11
|
+
p.unsupported.delete :cfunc # HACK
|
12
|
+
end
|
13
|
+
sexp = unifier.process(sexp)
|
14
|
+
self.new.process(sexp)
|
15
|
+
end
|
16
|
+
|
17
|
+
#sconover - 7/2010 - monkey-patch
|
18
|
+
#{1=>2}=={1=>2}
|
19
|
+
#The right side was having its braces cut off because of
|
20
|
+
#special handling of hashes within arglists within the seattlerb code.
|
21
|
+
#I tried to fork r2r and add a test, but a lot of other tests
|
22
|
+
#broke, and I just dont understand the test in ruby2ruby.
|
23
|
+
#So I'm emailing the author...
|
24
|
+
def process_hash(exp)
|
25
|
+
result = []
|
26
|
+
until exp.empty?
|
27
|
+
lhs = process(exp.shift)
|
28
|
+
rhs = exp.shift
|
29
|
+
t = rhs.first
|
30
|
+
rhs = process rhs
|
31
|
+
rhs = "(#{rhs})" unless [:lit, :str].include? t # TODO: verify better!
|
32
|
+
|
33
|
+
result << "#{lhs} => #{rhs}"
|
34
|
+
end
|
35
|
+
|
36
|
+
return "{ #{result.join(', ')} }"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/wrong.rb
CHANGED
@@ -5,4 +5,22 @@ class MiniTest::Unit::TestCase
|
|
5
5
|
def failure_class
|
6
6
|
MiniTest::Assertion
|
7
7
|
end
|
8
|
+
|
9
|
+
def assert(*args)
|
10
|
+
if block_given?
|
11
|
+
self._assertions += 1
|
12
|
+
super(explanation=args.first, depth=1)
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def deny(*args)
|
19
|
+
if block_given?
|
20
|
+
self._assertions += 1
|
21
|
+
super(explanation=args.first, depth=1)
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
8
26
|
end
|
data/lib/wrong/assert.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "predicated/predicate"
|
2
|
-
require "predicated/from/
|
2
|
+
require "predicated/from/ruby_code_string"
|
3
3
|
require "predicated/to/sentence"
|
4
4
|
require "wrong/chunk"
|
5
5
|
require "wrong/config"
|
@@ -123,6 +123,7 @@ module Wrong
|
|
123
123
|
unless value
|
124
124
|
chunk = Wrong::Chunk.from_block(block, depth + 2)
|
125
125
|
code = chunk.code
|
126
|
+
|
126
127
|
predicate = begin
|
127
128
|
Predicated::Predicate.from_ruby_code_string(code, block.binding)
|
128
129
|
rescue Predicated::Predicate::DontKnowWhatToDoWithThisSexpError
|
data/lib/wrong/version.rb
CHANGED
@@ -61,10 +61,37 @@ describe "basic assert features" do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
msg = rescuing { MyFailingAssertTest.new.test_fail }.message
|
64
|
+
|
64
65
|
assert { msg.include?("1 is not equal to 2") }
|
65
66
|
|
66
67
|
msg = rescuing { MyFailingDenyTest.new.test_fail }.message
|
67
68
|
assert { msg.include?("1 is equal to 1") }
|
68
69
|
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'reports number of assertions' do
|
73
|
+
before do
|
74
|
+
@test = Class.new(MiniTest::Unit::TestCase).new("x")
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'assert{} should bump number of assertions' do
|
78
|
+
@test.assert {true}
|
79
|
+
assert {@test._assertions == 1}
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'assert() should not bump twice number of assertions' do
|
83
|
+
@test.assert(true)
|
84
|
+
assert {@test._assertions == 1}
|
85
|
+
end
|
69
86
|
|
87
|
+
it 'deny{} should bump number of assertions' do
|
88
|
+
@test.deny {false}
|
89
|
+
assert {@test._assertions == 1}
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'deny() should bump once number of assertions' do
|
93
|
+
@test.deny(false)
|
94
|
+
assert {@test._assertions == 1}
|
95
|
+
end
|
70
96
|
end
|
97
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steve Conover
|
@@ -20,8 +20,24 @@ date: 2010-09-22 00:00:00 -07:00
|
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
name:
|
23
|
+
name: predicated
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 2
|
33
|
+
- 1
|
34
|
+
version: 0.2.1
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: ParseTree
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
26
42
|
requirements:
|
27
43
|
- - ">="
|
@@ -34,10 +50,10 @@ dependencies:
|
|
34
50
|
version: 3.0.5
|
35
51
|
type: :runtime
|
36
52
|
prerelease: false
|
37
|
-
version_requirements: *
|
53
|
+
version_requirements: *id002
|
38
54
|
- !ruby/object:Gem::Dependency
|
39
55
|
name: ruby_parser
|
40
|
-
requirement: &
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
58
|
requirements:
|
43
59
|
- - ">="
|
@@ -50,10 +66,10 @@ dependencies:
|
|
50
66
|
version: 2.0.4
|
51
67
|
type: :runtime
|
52
68
|
prerelease: false
|
53
|
-
version_requirements: *
|
69
|
+
version_requirements: *id003
|
54
70
|
- !ruby/object:Gem::Dependency
|
55
71
|
name: ruby2ruby
|
56
|
-
requirement: &
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
73
|
none: false
|
58
74
|
requirements:
|
59
75
|
- - ">="
|
@@ -66,10 +82,10 @@ dependencies:
|
|
66
82
|
version: 1.2.4
|
67
83
|
type: :runtime
|
68
84
|
prerelease: false
|
69
|
-
version_requirements: *
|
85
|
+
version_requirements: *id004
|
70
86
|
- !ruby/object:Gem::Dependency
|
71
87
|
name: diff
|
72
|
-
requirement: &
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
89
|
none: false
|
74
90
|
requirements:
|
75
91
|
- - ">="
|
@@ -82,10 +98,10 @@ dependencies:
|
|
82
98
|
version: 0.3.6
|
83
99
|
type: :runtime
|
84
100
|
prerelease: false
|
85
|
-
version_requirements: *
|
101
|
+
version_requirements: *id005
|
86
102
|
- !ruby/object:Gem::Dependency
|
87
103
|
name: diff-lcs
|
88
|
-
requirement: &
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
89
105
|
none: false
|
90
106
|
requirements:
|
91
107
|
- - ">="
|
@@ -98,7 +114,7 @@ dependencies:
|
|
98
114
|
version: 1.1.2
|
99
115
|
type: :runtime
|
100
116
|
prerelease: false
|
101
|
-
version_requirements: *
|
117
|
+
version_requirements: *id006
|
102
118
|
description: |-
|
103
119
|
Wrong provides a general assert method that takes a predicate block. Assertion failure
|
104
120
|
messages are rich in detail. The Wrong idea is to replace all those countless assert_this,
|
@@ -113,6 +129,7 @@ extensions: []
|
|
113
129
|
extra_rdoc_files:
|
114
130
|
- README.markdown
|
115
131
|
files:
|
132
|
+
- lib/predicated/lib/predicated/sexp_patch.rb
|
116
133
|
- lib/wrong/adapters/minitest.rb
|
117
134
|
- lib/wrong/adapters/rspec.rb
|
118
135
|
- lib/wrong/adapters/test_unit.rb
|