ae 1.5.0 → 1.6.0

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.
@@ -1,9 +1,23 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 1.6.0 / 2010-11-04
4
+
5
+ Support libraries defining toplevel methods, such as `legacy.rb`, now place
6
+ their methods in AE::World module instead of Object. AE::World needs to
7
+ to be included in the context desired for the testing framework used. This
8
+ is important to prevent polution of the the Object namespace.
9
+
10
+ Changes:
11
+
12
+ * Toplevel extras are defined in AE::World instead of Object.
13
+ * In dot.rb #true/#false methods renamed to `#true!`/`#false!`.
14
+ * In dot.rb `#true!`/`#false!` methods can take an error or error message.
15
+
16
+
3
17
  == 1.5.0 / 2010-09-06
4
18
 
5
19
  This release adds adapters for TestUnit, MiniTest and RSpec. AE worked with
6
- them previously but AE assertions were seen as errors rather than natice
20
+ them previously but AE assertions were seen as errors rather than nice
7
21
  assertions. Likewise assertion counts were off in the final tally. These
8
22
  adapters insert AE's counts so the the tally's are correct.
9
23
 
@@ -11,6 +11,7 @@ require 'ae/core_ext'
11
11
  #
12
12
  class Assertion < Exception
13
13
 
14
+ # TODO: This doesn't seem to cut it anymore!
14
15
  @count = 0
15
16
  @fails = 0
16
17
 
@@ -44,6 +45,7 @@ class Assertion < Exception
44
45
  # is increased. If +pass+ if false then both +@count+ and +@fails+
45
46
  # are incremented.
46
47
  def increment(pass)
48
+ recount unless instance_variable_defined?('@count') # TODO: Come on, there has to be a better way!
47
49
  @count += 1
48
50
  @fails += 1 unless pass
49
51
  end
@@ -102,7 +102,7 @@ class Assertor < AE::BasicObject
102
102
  rescue match => error
103
103
  pass = true
104
104
  msg = "#{match} raised"
105
- rescue Exception => error
105
+ rescue ::Exception => error
106
106
  pass = false
107
107
  msg = "#{match} expected but #{error.class} was raised"
108
108
  ensure
@@ -0,0 +1,23 @@
1
+ module AE
2
+
3
+ module CheckOK
4
+ def check(&block)
5
+ @_check = block
6
+ end
7
+
8
+ def ok(*args)
9
+ @_check.call(*args)
10
+ end
11
+
12
+ #def no(*args)
13
+ # @_check.call(*args)
14
+ #end
15
+ end
16
+
17
+ module World
18
+ include CheckOK
19
+ end
20
+
21
+ end
22
+
23
+
@@ -0,0 +1,68 @@
1
+ require 'ae/assertion'
2
+
3
+ class AE
4
+ # Given that x is "tom" then we can assert it
5
+ # is using an asseretion pipe.
6
+ #
7
+ # x = "tom"
8
+ #
9
+ # T x == "tom"
10
+ #
11
+ # We can assert the opposite using F.
12
+ #
13
+ # F x == "tom"
14
+ #
15
+ # These can be used at any point of return.
16
+ #
17
+ # T case x
18
+ # when 'tom' then true
19
+ # else false
20
+ # end
21
+ #
22
+ module Detest
23
+
24
+ # Test for true.
25
+ #
26
+ # T 1 == 1
27
+ #
28
+ def T(x=nil, &b)
29
+ Assertion.test(x || b.call, :backtrace=>caller)
30
+ end
31
+
32
+ # Test for not.
33
+ #
34
+ # F 1 == 2
35
+ #
36
+ def F(x=nil, &b)
37
+ Assertion.test(!(x || b.call), :backtrace=>caller)
38
+ end
39
+
40
+ # Test for nil?.
41
+ #
42
+ # N nil
43
+ #
44
+ def N(x=nil,&b)
45
+ Assertion.test(nil == (x || b.call), :backtrace=>caller)
46
+ end
47
+
48
+ # Expect and error.
49
+ #
50
+ # E { raise }
51
+ #
52
+ # Unless #T, #F and #N, the #E method only supports block notation.
53
+ def E(&b)
54
+ expect(Exception, &b)
55
+ end
56
+
57
+ # Catch a symbol.
58
+ #def C
59
+ #end
60
+ end
61
+
62
+ module World
63
+ include AE::Detest
64
+ end
65
+
66
+ end
67
+
68
+
@@ -1,20 +1,44 @@
1
1
  # Expiremental Concept
2
2
 
3
+ #
3
4
  class TrueClass
4
- def true
5
+ # Assert true.
6
+ #
7
+ # (x == y).true!
8
+ #
9
+ def true!(msg=nil)
5
10
  true
6
11
  end
7
- def false
8
- fail Assertion.new('true', :backtrace=>caller)
9
- #raise Assertion
12
+ # Assert false.
13
+ #
14
+ # (x == y).false!
15
+ #
16
+ def false!(err="not false")
17
+ if Exception === err
18
+ fail err
19
+ else
20
+ fail Assertion.new(err.to_s, :backtrace=>caller)
21
+ end
10
22
  end
11
23
  end
12
24
 
13
25
  class FalseClass
14
- def true
15
- fail Assertion.new('false', :backtrace=>caller)
26
+ # Assert true.
27
+ #
28
+ # (x == y).true!
29
+ #
30
+ def true!(err="not true")
31
+ if Exception === err
32
+ fail err
33
+ else
34
+ fail Assertion.new(err.to_s, :backtrace=>caller)
35
+ end
16
36
  end
17
- def false
37
+ # Assert false.
38
+ #
39
+ # (x == y).false!
40
+ #
41
+ def false!(msg=nil)
18
42
  true
19
43
  end
20
44
  end
@@ -282,9 +282,10 @@ module AE
282
282
  # include Legacy::Assertions
283
283
  # end
284
284
 
285
- end
285
+ module World
286
+ include AE::Legacy::Assertions
287
+ end
286
288
 
287
- class ::Object #:nodoc:
288
- include AE::Legacy::Assertions
289
289
  end
290
290
 
291
+
@@ -1,6 +1,6 @@
1
1
  name : ae
2
- date : 2010-09-06
3
- version : 1.5.0
2
+ date : 2010-11-04
3
+ version : 1.6.0
4
4
 
5
5
  requires:
6
6
  - syckle (build)
@@ -3,16 +3,21 @@ title : AE
3
3
  summary: Assertive Expressive
4
4
  suite : proutils
5
5
  contact: trans <transfire@gmail.com>
6
- created: 2008-08-17 09:00:06
6
+ created: 2008-08-17
7
7
  authors: Thomas Sawyer
8
8
  license: MIT
9
9
 
10
10
  description:
11
- Assertive Expressive is an assertions library intended for reuse
12
- by any TDD, BDD or the like system.
11
+ Assertive Expressive is an assertions library specifically
12
+ designed for reuse by other test frameworks.
13
13
 
14
14
  resources:
15
- homepage: http://proutils.github.com/ae
16
- repository: git://github.com/proutils/ae.git
15
+ home: http://proutils.github.com/ae
16
+ code: http://github.com/proutils/ae
17
+ docs: http://wiki.github.com/proutils/ae/docs/qed
18
+ wiki: http://wiki.github.com/proutils/ae
19
+ bugs: http://github.com/proutils/ae/issues
20
+ mail: http://groups.google.com/group/rubyworks-mailinglist
21
+ repo: git://github.com/proutils/ae.git
17
22
 
18
23
  copyright: Copyright (c) 2008 Thomas Sawyer
@@ -0,0 +1,29 @@
1
+ = Assertion Counts
2
+
3
+ AE tracks the number of assertions made and the number that failed to pass.
4
+ We can reset the count using the +recount+ class method.
5
+
6
+ fails, total = Assertion.recount
7
+
8
+ For example if we one assertion fails and another fails.
9
+
10
+ assert(true)
11
+
12
+ expect Assertion do
13
+ assert(false)
14
+ end
15
+
16
+ We will see that AE counted three assertions and one failure.
17
+
18
+ Assertion.count.assert == 3
19
+ Assertion.fails.assert == 1
20
+
21
+ The #expect call is an assertion too, which is why the count is 3
22
+ rather than 2.
23
+
24
+ Now that we are done checking counts we will restore them so that
25
+ any other demos being run with this will tally correctly.
26
+
27
+ Assertion.fails = fails
28
+ Assertion.count = total + 3
29
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 1.5.0
10
+ version: 1.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Sawyer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-06 00:00:00 -04:00
18
+ date: 2010-11-05 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: "0"
47
47
  type: :development
48
48
  version_requirements: *id002
49
- description: Assertive Expressive is an assertions library intended for reuse by any TDD, BDD or the like system.
49
+ description: Assertive Expressive is an assertions library specifically designed for reuse by other test frameworks.
50
50
  email: transfire@gmail.com
51
51
  executables: []
52
52
 
@@ -55,16 +55,12 @@ extensions: []
55
55
  extra_rdoc_files:
56
56
  - README.rdoc
57
57
  files:
58
- - demo/cucumber/features/cucumber.feature
59
- - demo/cucumber/features/step_definitions/cucumber_steps.rb
60
- - demo/cucumber/features/support/env.rb
61
- - demo/minitest/example.rb
62
- - demo/testunit/example.rb
63
58
  - qed/01_overview.rdoc
64
59
  - qed/02_assertion.rdoc
65
60
  - qed/03_assert.rdoc
66
61
  - qed/04_subjunctive.rdoc
67
62
  - qed/05_expect.rdoc
63
+ - qed/06_counts.rdoc
68
64
  - qed/07_matchers.rdoc
69
65
  - lib/ae/adapter.rb
70
66
  - lib/ae/adapters/minitest.rb
@@ -74,7 +70,9 @@ files:
74
70
  - lib/ae/assertion.rb
75
71
  - lib/ae/assertor.rb
76
72
  - lib/ae/basic_object.rb
73
+ - lib/ae/check.rb
77
74
  - lib/ae/core_ext.rb
75
+ - lib/ae/detest.rb
78
76
  - lib/ae/dot.rb
79
77
  - lib/ae/expect.rb
80
78
  - lib/ae/legacy.rb
@@ -130,3 +128,4 @@ summary: Assertive Expressive
130
128
  test_files:
131
129
  - lib/ae/adapters/minitest.rb
132
130
  - lib/ae/adapters/testunit.rb
131
+ - lib/ae/detest.rb
@@ -1,10 +0,0 @@
1
- Feature: Cucumber SUpport
2
- In order to please people who like Cucumber
3
- As an AE user
4
- I want to be able to use assert in my step definitions
5
-
6
- Scenario: assert
7
- Given x = 5
8
- And y = 5
9
- Then I can assert that x.assert == y
10
-
@@ -1,11 +0,0 @@
1
-
2
- Given /^(\w+) = (\w+)$/ do |var, value|
3
- instance_variable_set("@#{var}", value)
4
- end
5
-
6
- Then /^I can assert that (\w+).assert == (\w+)$/ do |var_a, var_b|
7
- a = instance_variable_get("@#{var_a}")
8
- b = instance_variable_get("@#{var_b}")
9
- a.assert == b
10
- end
11
-
@@ -1 +0,0 @@
1
- require 'ae'
@@ -1,34 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'ae/adapters/minitest'
3
-
4
- class MiniTestSupport < MiniTest::Unit::TestCase
5
-
6
- def test_assert_pass
7
- x = 5
8
- y = 5
9
- x.assert == y
10
- end
11
-
12
- def test_assert_fail
13
- x = 5
14
- y = 6
15
- x.assert == y
16
- end
17
-
18
- def test_assert_fail_original
19
- x = 5
20
- y = 6
21
- assert_equal(x, y)
22
- end
23
-
24
- def test_assert_pass_original
25
- x = 5
26
- y = 5
27
- assert_equal(x, y)
28
- end
29
-
30
- def test_exception
31
- raise
32
- end
33
-
34
- end
@@ -1,34 +0,0 @@
1
- require 'test/unit'
2
- require 'ae/adapters/testunit'
3
-
4
- class TestUnitSupport < Test::Unit::TestCase
5
-
6
- def test_assert_pass
7
- x = 5
8
- y = 5
9
- x.assert == y
10
- end
11
-
12
- def test_assert_fail
13
- x = 5
14
- y = 6
15
- x.assert == y
16
- end
17
-
18
- def test_assert_fail_original
19
- x = 5
20
- y = 6
21
- assert_equal(x, y)
22
- end
23
-
24
- def test_assert_pass_original
25
- x = 5
26
- y = 5
27
- assert_equal(x, y)
28
- end
29
-
30
- def test_exception
31
- raise
32
- end
33
-
34
- end