wrong 0.3.0 → 0.3.1

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.
@@ -2,7 +2,7 @@ require "./test/test_helper"
2
2
 
3
3
  require "wrong/assert"
4
4
 
5
- regarding "failures" do
5
+ describe "failures" do
6
6
 
7
7
  before do
8
8
  @m = Module.new do
@@ -10,15 +10,15 @@ regarding "failures" do
10
10
  end
11
11
  end
12
12
 
13
- regarding "simple" do
13
+ describe "simple" do
14
14
 
15
- test "raw boolean assert failure" do
15
+ it "raw boolean assert failure" do
16
16
  error = get_error { @m.assert { false } }
17
17
  # puts error.message
18
18
  assert_match "false", error.message
19
19
  end
20
20
 
21
- test "raw boolean deny failure" do
21
+ it "raw boolean deny failure" do
22
22
  error = get_error {
23
23
  @m.deny { true }
24
24
  }
@@ -26,7 +26,7 @@ regarding "failures" do
26
26
  assert_match "true", error.message
27
27
  end
28
28
 
29
- test "equality failure" do
29
+ it "equality failure" do
30
30
  assert_match "1 is not equal to 2", get_error {
31
31
  @m.assert { 1==2 }
32
32
  }.message
@@ -35,7 +35,7 @@ regarding "failures" do
35
35
  }.message
36
36
  end
37
37
 
38
- test "failure of basic operations" do
38
+ it "failure of basic operations" do
39
39
  assert_match "1 is not greater than 2", get_error {
40
40
  @m.assert { 1>2 }
41
41
  }.message
@@ -63,13 +63,13 @@ regarding "failures" do
63
63
  }.message
64
64
  end
65
65
 
66
- test "object failure" do
66
+ it "object failure" do
67
67
  assert_match "Color:red is not equal to 2", get_error {
68
68
  @m.assert { Color.new("red")==2 }
69
69
  }.message
70
70
  end
71
71
 
72
- test %{multiline assert block shouldn't look any different
72
+ it %{multiline assert block shouldn't look any different
73
73
  than when there everything is on one line} do
74
74
  assert_match("1 is not equal to 2", get_error {
75
75
  @m.assert {
@@ -81,8 +81,8 @@ regarding "failures" do
81
81
 
82
82
  end
83
83
 
84
- regarding "accessing and printing values set outside of the assert" do
85
- test "use a value in the assert defined outside of it" do
84
+ describe "accessing and printing values set outside of the assert" do
85
+ it "use a value in the assert defined outside of it" do
86
86
  a = 1
87
87
  assert_match "1 is not equal to 2", get_error {
88
88
  @m.assert { a==2 }
@@ -93,8 +93,18 @@ regarding "failures" do
93
93
  end
94
94
  end
95
95
 
96
- regarding "the assert block has many statements" do
97
- test "only pay attention to the final statement" do
96
+ describe "conjunctions (and and or)" do
97
+ it "omit a primary failure message since 'This is not true etc.' is more obscuring than clarifying" do
98
+ m = get_error {
99
+ x = 5
100
+ @m.assert { x == 5 && x != 5}
101
+ }.message
102
+ assert m == "Expected ((x == 5) and (not (x == 5))), but \n (x == 5) is true\n x is 5\n (not (x == 5)) is false\n"
103
+ end
104
+ end
105
+
106
+ describe "the assert block has many statements" do
107
+ it "only pay attention to the final statement" do
98
108
  assert_match("1 is not equal to 2", get_error {
99
109
  @m.assert {
100
110
  a = "aaa"
@@ -107,7 +117,7 @@ regarding "failures" do
107
117
  }.message)
108
118
  end
109
119
 
110
- test "works even if the assertion is based on stuff set previously in the block" do
120
+ it "works even if the assertion is based on stuff set previously in the block" do
111
121
  assert_match("\"aaa\" is not equal to \"bbb\"", get_error {
112
122
  @m.assert {
113
123
  a = "aaa"
@@ -117,16 +127,16 @@ regarding "failures" do
117
127
  end
118
128
  end
119
129
 
120
- regarding "array comparisons" do
121
- test "basic" do
130
+ describe "array comparisons" do
131
+ it "basic" do
122
132
  assert_match %{[1, 2] is not equal to ["a", "b"]}, get_error {
123
133
  @m.assert { [1, 2]==%w{a b} }
124
134
  }.message
125
135
  end
126
136
  end
127
137
 
128
- regarding "hash comparisons" do
129
- test "basic" do
138
+ describe "hash comparisons" do
139
+ it "basic" do
130
140
  assert_match '{1=>2} is not equal to {"a"=>"b"}',
131
141
  get_error {
132
142
  @m.assert { {1=>2}=={"a"=>"b"} }
@@ -134,8 +144,8 @@ regarding "failures" do
134
144
  end
135
145
  end
136
146
 
137
- regarding "methods that result in a boolean. this might be hard." do
138
- test "string include" do
147
+ describe "methods that result in a boolean. this might be hard." do
148
+ it "string include" do
139
149
  assert_match "\"abc\" does not include \"cd\"", get_error {
140
150
  @m.assert { "abc".include?("cd") }
141
151
  }.message
@@ -3,7 +3,7 @@ require "wrong/assert"
3
3
  require "wrong/message/array_diff"
4
4
  require "wrong/adapters/minitest"
5
5
 
6
- regarding "when you're comparing strings and they don't match, show me the diff message" do
6
+ describe "when you're comparing strings and they don't match, show me the diff message" do
7
7
 
8
8
  def assert_string_diff_message(first_array, second_array, expected_error_message)
9
9
  assert {
@@ -13,7 +13,7 @@ regarding "when you're comparing strings and they don't match, show me the diff
13
13
  }
14
14
  end
15
15
 
16
- test "don't attempt to do this if the assertion is not of the form a_array==b_array" do
16
+ it "don't attempt to do this if the assertion is not of the form a_array==b_array" do
17
17
  deny {
18
18
  rescuing {
19
19
  assert { [1]==2 }
@@ -26,7 +26,7 @@ regarding "when you're comparing strings and they don't match, show me the diff
26
26
  }
27
27
  end
28
28
 
29
- test "simple" do
29
+ it "simple" do
30
30
  assert {
31
31
  rescuing {
32
32
  assert { ["a"]==["b"] }
@@ -40,7 +40,7 @@ regarding "when you're comparing strings and they don't match, show me the diff
40
40
  })
41
41
  end
42
42
 
43
- test "elements align properly" do
43
+ it "elements align properly" do
44
44
  assert_string_diff_message(["a", "b", "c"], ["a", "cccc", "c"], %{
45
45
  ["a", "b" , "c"]
46
46
  ["a", "cccc", "c"]
@@ -54,7 +54,7 @@ regarding "when you're comparing strings and they don't match, show me the diff
54
54
  })
55
55
  end
56
56
 
57
- test "different primitive types" do
57
+ it "different primitive types" do
58
58
  assert_string_diff_message([1, true], [2, true, nil], %{
59
59
  [1, true]
60
60
  [2, true, nil]
@@ -62,7 +62,7 @@ regarding "when you're comparing strings and they don't match, show me the diff
62
62
  })
63
63
  end
64
64
 
65
- test "2d array - just inspects the inner array like it would any other element" do
65
+ it "2d array - just inspects the inner array like it would any other element" do
66
66
  assert { [1, [2, 3]] == [1, [2, 3]] }
67
67
  assert_string_diff_message([1, [2]], [1, [2, 3]], %{
68
68
  [1, [2] ]
@@ -3,7 +3,7 @@ require "wrong/assert"
3
3
  require "wrong/message/string_diff"
4
4
  require "wrong/adapters/minitest"
5
5
 
6
- regarding "when you're comparing strings and they don't match, show me the diff message" do
6
+ describe "when you're comparing strings and they don't match, show me the diff message" do
7
7
 
8
8
  def assert_string_diff_message(first_string, second_string, str)
9
9
  assert{
@@ -13,7 +13,7 @@ regarding "when you're comparing strings and they don't match, show me the diff
13
13
  }
14
14
  end
15
15
 
16
- test "don't attempt to do this if the assertion is not of the form a_string==b_string" do
16
+ it "don't attempt to do this if the assertion is not of the form a_string==b_string" do
17
17
  deny{
18
18
  rescuing{
19
19
  assert{1==2}
@@ -36,7 +36,7 @@ regarding "when you're comparing strings and they don't match, show me the diff
36
36
  }
37
37
  end
38
38
 
39
- test "simple" do
39
+ it "simple" do
40
40
  assert{
41
41
  rescuing{
42
42
  assert{"a"=="b"}
@@ -51,7 +51,7 @@ acc
51
51
  })
52
52
  end
53
53
 
54
- test "whitespace" do
54
+ it "whitespace" do
55
55
  assert_string_diff_message("a\nb", "a\ncc", %{
56
56
  a\\nb
57
57
  ^
@@ -74,7 +74,7 @@ a\\rcc
74
74
 
75
75
  end
76
76
 
77
- xtest "elides really long matching sections" do
77
+ xit "elides really long matching sections" do
78
78
  left = "x"*100 + "ab" + "y"*100 + "AB" + "z"*100
79
79
  right = "x"*100 + "acc" + "y"*100 + "ACC" + "z"*100
80
80
 
@@ -2,11 +2,11 @@ require "./test/test_helper"
2
2
  require "wrong/assert"
3
3
  require "wrong/message/test_context"
4
4
 
5
- regarding "showing the lines just above where the failure occurs, so you have some context" do
5
+ describe "showing the lines just above where the failure occurs, so you have some context" do
6
6
 
7
7
  include Wrong::Assert
8
8
 
9
- test "you can see test method all the way back to the start of the test, plus an indication of where the failure was" do
9
+ it "you can see test method all the way back to the start of the test, plus an indication of where the failure was" do
10
10
  a = 1
11
11
  b = 2
12
12
  c = 1
@@ -16,7 +16,7 @@ regarding "showing the lines just above where the failure occurs, so you have so
16
16
  rescue Wrong::Assert::AssertionFailedError => e
17
17
  assert do
18
18
  e.message.include?(
19
- %{ test "you can see test method all the way back to the start of the test, plus an indication of where the failure was" do
19
+ %{ it "you can see test method all the way back to the start of the test, plus an indication of where the failure was" do
20
20
  a = 1
21
21
  b = 2
22
22
  c = 1
@@ -65,4 +65,4 @@ regarding "showing the lines just above where the failure occurs, so you have so
65
65
  end
66
66
  end
67
67
 
68
- end
68
+ end
@@ -3,12 +3,12 @@ require "./test/test_helper"
3
3
  require "wrong/assert"
4
4
  require "wrong/adapters/minitest"
5
5
 
6
- regarding "a tool for rescuing errors" do
6
+ describe "a tool for rescuing errors" do
7
7
 
8
8
  class RedError < StandardError; end
9
9
  class BlueError < StandardError; end
10
10
 
11
- test "catch the error and assert on it" do
11
+ it "catch the error and assert on it" do
12
12
  assert{ rescuing{raise RedError.new}.is_a?(RedError) }
13
13
  assert{ rescuing{"x"}.nil? }
14
14
  end
@@ -1,9 +1,9 @@
1
1
  require "./test/test_helper"
2
2
  require "wrong/sexp_ext"
3
3
 
4
- regarding Sexp do
5
- regarding "#doop" do
6
- test "deeply duplicates the sexp" do
4
+ describe Sexp do
5
+ describe "#doop" do
6
+ it "deeply duplicates the sexp" do
7
7
  original = RubyParser.new.parse("x == 5")
8
8
  duplicate = original.doop
9
9
  assert(original.object_id != duplicate.object_id)
@@ -17,60 +17,60 @@ regarding Sexp do
17
17
  RubyParser.new.parse(ruby)
18
18
  end
19
19
 
20
- regarding "#to_ruby" do
21
- test "converts the sexp to ruby code" do
20
+ describe "#to_ruby" do
21
+ it "converts the sexp to ruby code" do
22
22
  sexp = parse("x == 5")
23
23
  assert sexp.to_ruby == "(x == 5)"
24
24
  end
25
25
 
26
- test "leaves the original sexp alone" do
26
+ it "leaves the original sexp alone" do
27
27
  sexp = parse("x == 5")
28
28
  assert sexp.to_ruby == "(x == 5)"
29
29
  assert sexp.to_ruby == "(x == 5)" # intended
30
30
  end
31
31
  end
32
32
 
33
- regarding "#assertion? with a question mark" do
34
- test "matches an sexp that looks like assert { }" do
33
+ describe "#assertion? with a question mark" do
34
+ it "matches an sexp that looks like assert { }" do
35
35
  sexp = parse("assert { true }")
36
36
  assert sexp.assertion?
37
37
  end
38
38
 
39
- test "matches an sexp that looks like assert(message) { }" do
39
+ it "matches an sexp that looks like assert(message) { }" do
40
40
  sexp = parse("assert('hi') { true }")
41
41
  assert sexp.assertion?
42
42
  end
43
43
 
44
- test "matches an sexp that looks like deny { }" do
44
+ it "matches an sexp that looks like deny { }" do
45
45
  sexp = parse("deny { false }")
46
46
  assert sexp.assertion?
47
47
  end
48
48
 
49
- test "doesn't match an sexp that calls assert without a block" do
49
+ it "doesn't match an sexp that calls assert without a block" do
50
50
  sexp = parse("assert(true)")
51
51
  assert !sexp.assertion?
52
52
  end
53
53
 
54
- test "doesn't match a normal sexp" do
54
+ it "doesn't match a normal sexp" do
55
55
  sexp = parse("x == 5")
56
56
  assert !sexp.assertion?
57
57
  end
58
58
  end
59
59
 
60
- regarding "#assertion" do
61
- test "matches a top-level sexp that looks like assert { }" do
60
+ describe "#assertion" do
61
+ it "matches a top-level sexp that looks like assert { }" do
62
62
  sexp = parse("assert { true }")
63
63
  code = sexp.assertion.to_ruby
64
64
  assert code == "assert { true }"
65
65
  end
66
66
 
67
- test "matches a nested sexp that looks like assert { }" do
67
+ it "matches a nested sexp that looks like assert { }" do
68
68
  sexp = parse("nesting { assert { true } }")
69
69
  code = sexp.assertion.to_ruby
70
70
  assert code == "assert { true }"
71
71
  end
72
72
 
73
- test "matches the first nested sexp that looks like assert { }" do
73
+ it "matches the first nested sexp that looks like assert { }" do
74
74
  sexp = parse("nesting { assert { true } or assert { false } }")
75
75
  code = sexp.assertion.to_ruby
76
76
  assert code == "assert { true }"
@@ -6,6 +6,7 @@ require "minitest/spec"
6
6
  require "minitest/unit"
7
7
  require "pp"
8
8
 
9
+ # yes, this does look a lot like Wrong::Assert#rescuing :-)
9
10
  def get_error
10
11
  error = nil
11
12
  begin
@@ -13,10 +14,6 @@ def get_error
13
14
  rescue Exception, RuntimeError => e
14
15
  error = e
15
16
  end
16
-
17
- # puts ""
18
- # puts error
19
- #
20
17
  error
21
18
  end
22
19
 
@@ -24,10 +21,8 @@ class MiniTest::Unit::TestCase
24
21
  end
25
22
 
26
23
  module Kernel
27
- alias_method :regarding, :describe
28
-
29
- def xregarding(str)
30
- puts "x'd out 'regarding \"#{str}\"'"
24
+ def xdescribe(str)
25
+ puts "x'd out describe \"#{str}\""
31
26
  end
32
27
  end
33
28
 
@@ -35,15 +30,13 @@ class MiniTest::Spec
35
30
  include MiniTest::Assertions
36
31
 
37
32
  class << self
38
- alias_method :test, :it
39
-
40
- def xtest(str)
41
- puts "x'd out 'test \"#{str}\"'"
33
+ def xit(str)
34
+ puts "x'd out test \"#{str}\""
42
35
  end
43
-
44
36
  end
45
37
  end
46
38
 
39
+ # dummy class for use by tests
47
40
  class Color
48
41
  attr_reader :name
49
42
  def initialize(name)
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve Conover
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-08-26 00:00:00 -07:00
19
+ date: 2010-08-29 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency