solid_assert 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 092c3b76b199657802d4b86d6116824fa2af9d3f
4
+ data.tar.gz: 95d740d95ec68db0322b2bdc7d527b89680059bc
5
+ SHA512:
6
+ metadata.gz: 8c29a0285557dce36c1b6724af7e8db9ea91906e7f2ee3828e491639091c165964f158faeca08d58cd11811ab3d363a787c0f45f41f4591e72be3676efa1afd9
7
+ data.tar.gz: bef2daed211dbd168b77f72e84c69a4231deffd29696c38a43864750442ebc604a97a602136baa5093264ff2bcd9772a879602d324f8f4e6188db888d6949b88
@@ -0,0 +1,9 @@
1
+ /rdoc
2
+ /doc
3
+ /.yardoc
4
+ /.bundle
5
+ /pkg
6
+ /.idea
7
+ /Gemfile.lock
8
+ /.ruby-version
9
+ /.ruby-gemset
data/.rspec CHANGED
@@ -1 +1,2 @@
1
+ --format=doc
1
2
  --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
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
- # Add dependencies to develop your gem here.
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,6 +1,8 @@
1
1
  # solid_assert
2
2
 
3
- *solid_assert* is a simple implementation of an `assert` utility in Ruby. It let you write tests for your assumptions while coding.
3
+ [![Build Status](https://travis-ci.org/jorgemanrubia/solid_assert.svg?branch=master)](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
 
@@ -14,7 +16,7 @@ Assertions are typically used in development mode. You might want to disable the
14
16
 
15
17
  # Installation
16
18
 
17
- In your `Gemfile`
19
+ Add to your `Gemfile`:
18
20
 
19
21
  ```ruby
20
22
  gem "solid_assert"
@@ -22,36 +24,41 @@ gem "solid_assert"
22
24
 
23
25
  # Usage
24
26
 
25
- You can enable assertions with
27
+ You can enable/disable assertions with:
26
28
 
27
29
  ```ruby
28
30
  SolidAssert.enable_assertions
31
+ SolidAssert.disable_assertions
29
32
  ```
30
33
 
31
34
  Assertions are disabled by default.
32
35
 
33
- Use `assert` for testing conditions. You can optionally provide a message
36
+ Use `assert` for testing conditions. You can optionally provide an error message,
37
+ exception class or exception object.
34
38
 
35
39
  ```ruby
36
40
  assert some_string != "some value"
37
- assert clients.empty?, "Isn't the clients list empty?"
41
+ assert clients.empty?, "The list must not be empty!"
42
+ assert xyz, StandardError.new("This is a custom exception object")
43
+ assert abc, CustomErrorClass
38
44
  ```
39
45
 
40
- 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
46
+ Use `invariant` for testing blocks of code. This comes handy when testing your assumptions requires several lines of code.
47
+ You can provide an optional message (or exception class/object) if you want.
41
48
 
42
49
  ```ruby
43
50
  invariant do
44
- one_variable = calculate_some_value
45
- other_variable = calculate_some_other_value
46
- one_variable > other_variable
51
+ one_variable = calculate_some_value
52
+ other_variable = calculate_some_other_value
53
+ one_variable > other_variable
47
54
  end
48
55
  ```
49
56
 
50
57
  ```ruby
51
- invariant "Lists with different sizes?" do
52
- one_variable = calculate_some_value
53
- other_variable = calculate_some_other_value
54
- one_variable > other_variable
58
+ invariant "Lists must have equal sizes!" do
59
+ len = calculate_list_length
60
+ other_len = calculate_other_list_length
61
+ len == other_len
55
62
  end
56
63
  ```
57
64
 
@@ -60,15 +67,12 @@ end
60
67
  Create a file named `solid_assert.rb` in the `config/initializers` dir with the following content:
61
68
 
62
69
  ```ruby
63
- SolidAssert.enable_assertions if !Rails.env.production?
70
+ SolidAssert.enable_assertions unless Rails.env.production?
64
71
  ```
65
72
 
66
- This way assertions will be disabled in production and enabled in the rest of environments
73
+ This way assertions will be disabled in production and enabled in the rest of environments.
67
74
 
68
75
  ## References
69
76
 
70
77
  - [Programming with assertions](http://download.oracle.com/javase/1.4.2/docs/guide/lang/assert.html). A great article on assertions. It is about the Java language, but the concepts apply to any programming language.
71
78
  - 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)
72
-
73
-
74
-
data/Rakefile CHANGED
@@ -1,49 +1,6 @@
1
- # encoding: utf-8
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
3
- require 'rubygems'
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
- require 'jeweler'
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
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "solid_assert"
5
+
6
+ require "irb"
7
+ IRB.start
@@ -1,9 +1,33 @@
1
- Dir[File.dirname(__FILE__) + '/solid_assert/**/*.rb'].each do |file|
2
- require file
3
- end
1
+ require "forwardable"
2
+ require "solid_assert/null_assert"
3
+ require "solid_assert/assert"
4
4
 
5
- Object.class_eval do
6
- include SolidAssert::NullAssert
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
@@ -1,21 +1,38 @@
1
+ require "singleton"
2
+ require "solid_assert/assertion_failed_error"
3
+
1
4
  module SolidAssert
2
- module Assert
3
5
 
4
- # Expresses a condition and fails if the condition is not satisfied
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 false
8
- # assert not_nil_object
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
15
+ # assert false, StandardError.new("Not XYZ!") # raise custom exception object
16
+ # assert false, CustomError # raise custom exception class
10
17
  #
11
- # @param condition The condition to assert
12
- # @param message The optional message when the condition is not satisfied
18
+ # @param condition A condition to assert
19
+ # @param exception An optional error message (or exception)
13
20
  # @raise {AssertionFailedError} when the condition is not satisfied
14
- def assert(condition, message=nil)
15
- raise SolidAssert::AssertionFailedError.new(message) if !condition
21
+ def assert(condition, exception = nil)
22
+ if !condition
23
+ if exception.kind_of?(Exception) or exception.class.eql?(Class)
24
+ raise exception
25
+ else
26
+ raise SolidAssert::AssertionFailedError.new(exception)
27
+ end
28
+ end
16
29
  end
17
30
 
18
- # Let you {#assert} a block of code. It comes handy when your assertion requires more than one lines of code
31
+ # Let you {#assert} a block of code.
32
+ #
33
+ # It comes handy when your assertion requires more than one line of code.
34
+ # An assertion is performed on the result of the provided block evaluation.
35
+ #
19
36
  # Usage:
20
37
  # invariant do
21
38
  # some_number = 1
@@ -23,15 +40,20 @@ module SolidAssert
23
40
  # some_number == other_number
24
41
  # end
25
42
  #
26
- # invariant "Both numbers should be equal" do
27
- # some_number = 1
28
- # other_number = 2
43
+ # invariant "Both numbers should be equal" do # optional error message
44
+ # ...
29
45
  # some_number == other_number
30
46
  # end
31
- # @param message The optional message when the block doesn't evaluates to a satisfied condition
32
- # @yield The block that will be evaluated for deciding whether the condition is satisfied
33
- def invariant(message=nil)
34
- assert yield, message
47
+ #
48
+ # invariant CustomError do # custom exception class
49
+ # ...
50
+ # some_number == other_number
51
+ # end
52
+ #
53
+ # @param exception An optional error message (or exception)
54
+ # @yield A block of code
55
+ def invariant(exception = nil)
56
+ assert yield, exception
35
57
  end
36
58
  end
37
59
  end
@@ -1,10 +1,3 @@
1
1
  module SolidAssert
2
-
3
- class AssertionFailedError < StandardError
4
- def initialize(message=nil)
5
- super
6
- end
7
- end
8
-
2
+ class AssertionFailedError < StandardError ; end
9
3
  end
10
-
@@ -1,14 +1,17 @@
1
+ require "singleton"
2
+
1
3
  module SolidAssert
2
4
 
3
- # Null assert implementation. Used when the assertions are disabled
4
- module NullAssert
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
@@ -0,0 +1,3 @@
1
+ module SolidAssert
2
+ VERSION = "0.8.0"
3
+ end
@@ -1,65 +1,23 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
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 |s|
7
- s.name = %q{solid_assert}
8
- s.version = "0.7.3"
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
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Jorge Manrubia}]
12
- s.date = %q{2011-09-20}
13
- s.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)'}
14
- s.email = %q{jorge.manrubia@gmail.com}
15
- s.extra_rdoc_files = [
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
- if s.respond_to? :specification_version then
45
- s.specification_version = 3
18
+ spec.required_ruby_version = "~> 2.0"
46
19
 
47
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
49
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
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", "~> 1.11"
21
+ spec.add_development_dependency "rake", "~> 10.5"
22
+ spec.add_development_dependency "rspec", "~> 3.4"
64
23
  end
65
-
metadata CHANGED
@@ -1,143 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: solid_assert
3
- version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 3
10
- version: 0.7.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jorge Manrubia
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-09-20 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- type: :development
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
25
17
  - - ~>
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
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
37
20
  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
50
- name: bundler
51
21
  prerelease: false
52
- - !ruby/object:Gem::Dependency
53
- type: :development
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
57
31
  - - ~>
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
32
+ - !ruby/object:Gem::Version
33
+ version: '10.5'
34
+ type: :development
67
35
  prerelease: false
68
- - !ruby/object:Gem::Dependency
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.5'
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
- description: 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)'
83
- email: jorge.manrubia@gmail.com
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
- extra_rdoc_files:
89
- - LICENSE.txt
90
- - README.md
91
- files:
92
- - .document
62
+ extra_rdoc_files: []
63
+ files:
64
+ - .gitignore
93
65
  - .rspec
66
+ - .travis.yml
94
67
  - Gemfile
95
68
  - LICENSE.txt
96
69
  - README.md
97
70
  - Rakefile
98
- - VERSION
71
+ - bin/console
99
72
  - lib/solid_assert.rb
100
73
  - lib/solid_assert/assert.rb
101
74
  - lib/solid_assert/assertion_failed_error.rb
102
75
  - lib/solid_assert/null_assert.rb
103
- - lib/solid_assert/solid_assert.rb
76
+ - lib/solid_assert/version.rb
104
77
  - solid_assert.gemspec
105
- - spec/solid_assert/assert_spec.rb
106
- - spec/solid_assert/null_assert_spec.rb
107
- - spec/solid_assert/solid_assert_spec.rb
108
- - spec/spec_helper.rb
109
- homepage: http://github.com/jorgemanrubia/solid_assert
110
- licenses:
78
+ homepage: https://github.com/jorgemanrubia/solid_assert
79
+ licenses:
111
80
  - MIT
81
+ metadata: {}
112
82
  post_install_message:
113
83
  rdoc_options: []
114
-
115
- require_paths:
84
+ require_paths:
116
85
  - lib
117
- required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
126
- required_rubygems_version: !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: '2.0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
135
96
  requirements: []
136
-
137
97
  rubyforge_project:
138
- rubygems_version: 1.8.6
98
+ rubygems_version: 2.4.8
139
99
  signing_key:
140
- specification_version: 3
100
+ specification_version: 4
141
101
  summary: Assert utility for ruby
142
102
  test_files: []
143
-
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.7.3
@@ -1,12 +0,0 @@
1
- module SolidAssert
2
- # Turns the assertions on
3
- def self.enable_assertions
4
- Object.class_eval do
5
- include Assert
6
- end
7
- end
8
-
9
- end
10
-
11
-
12
-
@@ -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
-
@@ -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