wrong 0.6.0-java → 0.6.1-java
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.markdown +20 -2
 - data/lib/wrong/assert.rb +12 -1
 - data/lib/wrong/version.rb +1 -1
 - data/test/verbose_test.rb +66 -0
 - metadata +15 -13
 
    
        data/README.markdown
    CHANGED
    
    | 
         @@ -4,7 +4,9 @@ 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            ## Abstract ##
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            Wrong provides a general assert method that takes a  
     | 
| 
      
 7 
     | 
    
         
            +
            Wrong provides a simple, general assert method that takes a block, and understands the code inside it, providing verbose failure messages for free.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            The Wrong idea is to replace `assert_equal` and all those countless `assert\_this`, `assert\_that`, `should\_something` library methods which only exist to give a failure message that's not simply "assertion failed". Wrong replaces all of them in one fell swoop, since if you can write it in Ruby, Wrong can make a sensible failure message out of it.
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
11 
     | 
    
         
             
            We'd very much appreciate feedback and bug reports. There are plenty of things left to be done to make the results look uniformly clean and beautiful. We want your feedback, and especially to give us cases where either it blows up or the output is ugly or uninformative.
         
     | 
| 
       10 
12 
     | 
    
         | 
| 
         @@ -113,7 +115,11 @@ Remember, if you want `d` to work at runtime (e.g. in a webapp) then you must `i 
     | 
|
| 
       113 
115 
     | 
    
         | 
| 
       114 
116 
     | 
    
         
             
            ### eventually
         
     | 
| 
       115 
117 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
            If you care that something is going to be true *soon*, but maybe not *right* now, use `eventually`. 
     | 
| 
      
 118 
     | 
    
         
            +
            If you care that something is going to be true *soon*, but maybe not *right* now, use `eventually`.
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                eventually { night? }
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            It will keep executing the block, up to 4 times a second, until either
         
     | 
| 
       117 
123 
     | 
    
         | 
| 
       118 
124 
     | 
    
         
             
              * the block returns true(ish)
         
     | 
| 
       119 
125 
     | 
    
         
             
              * 5 seconds elapse
         
     | 
| 
         @@ -428,6 +434,18 @@ Here are some suggestions: 
     | 
|
| 
       428 
434 
     | 
    
         | 
| 
       429 
435 
     | 
    
         
             
            Just don't use "`aver`" since we took that one for an internal method in `Wrong::Assert`.
         
     | 
| 
       430 
436 
     | 
    
         | 
| 
      
 437 
     | 
    
         
            +
            ### Verbose ###
         
     | 
| 
      
 438 
     | 
    
         
            +
             
     | 
| 
      
 439 
     | 
    
         
            +
            Wrong works inside frameworks like Test::Unit and RSpec, but sometimes you just want to stick a bunch of assertions in a file and run it. In that case, *verbose mode* might come in handy. It prints every *successful* assertion to the console (including explanations, if provided, and in color, if desired).
         
     | 
| 
      
 440 
     | 
    
         
            +
             
     | 
| 
      
 441 
     | 
    
         
            +
                Wrong.config.verbose
         
     | 
| 
      
 442 
     | 
    
         
            +
                assert("basic math") { 2 + 2 == 4}
         
     | 
| 
      
 443 
     | 
    
         
            +
                
         
     | 
| 
      
 444 
     | 
    
         
            +
            prints
         
     | 
| 
      
 445 
     | 
    
         
            +
             
     | 
| 
      
 446 
     | 
    
         
            +
                basic math: ((2 + 2) == 4)
         
     | 
| 
      
 447 
     | 
    
         
            +
             
     | 
| 
      
 448 
     | 
    
         
            +
             
     | 
| 
       431 
449 
     | 
    
         
             
            ## Helper Assert Methods ##
         
     | 
| 
       432 
450 
     | 
    
         | 
| 
       433 
451 
     | 
    
         
             
            If you really want to, you can define your proc in one method, pass it in to another method, and have that method assert it. This is a challenge for Wrong and you probably shouldn't do it. Wrong will do its best to figure out where the actual assertion code is but it might not succeed.
         
     | 
    
        data/lib/wrong/assert.rb
    CHANGED
    
    | 
         @@ -6,6 +6,7 @@ require "wrong/chunk" 
     | 
|
| 
       6 
6 
     | 
    
         
             
            require "wrong/config"
         
     | 
| 
       7 
7 
     | 
    
         
             
            require "wrong/failure_message"
         
     | 
| 
       8 
8 
     | 
    
         
             
            require "wrong/ruby2ruby_patch" # need to patch it after some other stuff loads
         
     | 
| 
      
 9 
     | 
    
         
            +
            require "wrong/rainbow"
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            module Wrong
         
     | 
| 
       11 
12 
     | 
    
         
             
              module Assert
         
     | 
| 
         @@ -65,7 +66,17 @@ module Wrong 
     | 
|
| 
       65 
66 
     | 
    
         | 
| 
       66 
67 
     | 
    
         
             
                  value = block.call
         
     | 
| 
       67 
68 
     | 
    
         
             
                  value = !value if valence == :deny
         
     | 
| 
       68 
     | 
    
         
            -
                   
     | 
| 
      
 69 
     | 
    
         
            +
                  if value
         
     | 
| 
      
 70 
     | 
    
         
            +
                    if Wrong.config[:verbose]
         
     | 
| 
      
 71 
     | 
    
         
            +
                      code = Wrong::Chunk.from_block(block, depth + 2).code 
         
     | 
| 
      
 72 
     | 
    
         
            +
                      if Wrong.config[:color]
         
     | 
| 
      
 73 
     | 
    
         
            +
                        explanation = explanation.color(:blue) if explanation
         
     | 
| 
      
 74 
     | 
    
         
            +
                        code = code.color(:green)
         
     | 
| 
      
 75 
     | 
    
         
            +
                      end
         
     | 
| 
      
 76 
     | 
    
         
            +
                      message = "#{explanation + ": " if explanation}#{code}"
         
     | 
| 
      
 77 
     | 
    
         
            +
                      puts message
         
     | 
| 
      
 78 
     | 
    
         
            +
                    end
         
     | 
| 
      
 79 
     | 
    
         
            +
                  else
         
     | 
| 
       69 
80 
     | 
    
         
             
                    chunk = Wrong::Chunk.from_block(block, depth + 2)
         
     | 
| 
       70 
81 
     | 
    
         | 
| 
       71 
82 
     | 
    
         
             
                    message = FailureMessage.new(chunk, valence, explanation).full
         
     | 
    
        data/lib/wrong/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,66 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            here = File.dirname(__FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "#{here}/test_helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "wrong/assert"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "wrong/helpers"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "wrong/d"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "wrong/rainbow"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            describe "verbose assert" do
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
              include Wrong::Helpers
         
     | 
| 
      
 12 
     | 
    
         
            +
              include Wrong::D
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              before do
         
     | 
| 
      
 15 
     | 
    
         
            +
                @m = Module.new do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  extend Wrong::Assert
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
                Wrong.config.verbose
         
     | 
| 
      
 19 
     | 
    
         
            +
                @color_enabled = Sickill::Rainbow.enabled
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
              
         
     | 
| 
      
 22 
     | 
    
         
            +
              after do
         
     | 
| 
      
 23 
     | 
    
         
            +
                Wrong.config[:verbose] = nil
         
     | 
| 
      
 24 
     | 
    
         
            +
                Wrong.config[:color] = nil
         
     | 
| 
      
 25 
     | 
    
         
            +
                Sickill::Rainbow.enabled = @color_enabled
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              it "sets the verbose flag" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                assert Wrong.config[:verbose]
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
              
         
     | 
| 
      
 32 
     | 
    
         
            +
              it "prints the contents of a successful assert" do
         
     | 
| 
      
 33 
     | 
    
         
            +
                out = capturing {
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @m.assert { 2 + 2 == 4 }
         
     | 
| 
      
 35 
     | 
    
         
            +
                }
         
     | 
| 
      
 36 
     | 
    
         
            +
                assert_equal "((2 + 2) == 4)\n", out
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              it "prints the message and contents of a successful assert" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                out = capturing {
         
     | 
| 
      
 41 
     | 
    
         
            +
                  @m.assert("basic math") { 2 + 2 == 4 }
         
     | 
| 
      
 42 
     | 
    
         
            +
                }
         
     | 
| 
      
 43 
     | 
    
         
            +
                assert_equal "basic math: ((2 + 2) == 4)\n", out
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
              
         
     | 
| 
      
 46 
     | 
    
         
            +
              it "prints in color" do
         
     | 
| 
      
 47 
     | 
    
         
            +
                Wrong.config.color
         
     | 
| 
      
 48 
     | 
    
         
            +
                Sickill::Rainbow.enabled = true
         
     | 
| 
      
 49 
     | 
    
         
            +
                out = capturing {
         
     | 
| 
      
 50 
     | 
    
         
            +
                  @m.assert { 2 + 2 == 4 }
         
     | 
| 
      
 51 
     | 
    
         
            +
                }
         
     | 
| 
      
 52 
     | 
    
         
            +
                colored = ["((2 + 2) == 4)".color(:green), "\n"].join
         
     | 
| 
      
 53 
     | 
    
         
            +
                assert_equal colored, out
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              it "prints in color with an explanation" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                Wrong.config.color
         
     | 
| 
      
 58 
     | 
    
         
            +
                Sickill::Rainbow.enabled = true
         
     | 
| 
      
 59 
     | 
    
         
            +
                out = capturing {
         
     | 
| 
      
 60 
     | 
    
         
            +
                  @m.assert("basic math") { 2 + 2 == 4 }
         
     | 
| 
      
 61 
     | 
    
         
            +
                }
         
     | 
| 
      
 62 
     | 
    
         
            +
                colored = ["basic math".color(:blue), ": ", "((2 + 2) == 4)".color(:green), "\n"].join
         
     | 
| 
      
 63 
     | 
    
         
            +
                assert_equal colored, out
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: wrong
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: java
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,11 +10,11 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2012-02-03 00:00:00.000000000Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: predicated
         
     | 
| 
       17 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 17 
     | 
    
         
            +
              requirement: &70228833367520 !ruby/object:Gem::Requirement
         
     | 
| 
       18 
18 
     | 
    
         
             
                none: false
         
     | 
| 
       19 
19 
     | 
    
         
             
                requirements:
         
     | 
| 
       20 
20 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -22,10 +22,10 @@ dependencies: 
     | 
|
| 
       22 
22 
     | 
    
         
             
                    version: 0.2.3
         
     | 
| 
       23 
23 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       24 
24 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       25 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 25 
     | 
    
         
            +
              version_requirements: *70228833367520
         
     | 
| 
       26 
26 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       27 
27 
     | 
    
         
             
              name: ruby_parser
         
     | 
| 
       28 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 28 
     | 
    
         
            +
              requirement: &70228833367020 !ruby/object:Gem::Requirement
         
     | 
| 
       29 
29 
     | 
    
         
             
                none: false
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - ~>
         
     | 
| 
         @@ -33,10 +33,10 @@ dependencies: 
     | 
|
| 
       33 
33 
     | 
    
         
             
                    version: 2.0.4
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: *70228833367020
         
     | 
| 
       37 
37 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       38 
38 
     | 
    
         
             
              name: ruby2ruby
         
     | 
| 
       39 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 39 
     | 
    
         
            +
              requirement: &70228833366560 !ruby/object:Gem::Requirement
         
     | 
| 
       40 
40 
     | 
    
         
             
                none: false
         
     | 
| 
       41 
41 
     | 
    
         
             
                requirements:
         
     | 
| 
       42 
42 
     | 
    
         
             
                - - ~>
         
     | 
| 
         @@ -44,10 +44,10 @@ dependencies: 
     | 
|
| 
       44 
44 
     | 
    
         
             
                    version: '1.2'
         
     | 
| 
       45 
45 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       46 
46 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       47 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 47 
     | 
    
         
            +
              version_requirements: *70228833366560
         
     | 
| 
       48 
48 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       49 
49 
     | 
    
         
             
              name: sexp_processor
         
     | 
| 
       50 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 50 
     | 
    
         
            +
              requirement: &70228833366100 !ruby/object:Gem::Requirement
         
     | 
| 
       51 
51 
     | 
    
         
             
                none: false
         
     | 
| 
       52 
52 
     | 
    
         
             
                requirements:
         
     | 
| 
       53 
53 
     | 
    
         
             
                - - ~>
         
     | 
| 
         @@ -55,10 +55,10 @@ dependencies: 
     | 
|
| 
       55 
55 
     | 
    
         
             
                    version: '3.0'
         
     | 
| 
       56 
56 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       57 
57 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       58 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 58 
     | 
    
         
            +
              version_requirements: *70228833366100
         
     | 
| 
       59 
59 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       60 
60 
     | 
    
         
             
              name: diff-lcs
         
     | 
| 
       61 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 61 
     | 
    
         
            +
              requirement: &70228833365640 !ruby/object:Gem::Requirement
         
     | 
| 
       62 
62 
     | 
    
         
             
                none: false
         
     | 
| 
       63 
63 
     | 
    
         
             
                requirements:
         
     | 
| 
       64 
64 
     | 
    
         
             
                - - ~>
         
     | 
| 
         @@ -66,7 +66,7 @@ dependencies: 
     | 
|
| 
       66 
66 
     | 
    
         
             
                    version: 1.1.2
         
     | 
| 
       67 
67 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       68 
68 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       69 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 69 
     | 
    
         
            +
              version_requirements: *70228833365640
         
     | 
| 
       70 
70 
     | 
    
         
             
            description: ! 'Wrong provides a general assert method that takes a predicate block.
         
     | 
| 
       71 
71 
     | 
    
         
             
              Assertion failure
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
         @@ -151,6 +151,7 @@ files: 
     | 
|
| 
       151 
151 
     | 
    
         
             
            - test/string_comparison_test.rb
         
     | 
| 
       152 
152 
     | 
    
         
             
            - test/suite.rb
         
     | 
| 
       153 
153 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
| 
      
 154 
     | 
    
         
            +
            - test/verbose_test.rb
         
     | 
| 
       154 
155 
     | 
    
         
             
            - test/wrong_test.rb
         
     | 
| 
       155 
156 
     | 
    
         
             
            homepage: http://github.com/sconover/wrong
         
     | 
| 
       156 
157 
     | 
    
         
             
            licenses: []
         
     | 
| 
         @@ -166,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       166 
167 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       167 
168 
     | 
    
         
             
                  segments:
         
     | 
| 
       168 
169 
     | 
    
         
             
                  - 0
         
     | 
| 
       169 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 170 
     | 
    
         
            +
                  hash: 3739027713376098366
         
     | 
| 
       170 
171 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       171 
172 
     | 
    
         
             
              none: false
         
     | 
| 
       172 
173 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -223,4 +224,5 @@ test_files: 
     | 
|
| 
       223 
224 
     | 
    
         
             
            - test/string_comparison_test.rb
         
     | 
| 
       224 
225 
     | 
    
         
             
            - test/suite.rb
         
     | 
| 
       225 
226 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
| 
      
 227 
     | 
    
         
            +
            - test/verbose_test.rb
         
     | 
| 
       226 
228 
     | 
    
         
             
            - test/wrong_test.rb
         
     |