solid_assert 0.7.2 → 1.1.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.
- checksums.yaml +7 -0
 - data/.gitignore +9 -0
 - data/.rspec +1 -0
 - data/.travis.yml +3 -0
 - data/Gemfile +1 -15
 - data/README.md +54 -29
 - data/Rakefile +4 -47
 - data/lib/solid_assert/assert.rb +27 -17
 - data/lib/solid_assert/assertion_failed_error.rb +1 -8
 - data/lib/solid_assert/null_assert.rb +9 -6
 - data/lib/solid_assert/version.rb +3 -0
 - data/lib/solid_assert.rb +29 -5
 - data/solid_assert.gemspec +18 -60
 - metadata +70 -113
 - data/.document +0 -5
 - data/VERSION +0 -1
 - data/lib/solid_assert/solid_assert.rb +0 -12
 - data/spec/solid_assert/assert_spec.rb +0 -50
 - data/spec/solid_assert/null_assert_spec.rb +0 -31
 - data/spec/solid_assert/solid_assert_spec.rb +0 -25
 - data/spec/spec_helper.rb +0 -13
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4627026d63e35103c5c22f19de8c4ef776ebc1d172d4bc897813c315aec1c731
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e98bfadd3b7a5e26ba087ebcb7a88167bbea26f5c279684dcc55bf292ca55813
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 03b063229bc1eab36ca5787178262b5ff579d04494e78ae66b3cec5b5afcca318024f7161a2dcf1b616d8b87b006085f9fff6c8def64eb387cab010f029f4ba5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f041e3d8d4ac25f60ac82a65c2395816f9d96edd6fc8124bc7bb866c3169b9f541a8622f513f67b314106d51ac2de982a4607bf6442d4f2108dc91c93ab06909
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    CHANGED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -1,17 +1,3 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            source "http://rubygems.org"
         
     | 
| 
       2 
     | 
    
         
            -
            # Add dependencies required to use your gem here.
         
     | 
| 
       3 
     | 
    
         
            -
            # Example:
         
     | 
| 
       4 
     | 
    
         
            -
            #   gem "activesupport", ">= 2.3.5"
         
     | 
| 
       5 
2 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            # Include everything needed to run rake, tests, features, etc.
         
     | 
| 
       8 
     | 
    
         
            -
            group :development do
         
     | 
| 
       9 
     | 
    
         
            -
              gem "rspec", "~> 2.3.0"
         
     | 
| 
       10 
     | 
    
         
            -
              gem "bundler", "~> 1.0.0"
         
     | 
| 
       11 
     | 
    
         
            -
              gem "jeweler", "~> 1.6.4"
         
     | 
| 
       12 
     | 
    
         
            -
              gem "rcov", ">= 0"
         
     | 
| 
       13 
     | 
    
         
            -
            end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            group :test do
         
     | 
| 
       16 
     | 
    
         
            -
              gem 'ZenTest'
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
| 
      
 3 
     | 
    
         
            +
            gemspec
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,54 +1,79 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # solid_assert
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            [](https://travis-ci.org/jorgemanrubia/solid_assert)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            *solid_assert* is a simple implementation of an `assert` utility in Ruby. It lets you write tests for your assumptions while coding.
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
7 
     | 
    
         
             
            Assertions are meant to test conditions about the integrity of your code. You should use them for testing assumptions like the following:
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
            - If the flow reaches here, then this variable has to have this value.
         
     | 
| 
       8 
10 
     | 
    
         
             
            - This line of code should never be executed.
         
     | 
| 
       9 
     | 
    
         
            -
            - At this point, this list should contain one entry for  
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            Notice that assertions shouldn't be used for handling error situations. Use Ruby built-in exception handling for that.
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            Assertions are typically used in development mode. You might want to disable them in production for performance reasons.
         
     | 
| 
      
 11 
     | 
    
         
            +
            - At this point, this list should contain one entry for each key in this hash.
         
     | 
| 
       14 
12 
     | 
    
         | 
| 
       15 
13 
     | 
    
         
             
            # Installation
         
     | 
| 
       16 
14 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
            Add to your `Gemfile`:
         
     | 
| 
       18 
16 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 18 
     | 
    
         
            +
            gem "solid_assert"
         
     | 
| 
      
 19 
     | 
    
         
            +
            ```
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            # Usage
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            You can enable assertions with
         
     | 
| 
      
 23 
     | 
    
         
            +
            You can enable/disable assertions with:
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 26 
     | 
    
         
            +
            SolidAssert.enable_assertions
         
     | 
| 
      
 27 
     | 
    
         
            +
            SolidAssert.disable_assertions
         
     | 
| 
      
 28 
     | 
    
         
            +
            ```
         
     | 
| 
       26 
29 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
            Assertions are disabled by default.
         
     | 
| 
      
 30 
     | 
    
         
            +
            Assertions are disabled by default and are typically used in development mode only. You might want to disable them in production for performance reasons.
         
     | 
| 
       28 
31 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
            Use `assert` for testing conditions. You can optionally provide  
     | 
| 
      
 32 
     | 
    
         
            +
            Use `assert` for testing conditions. You can optionally provide an error message.
         
     | 
| 
       30 
33 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            Use `invariant` for testing blocks of code. This comes handy when testing your assumptions requires several lines of code. You can provide an optional message if you want
         
     | 
| 
      
 34 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 35 
     | 
    
         
            +
            assert some_string != "unexpected value"
         
     | 
| 
      
 36 
     | 
    
         
            +
            assert user.authenticated?
         
     | 
| 
       35 
37 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
            		one_variable > other_variable
         
     | 
| 
       40 
     | 
    
         
            -
            	end
         
     | 
| 
      
 38 
     | 
    
         
            +
            assert apples_count > 5, "Not enough apples!"
         
     | 
| 
      
 39 
     | 
    
         
            +
            assert !clients.empty?, "The list must NOT be empty!"
         
     | 
| 
      
 40 
     | 
    
         
            +
            ```
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
            		one_variable > other_variable
         
     | 
| 
       46 
     | 
    
         
            -
            	end
         
     | 
| 
      
 42 
     | 
    
         
            +
            Use `invariant` for testing blocks of code. This comes handy
         
     | 
| 
      
 43 
     | 
    
         
            +
            when testing your assumptions requires several lines of code.
         
     | 
| 
      
 44 
     | 
    
         
            +
            You can provide an optional message too.
         
     | 
| 
       47 
45 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 47 
     | 
    
         
            +
            invariant do
         
     | 
| 
      
 48 
     | 
    
         
            +
              one_variable = calculate_some_value
         
     | 
| 
      
 49 
     | 
    
         
            +
              other_variable = calculate_some_other_value
         
     | 
| 
      
 50 
     | 
    
         
            +
              one_variable > other_variable
         
     | 
| 
      
 51 
     | 
    
         
            +
            end
         
     | 
| 
      
 52 
     | 
    
         
            +
            ```
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 55 
     | 
    
         
            +
            invariant "Lists must have equal sizes!" do
         
     | 
| 
      
 56 
     | 
    
         
            +
              len = calculate_list_length
         
     | 
| 
      
 57 
     | 
    
         
            +
              other_len = calculate_other_list_length
         
     | 
| 
      
 58 
     | 
    
         
            +
              len == other_len
         
     | 
| 
      
 59 
     | 
    
         
            +
            end
         
     | 
| 
      
 60 
     | 
    
         
            +
            ```
         
     | 
| 
       49 
61 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
            - [Writing Solid Code](http://www.amazon.com/Writing-Solid-Code-Microsoft-Programming/dp/1556155514). A great book on good coding design practices. Again, it based in C, but the practices it talks about apply to coding in any programming language.
         
     | 
| 
      
 62 
     | 
    
         
            +
            ### Assertion Error
         
     | 
| 
       52 
63 
     | 
    
         | 
| 
      
 64 
     | 
    
         
            +
            Failed assertion will raise `SolidAssert::AssertionFailedError` error. You shouldn't catch it in a `rescue` block! If it raised then something is wrong with either your code or with you assumption. *Assertions shouldn't be used for handling error situations!* Use Ruby built-in exception handling for that.
         
     | 
| 
       53 
65 
     | 
    
         | 
| 
      
 66 
     | 
    
         
            +
            ## Rails
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            Create a file named `solid_assert.rb` in the `config/initializers` dir with the following content:
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 71 
     | 
    
         
            +
            SolidAssert.enable_assertions unless Rails.env.production?
         
     | 
| 
      
 72 
     | 
    
         
            +
            ```
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            This way assertions will be disabled in production and enabled in the rest of environments.
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            ## References
         
     | 
| 
       54 
77 
     | 
    
         | 
| 
      
 78 
     | 
    
         
            +
            - [Programming with assertions](https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html). A great article on assertions. It is about the Java language, but the concepts apply to any programming language.
         
     | 
| 
      
 79 
     | 
    
         
            +
            - There are good references to assertive programming in some classic books like [The Pragmatic Programmer From Journeyman to Master](http://www.amazon.com/exec/obidos/ASIN/020161622X/ref=nosim/jorgmanrpersp-20), [Code Complete](http://www.amazon.com/exec/obidos/ASIN/0735619670/ref=nosim/jorgmanrpersp-20) and [Writing solid code](http://www.amazon.com/exec/obidos/ASIN/1556155514/ref=nosim/jorgmanrpersp-20)
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,49 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require "bundler/gem_tasks"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "rspec/core/rake_task"
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            require 'bundler'
         
     | 
| 
       5 
     | 
    
         
            -
            begin
         
     | 
| 
       6 
     | 
    
         
            -
              Bundler.setup(:default, :development)
         
     | 
| 
       7 
     | 
    
         
            -
            rescue Bundler::BundlerError => e
         
     | 
| 
       8 
     | 
    
         
            -
              $stderr.puts e.message
         
     | 
| 
       9 
     | 
    
         
            -
              $stderr.puts "Run `bundle install` to install missing gems"
         
     | 
| 
       10 
     | 
    
         
            -
              exit e.status_code
         
     | 
| 
       11 
     | 
    
         
            -
            end
         
     | 
| 
       12 
     | 
    
         
            -
            require 'rake'
         
     | 
| 
      
 4 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:spec)
         
     | 
| 
       13 
5 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            Jeweler::Tasks.new do |gem|
         
     | 
| 
       16 
     | 
    
         
            -
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         
     | 
| 
       17 
     | 
    
         
            -
              gem.name = "solid_assert"
         
     | 
| 
       18 
     | 
    
         
            -
              gem.homepage = "http://github.com/jorgemanrubia/solid_assert"
         
     | 
| 
       19 
     | 
    
         
            -
              gem.license = "MIT"
         
     | 
| 
       20 
     | 
    
         
            -
              gem.summary = %Q{Assert utility for ruby}
         
     | 
| 
       21 
     | 
    
         
            -
              gem.description = %Q{Assert utility for ruby. It let you code your assumptions and code invariants, so they are checked automatically. It can be deactivated, so you it doesn't affect to your program performance (for example, in production)'}
         
     | 
| 
       22 
     | 
    
         
            -
              gem.email = "jorge.manrubia@gmail.com"
         
     | 
| 
       23 
     | 
    
         
            -
              gem.authors = ["Jorge Manrubia"]
         
     | 
| 
       24 
     | 
    
         
            -
              # dependencies defined in Gemfile
         
     | 
| 
       25 
     | 
    
         
            -
            end
         
     | 
| 
       26 
     | 
    
         
            -
            Jeweler::RubygemsDotOrgTasks.new
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            require 'rspec/core'
         
     | 
| 
       29 
     | 
    
         
            -
            require 'rspec/core/rake_task'
         
     | 
| 
       30 
     | 
    
         
            -
            RSpec::Core::RakeTask.new(:spec) do |spec|
         
     | 
| 
       31 
     | 
    
         
            -
              spec.pattern = FileList['spec/**/*_spec.rb']
         
     | 
| 
       32 
     | 
    
         
            -
            end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            RSpec::Core::RakeTask.new(:rcov) do |spec|
         
     | 
| 
       35 
     | 
    
         
            -
              spec.pattern = 'spec/**/*_spec.rb'
         
     | 
| 
       36 
     | 
    
         
            -
              spec.rcov = true
         
     | 
| 
       37 
     | 
    
         
            -
            end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
            task :default => :spec
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            require 'rake/rdoctask'
         
     | 
| 
       42 
     | 
    
         
            -
            Rake::RDocTask.new do |rdoc|
         
     | 
| 
       43 
     | 
    
         
            -
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
       46 
     | 
    
         
            -
              rdoc.title = "solid_assert #{version}"
         
     | 
| 
       47 
     | 
    
         
            -
              rdoc.rdoc_files.include('README*')
         
     | 
| 
       48 
     | 
    
         
            -
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
       49 
     | 
    
         
            -
            end
         
     | 
| 
      
 6 
     | 
    
         
            +
            task default: :spec
         
     | 
    
        data/lib/solid_assert/assert.rb
    CHANGED
    
    | 
         @@ -1,21 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "singleton"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "solid_assert/assertion_failed_error"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
       1 
4 
     | 
    
         
             
            module SolidAssert
         
     | 
| 
       2 
     | 
    
         
            -
              module Assert
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
              # Actual assertions implementation
         
     | 
| 
      
 7 
     | 
    
         
            +
              class Assert
         
     | 
| 
      
 8 
     | 
    
         
            +
                include Singleton
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                # Check if a condition is truthy and fail if it is not.
         
     | 
| 
       5 
11 
     | 
    
         
             
                #
         
     | 
| 
       6 
     | 
    
         
            -
                # Usage
         
     | 
| 
       7 
     | 
    
         
            -
                #   assert  
     | 
| 
       8 
     | 
    
         
            -
                #   assert  
     | 
| 
       9 
     | 
    
         
            -
                #   assert !list.empty?, "The list should not be empty at this point"
         
     | 
| 
      
 12 
     | 
    
         
            +
                # Usage:
         
     | 
| 
      
 13 
     | 
    
         
            +
                #   assert expr  # raise SolidAssert::AssertionFailedError if expr is falsy
         
     | 
| 
      
 14 
     | 
    
         
            +
                #   assert !list.empty?, "The list should not be empty"  # optional error message
         
     | 
| 
       10 
15 
     | 
    
         
             
                #
         
     | 
| 
       11 
     | 
    
         
            -
                # @param condition  
     | 
| 
       12 
     | 
    
         
            -
                # @param message  
     | 
| 
      
 16 
     | 
    
         
            +
                # @param condition A condition to assert
         
     | 
| 
      
 17 
     | 
    
         
            +
                # @param message An optional error message
         
     | 
| 
       13 
18 
     | 
    
         
             
                # @raise {AssertionFailedError} when the condition is not satisfied
         
     | 
| 
       14 
     | 
    
         
            -
                def assert(condition, message=nil)
         
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
      
 19 
     | 
    
         
            +
                def assert(condition, message = nil)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  fail SolidAssert::AssertionFailedError.new(message) if !condition
         
     | 
| 
       16 
21 
     | 
    
         
             
                end
         
     | 
| 
       17 
22 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                # Let you {#assert} a block of code. 
     | 
| 
      
 23 
     | 
    
         
            +
                # Let you {#assert} a block of code.
         
     | 
| 
      
 24 
     | 
    
         
            +
                #
         
     | 
| 
      
 25 
     | 
    
         
            +
                # It comes handy when your assertion requires more than one line of code.
         
     | 
| 
      
 26 
     | 
    
         
            +
                # An assertion is performed on the result of the provided block evaluation.
         
     | 
| 
      
 27 
     | 
    
         
            +
                #
         
     | 
| 
       19 
28 
     | 
    
         
             
                # Usage:
         
     | 
| 
       20 
29 
     | 
    
         
             
                #   invariant do
         
     | 
| 
       21 
30 
     | 
    
         
             
                #     some_number = 1
         
     | 
| 
         @@ -23,14 +32,15 @@ module SolidAssert 
     | 
|
| 
       23 
32 
     | 
    
         
             
                #     some_number == other_number
         
     | 
| 
       24 
33 
     | 
    
         
             
                #   end
         
     | 
| 
       25 
34 
     | 
    
         
             
                #
         
     | 
| 
       26 
     | 
    
         
            -
                #   invariant "Both numbers should be equal" do
         
     | 
| 
       27 
     | 
    
         
            -
                #      
     | 
| 
       28 
     | 
    
         
            -
                #     other_number = 2
         
     | 
| 
      
 35 
     | 
    
         
            +
                #   invariant "Both numbers should be equal" do  # optional error message
         
     | 
| 
      
 36 
     | 
    
         
            +
                #     ...
         
     | 
| 
       29 
37 
     | 
    
         
             
                #     some_number == other_number
         
     | 
| 
       30 
38 
     | 
    
         
             
                #   end
         
     | 
| 
       31 
     | 
    
         
            -
                # 
     | 
| 
       32 
     | 
    
         
            -
                # @ 
     | 
| 
       33 
     | 
    
         
            -
                 
     | 
| 
      
 39 
     | 
    
         
            +
                #
         
     | 
| 
      
 40 
     | 
    
         
            +
                # @param message An optional error message
         
     | 
| 
      
 41 
     | 
    
         
            +
                # @raise {AssertionFailedError} when the condition is not satisfied
         
     | 
| 
      
 42 
     | 
    
         
            +
                # @yield A block of code
         
     | 
| 
      
 43 
     | 
    
         
            +
                def invariant(message = nil)
         
     | 
| 
       34 
44 
     | 
    
         
             
                  assert yield, message
         
     | 
| 
       35 
45 
     | 
    
         
             
                end
         
     | 
| 
       36 
46 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,14 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "singleton"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module SolidAssert
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
              # Null  
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
      
 5 
     | 
    
         
            +
              # Null assertions implementation (used when the assertions are disabled).
         
     | 
| 
      
 6 
     | 
    
         
            +
              class NullAssert
         
     | 
| 
      
 7 
     | 
    
         
            +
                include Singleton
         
     | 
| 
       5 
8 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
                # Empty implemention of {Assert#assert}
         
     | 
| 
       7 
     | 
    
         
            -
                def assert(condition, message=nil)
         
     | 
| 
      
 9 
     | 
    
         
            +
                # Empty implemention of {Assert#assert}.
         
     | 
| 
      
 10 
     | 
    
         
            +
                def assert(condition, message = nil)
         
     | 
| 
       8 
11 
     | 
    
         
             
                end
         
     | 
| 
       9 
12 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                # Empty implemention of {Assert#invariant}
         
     | 
| 
       11 
     | 
    
         
            -
                def invariant(message=nil)
         
     | 
| 
      
 13 
     | 
    
         
            +
                # Empty implemention of {Assert#invariant}.
         
     | 
| 
      
 14 
     | 
    
         
            +
                def invariant(message = nil)
         
     | 
| 
       12 
15 
     | 
    
         
             
                end
         
     | 
| 
       13 
16 
     | 
    
         
             
              end
         
     | 
| 
       14 
17 
     | 
    
         
             
            end
         
     | 
    
        data/lib/solid_assert.rb
    CHANGED
    
    | 
         @@ -1,9 +1,33 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require "forwardable"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "solid_assert/null_assert"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "solid_assert/assert"
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
      
 5 
     | 
    
         
            +
            module SolidAssert
         
     | 
| 
      
 6 
     | 
    
         
            +
              extend Forwardable
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              def_delegators "SolidAssert.assert_instance", :assert, :invariant
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 11 
     | 
    
         
            +
                def assert_instance
         
     | 
| 
      
 12 
     | 
    
         
            +
                  if @assertions_enabled
         
     | 
| 
      
 13 
     | 
    
         
            +
                    Assert.instance
         
     | 
| 
      
 14 
     | 
    
         
            +
                  else
         
     | 
| 
      
 15 
     | 
    
         
            +
                    NullAssert.instance
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                def enable_assertions
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @assertions_enabled = true
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                def disable_assertions
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @assertions_enabled = false
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
       7 
27 
     | 
    
         
             
            end
         
     | 
| 
       8 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
            SolidAssert.disable_assertions
         
     | 
| 
       9 
30 
     | 
    
         | 
| 
      
 31 
     | 
    
         
            +
            Object.class_eval do
         
     | 
| 
      
 32 
     | 
    
         
            +
              include SolidAssert
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
    
        data/solid_assert.gemspec
    CHANGED
    
    | 
         @@ -1,65 +1,23 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 1 
     | 
    
         
            +
            lib = File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "solid_assert/version"
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            Gem::Specification.new do | 
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 6 
     | 
    
         
            +
              spec.name          = "solid_assert"
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.version       = SolidAssert::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.authors       = ["Jorge Manrubia"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.email         = ["jorge.manrubia@gmail.com"]
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
       11 
     | 
    
         
            -
               
     | 
| 
       12 
     | 
    
         
            -
               
     | 
| 
       13 
     | 
    
         
            -
               
     | 
| 
       14 
     | 
    
         
            -
               
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
       16 
     | 
    
         
            -
                "LICENSE.txt",
         
     | 
| 
       17 
     | 
    
         
            -
                "README.md"
         
     | 
| 
       18 
     | 
    
         
            -
              ]
         
     | 
| 
       19 
     | 
    
         
            -
              s.files = [
         
     | 
| 
       20 
     | 
    
         
            -
                ".document",
         
     | 
| 
       21 
     | 
    
         
            -
                ".rspec",
         
     | 
| 
       22 
     | 
    
         
            -
                "Gemfile",
         
     | 
| 
       23 
     | 
    
         
            -
                "LICENSE.txt",
         
     | 
| 
       24 
     | 
    
         
            -
                "README.md",
         
     | 
| 
       25 
     | 
    
         
            -
                "Rakefile",
         
     | 
| 
       26 
     | 
    
         
            -
                "VERSION",
         
     | 
| 
       27 
     | 
    
         
            -
                "lib/solid_assert.rb",
         
     | 
| 
       28 
     | 
    
         
            -
                "lib/solid_assert/assert.rb",
         
     | 
| 
       29 
     | 
    
         
            -
                "lib/solid_assert/assertion_failed_error.rb",
         
     | 
| 
       30 
     | 
    
         
            -
                "lib/solid_assert/null_assert.rb",
         
     | 
| 
       31 
     | 
    
         
            -
                "lib/solid_assert/solid_assert.rb",
         
     | 
| 
       32 
     | 
    
         
            -
                "solid_assert.gemspec",
         
     | 
| 
       33 
     | 
    
         
            -
                "spec/solid_assert/assert_spec.rb",
         
     | 
| 
       34 
     | 
    
         
            -
                "spec/solid_assert/null_assert_spec.rb",
         
     | 
| 
       35 
     | 
    
         
            -
                "spec/solid_assert/solid_assert_spec.rb",
         
     | 
| 
       36 
     | 
    
         
            -
                "spec/spec_helper.rb"
         
     | 
| 
       37 
     | 
    
         
            -
              ]
         
     | 
| 
       38 
     | 
    
         
            -
              s.homepage = %q{http://github.com/jorgemanrubia/solid_assert}
         
     | 
| 
       39 
     | 
    
         
            -
              s.licenses = [%q{MIT}]
         
     | 
| 
       40 
     | 
    
         
            -
              s.require_paths = [%q{lib}]
         
     | 
| 
       41 
     | 
    
         
            -
              s.rubygems_version = %q{1.8.6}
         
     | 
| 
       42 
     | 
    
         
            -
              s.summary = %q{Assert utility for ruby}
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = %q{Assert utility for ruby}
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = %q{Assert utility for ruby. It lets you code your assumptions and code invariants, so they are checked automatically. It can be deactivated, so you it doesn't affect to your program performance (for example, in production).}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://github.com/jorgemanrubia/solid_assert"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         
     | 
| 
      
 16 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
       43 
17 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
               
     | 
| 
       45 
     | 
    
         
            -
                s.specification_version = 3
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.required_ruby_version = ">= 2.3"
         
     | 
| 
       46 
19 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
         
     | 
| 
       51 
     | 
    
         
            -
                  s.add_development_dependency(%q<rcov>, [">= 0"])
         
     | 
| 
       52 
     | 
    
         
            -
                else
         
     | 
| 
       53 
     | 
    
         
            -
                  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         
     | 
| 
       54 
     | 
    
         
            -
                  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
       55 
     | 
    
         
            -
                  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
         
     | 
| 
       56 
     | 
    
         
            -
                  s.add_dependency(%q<rcov>, [">= 0"])
         
     | 
| 
       57 
     | 
    
         
            -
                end
         
     | 
| 
       58 
     | 
    
         
            -
              else
         
     | 
| 
       59 
     | 
    
         
            -
                s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         
     | 
| 
       60 
     | 
    
         
            -
                s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
       61 
     | 
    
         
            -
                s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
         
     | 
| 
       62 
     | 
    
         
            -
                s.add_dependency(%q<rcov>, [">= 0"])
         
     | 
| 
       63 
     | 
    
         
            -
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 2.0"
         
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 13.0"
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_development_dependency "rspec", "~> 3.4"
         
     | 
| 
       64 
23 
     | 
    
         
             
            end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,143 +1,100 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --- !ruby/object:Gem::Specification 
     | 
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: solid_assert
         
     | 
| 
       3 
     | 
    
         
            -
            version: !ruby/object:Gem::Version 
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
              prerelease: 
         
     | 
| 
       6 
     | 
    
         
            -
              segments: 
         
     | 
| 
       7 
     | 
    
         
            -
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              - 7
         
     | 
| 
       9 
     | 
    
         
            -
              - 2
         
     | 
| 
       10 
     | 
    
         
            -
              version: 0.7.2
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.1.0
         
     | 
| 
       11 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
     | 
    
         
            -
            authors: 
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
       13 
7 
     | 
    
         
             
            - Jorge Manrubia
         
     | 
| 
       14 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       15 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       21 
     | 
    
         
            -
              type: :development
         
     | 
| 
       22 
     | 
    
         
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
       23 
     | 
    
         
            -
                none: false
         
     | 
| 
       24 
     | 
    
         
            -
                requirements: 
         
     | 
| 
       25 
     | 
    
         
            -
                - - ~>
         
     | 
| 
       26 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
         
     | 
| 
       27 
     | 
    
         
            -
                    hash: 3
         
     | 
| 
       28 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       29 
     | 
    
         
            -
                    - 2
         
     | 
| 
       30 
     | 
    
         
            -
                    - 3
         
     | 
| 
       31 
     | 
    
         
            -
                    - 0
         
     | 
| 
       32 
     | 
    
         
            -
                    version: 2.3.0
         
     | 
| 
       33 
     | 
    
         
            -
              version_requirements: *id001
         
     | 
| 
       34 
     | 
    
         
            -
              name: rspec
         
     | 
| 
       35 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       36 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       37 
     | 
    
         
            -
              type: :development
         
     | 
| 
       38 
     | 
    
         
            -
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
       39 
     | 
    
         
            -
                none: false
         
     | 
| 
       40 
     | 
    
         
            -
                requirements: 
         
     | 
| 
       41 
     | 
    
         
            -
                - - ~>
         
     | 
| 
       42 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
         
     | 
| 
       43 
     | 
    
         
            -
                    hash: 23
         
     | 
| 
       44 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       45 
     | 
    
         
            -
                    - 1
         
     | 
| 
       46 
     | 
    
         
            -
                    - 0
         
     | 
| 
       47 
     | 
    
         
            -
                    - 0
         
     | 
| 
       48 
     | 
    
         
            -
                    version: 1.0.0
         
     | 
| 
       49 
     | 
    
         
            -
              version_requirements: *id002
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-09-22 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
       50 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
       51 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '13.0'
         
     | 
| 
       53 
34 
     | 
    
         
             
              type: :development
         
     | 
| 
       54 
     | 
    
         
            -
              requirement: &id003 !ruby/object:Gem::Requirement 
         
     | 
| 
       55 
     | 
    
         
            -
                none: false
         
     | 
| 
       56 
     | 
    
         
            -
                requirements: 
         
     | 
| 
       57 
     | 
    
         
            -
                - - ~>
         
     | 
| 
       58 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
         
     | 
| 
       59 
     | 
    
         
            -
                    hash: 7
         
     | 
| 
       60 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       61 
     | 
    
         
            -
                    - 1
         
     | 
| 
       62 
     | 
    
         
            -
                    - 6
         
     | 
| 
       63 
     | 
    
         
            -
                    - 4
         
     | 
| 
       64 
     | 
    
         
            -
                    version: 1.6.4
         
     | 
| 
       65 
     | 
    
         
            -
              version_requirements: *id003
         
     | 
| 
       66 
     | 
    
         
            -
              name: jeweler
         
     | 
| 
       67 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '13.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '3.4'
         
     | 
| 
       69 
48 
     | 
    
         
             
              type: :development
         
     | 
| 
       70 
     | 
    
         
            -
              requirement: &id004 !ruby/object:Gem::Requirement 
         
     | 
| 
       71 
     | 
    
         
            -
                none: false
         
     | 
| 
       72 
     | 
    
         
            -
                requirements: 
         
     | 
| 
       73 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       74 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
         
     | 
| 
       75 
     | 
    
         
            -
                    hash: 3
         
     | 
| 
       76 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       77 
     | 
    
         
            -
                    - 0
         
     | 
| 
       78 
     | 
    
         
            -
                    version: "0"
         
     | 
| 
       79 
     | 
    
         
            -
              version_requirements: *id004
         
     | 
| 
       80 
     | 
    
         
            -
              name: rcov
         
     | 
| 
       81 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '3.4'
         
     | 
| 
      
 55 
     | 
    
         
            +
            description: Assert utility for ruby. It lets you code your assumptions and code invariants,
         
     | 
| 
      
 56 
     | 
    
         
            +
              so they are checked automatically. It can be deactivated, so you it doesn't affect
         
     | 
| 
      
 57 
     | 
    
         
            +
              to your program performance (for example, in production).
         
     | 
| 
      
 58 
     | 
    
         
            +
            email:
         
     | 
| 
      
 59 
     | 
    
         
            +
            - jorge.manrubia@gmail.com
         
     | 
| 
       84 
60 
     | 
    
         
             
            executables: []
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
61 
     | 
    
         
             
            extensions: []
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            -  
     | 
| 
       90 
     | 
    
         
            -
            -  
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
            - .document
         
     | 
| 
       93 
     | 
    
         
            -
            - .rspec
         
     | 
| 
      
 62 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 63 
     | 
    
         
            +
            files:
         
     | 
| 
      
 64 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 65 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
      
 66 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
       94 
67 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       95 
68 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       96 
69 
     | 
    
         
             
            - README.md
         
     | 
| 
       97 
70 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       98 
     | 
    
         
            -
            - VERSION
         
     | 
| 
       99 
71 
     | 
    
         
             
            - lib/solid_assert.rb
         
     | 
| 
       100 
72 
     | 
    
         
             
            - lib/solid_assert/assert.rb
         
     | 
| 
       101 
73 
     | 
    
         
             
            - lib/solid_assert/assertion_failed_error.rb
         
     | 
| 
       102 
74 
     | 
    
         
             
            - lib/solid_assert/null_assert.rb
         
     | 
| 
       103 
     | 
    
         
            -
            - lib/solid_assert/ 
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/solid_assert/version.rb
         
     | 
| 
       104 
76 
     | 
    
         
             
            - solid_assert.gemspec
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
            - spec/solid_assert/solid_assert_spec.rb
         
     | 
| 
       108 
     | 
    
         
            -
            - spec/spec_helper.rb
         
     | 
| 
       109 
     | 
    
         
            -
            homepage: http://github.com/jorgemanrubia/solid_assert
         
     | 
| 
       110 
     | 
    
         
            -
            licenses: 
         
     | 
| 
      
 77 
     | 
    
         
            +
            homepage: https://github.com/jorgemanrubia/solid_assert
         
     | 
| 
      
 78 
     | 
    
         
            +
            licenses:
         
     | 
| 
       111 
79 
     | 
    
         
             
            - MIT
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
      
 80 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 81 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       113 
82 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
            require_paths: 
         
     | 
| 
      
 83 
     | 
    
         
            +
            require_paths:
         
     | 
| 
       116 
84 
     | 
    
         
             
            - lib
         
     | 
| 
       117 
     | 
    
         
            -
            required_ruby_version: !ruby/object:Gem::Requirement 
     | 
| 
       118 
     | 
    
         
            -
               
     | 
| 
       119 
     | 
    
         
            -
              requirements: 
         
     | 
| 
      
 85 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 86 
     | 
    
         
            +
              requirements:
         
     | 
| 
       120 
87 
     | 
    
         
             
              - - ">="
         
     | 
| 
       121 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       122 
     | 
    
         
            -
                   
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                  version: "0"
         
     | 
| 
       126 
     | 
    
         
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       127 
     | 
    
         
            -
              none: false
         
     | 
| 
       128 
     | 
    
         
            -
              requirements: 
         
     | 
| 
      
 88 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 89 
     | 
    
         
            +
                  version: '2.3'
         
     | 
| 
      
 90 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 91 
     | 
    
         
            +
              requirements:
         
     | 
| 
       129 
92 
     | 
    
         
             
              - - ">="
         
     | 
| 
       130 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       131 
     | 
    
         
            -
                   
     | 
| 
       132 
     | 
    
         
            -
                  segments: 
         
     | 
| 
       133 
     | 
    
         
            -
                  - 0
         
     | 
| 
       134 
     | 
    
         
            -
                  version: "0"
         
     | 
| 
      
 93 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 94 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       135 
95 
     | 
    
         
             
            requirements: []
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
       140 
     | 
    
         
            -
            specification_version: 3
         
     | 
| 
      
 96 
     | 
    
         
            +
            rubygems_version: 3.1.4
         
     | 
| 
      
 97 
     | 
    
         
            +
            signing_key:
         
     | 
| 
      
 98 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
       141 
99 
     | 
    
         
             
            summary: Assert utility for ruby
         
     | 
| 
       142 
100 
     | 
    
         
             
            test_files: []
         
     | 
| 
       143 
     | 
    
         
            -
             
     | 
    
        data/.document
    DELETED
    
    
    
        data/VERSION
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.7.2
         
     | 
| 
         @@ -1,50 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "spec_helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe SolidAssert::Assert do
         
     | 
| 
       4 
     | 
    
         
            -
              include SolidAssert::Assert
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              describe "#assert" do
         
     | 
| 
       7 
     | 
    
         
            -
                describe "without assertion message" do
         
     | 
| 
       8 
     | 
    
         
            -
                  it "should fail when condition is false" do
         
     | 
| 
       9 
     | 
    
         
            -
                    expect { assert false }.to raise_error SolidAssert::AssertionFailedError
         
     | 
| 
       10 
     | 
    
         
            -
                  end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  it "should fail when condition evaluates to false" do
         
     | 
| 
       13 
     | 
    
         
            -
                    expect { assert nil }.to raise_error SolidAssert::AssertionFailedError
         
     | 
| 
       14 
     | 
    
         
            -
                  end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  it "should not fail when condition is true" do
         
     | 
| 
       17 
     | 
    
         
            -
                    expect { assert true }.to_not raise_error SolidAssert::AssertionFailedError
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                  it "should not fail when condition evaluates to true" do
         
     | 
| 
       21 
     | 
    
         
            -
                    expect { assert "This evaluates to true" }.to_not raise_error SolidAssert::AssertionFailedError
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
       23 
     | 
    
         
            -
                end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                describe "with assertion message" do
         
     | 
| 
       26 
     | 
    
         
            -
                  it "should raise error with specified message when condition evaluates to false" do
         
     | 
| 
       27 
     | 
    
         
            -
                    expect { assert nil, "The error message" }.to raise_error(SolidAssert::AssertionFailedError, "The error message")
         
     | 
| 
       28 
     | 
    
         
            -
                  end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                  it "should not raise any error when condition doesn't evaluate to false'" do
         
     | 
| 
       31 
     | 
    
         
            -
                    expect { assert 'This evaluates to true', "The error message" }.to_not raise_error(SolidAssert::AssertionFailedError)
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
              describe "#invariants" do
         
     | 
| 
       37 
     | 
    
         
            -
                it "should invoke assert with the provided block" do
         
     | 
| 
       38 
     | 
    
         
            -
                  self.should_receive(:assert).with('This is the invariant block', nil)
         
     | 
| 
       39 
     | 
    
         
            -
                  invariant { "This is the invariant block" }
         
     | 
| 
       40 
     | 
    
         
            -
                end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                it "should invoke assert with the provided block and the provided error message" do
         
     | 
| 
       43 
     | 
    
         
            -
                  self.should_receive(:assert).with('This is the invariant block', 'the error message')
         
     | 
| 
       44 
     | 
    
         
            -
                  invariant "the error message" do
         
     | 
| 
       45 
     | 
    
         
            -
                    "This is the invariant block"
         
     | 
| 
       46 
     | 
    
         
            -
                  end
         
     | 
| 
       47 
     | 
    
         
            -
                end
         
     | 
| 
       48 
     | 
    
         
            -
              end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,31 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "spec_helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe SolidAssert::NullAssert do
         
     | 
| 
       4 
     | 
    
         
            -
              include SolidAssert::NullAssert
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              describe "#assert" do
         
     | 
| 
       7 
     | 
    
         
            -
                it "should do nothing without message" do
         
     | 
| 
       8 
     | 
    
         
            -
                  assert false
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                it "should do nothing with message" do
         
     | 
| 
       12 
     | 
    
         
            -
                  assert false, "Some message"
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              describe "#invariants" do
         
     | 
| 
       17 
     | 
    
         
            -
                it "should do nothing without message" do
         
     | 
| 
       18 
     | 
    
         
            -
                  invariant do
         
     | 
| 
       19 
     | 
    
         
            -
                    false
         
     | 
| 
       20 
     | 
    
         
            -
                  end
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                it "should do nothing with message" do
         
     | 
| 
       24 
     | 
    
         
            -
                  invariant "Some message" do
         
     | 
| 
       25 
     | 
    
         
            -
                    false
         
     | 
| 
       26 
     | 
    
         
            -
                  end
         
     | 
| 
       27 
     | 
    
         
            -
                end
         
     | 
| 
       28 
     | 
    
         
            -
              end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
         @@ -1,25 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "spec_helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe SolidAssert::Assert do
         
     | 
| 
       4 
     | 
    
         
            -
              it "should enable the empty assert method by default" do
         
     | 
| 
       5 
     | 
    
         
            -
                assert false
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it "should enable the empty invariant method by default" do
         
     | 
| 
       9 
     | 
    
         
            -
                invariant{false}
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              describe ".enable_assertions" do
         
     | 
| 
       13 
     | 
    
         
            -
                it "should make the Object class to include the Assertions module" do
         
     | 
| 
       14 
     | 
    
         
            -
                  Object.should_receive(:include).with(SolidAssert::Assert)
         
     | 
| 
       15 
     | 
    
         
            -
                  SolidAssert.enable_assertions
         
     | 
| 
       16 
     | 
    
         
            -
                end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                it "should turn on the assertions" do
         
     | 
| 
       19 
     | 
    
         
            -
                  SolidAssert.enable_assertions
         
     | 
| 
       20 
     | 
    
         
            -
                  expect {assert false}.to raise_error(SolidAssert::AssertionFailedError)
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
    
        data/spec/spec_helper.rb
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         
     | 
| 
       2 
     | 
    
         
            -
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            require 'rspec'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'solid_assert'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            # Requires supporting files with custom matchers and macros, etc,
         
     | 
| 
       8 
     | 
    
         
            -
            # in ./support/ and its subdirectories.
         
     | 
| 
       9 
     | 
    
         
            -
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            RSpec.configure do |config|
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            end
         
     |