is_assertions 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a11ecc41c0e02fd1fa6642a5bf353168d1d0a33c
4
+ data.tar.gz: f0e13d34f499db83bd53c52689f06aa43e900f83
5
+ SHA512:
6
+ metadata.gz: b8c254bf4e1cf6548f800482f36e111035e857cc2be39f59fab4a3f11501a039cce369295014ac9a6ea5d830d789d151b15d3224360133a57d191a83da5e82fa
7
+ data.tar.gz: 9ab6062fc943b3424be5c924ce3f11b76de659fe47641fe59c25320d59e66e3324dc1ad61a8e51e8c935a91bb5c1ec6985c15d1525cbf11eee33ed6d40dc98c5
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in is_assertions.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sunny Hirai
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # IsAssertions
2
+
3
+ Add assertions to your code in a very simple and easy to read syntax.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'is_assertions'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install is_assertions
21
+
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require 'is_assertions'
27
+
28
+ class Thing
29
+
30
+ include IsAssertions
31
+
32
+ def initialize(name, age)
33
+ is name, String
34
+ is age, Fixnum
35
+ @name = name
36
+ end
37
+
38
+ end
39
+
40
+ # doesn't raise an error
41
+ Thing.new("John", 18)
42
+
43
+ # raises an errorj
44
+ Thing.new(123, 18)
45
+ ```
46
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ # require "rspec/core/rake_task"
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+
6
+ # RSpec::Core::RakeTask.new(:spec)
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.libs << "lib"
10
+ t.test_files = FileList['test/*test.rb']
11
+ t.verbose = true
12
+ end
13
+
14
+ task :default => :test
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'is_assertions/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "is_assertions"
8
+ spec.version = IsAssertions::VERSION
9
+ spec.authors = ["Sunny Hirai"]
10
+ spec.email = ["thesunny@gmail.com"]
11
+ spec.summary = %q{Add assertions in your code, not just in your tests}
12
+ spec.description = %q{Lets you add asssertions to your code, not just your tests, using a very clean and simple syntax}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", "~> 0.0"
24
+ end
@@ -0,0 +1,12 @@
1
+ require "is_assertions/version"
2
+ require "is_assertions/is_assertions_error"
3
+
4
+ module IsAssertions
5
+
6
+ def is(value, type)
7
+ if !value.is_a?(type)
8
+ raise IsAssertionsError, "value #{value.inspect} must be of type #{type}", caller(1)
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,2 @@
1
+ class IsAssertions::IsAssertionsError < StandardError
2
+ end
@@ -0,0 +1,3 @@
1
+ module IsAssertions
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,43 @@
1
+ require 'minitest/autorun'
2
+ require 'is_assertions'
3
+ require_relative 'user'
4
+
5
+ class IsAssertionsTest < MiniTest::Unit::TestCase
6
+
7
+ def setup
8
+ @user = User.new
9
+ end
10
+
11
+ def test_does_not_raise
12
+ @user.age = 25
13
+ end
14
+
15
+ def test_raises_right_exception
16
+ assert_raises IsAssertions::IsAssertionsError do
17
+ @user.age = "Bob"
18
+ end
19
+ end
20
+
21
+ def test_raises_from_the_right_line_of_code
22
+ raised = false
23
+ begin
24
+ @user.age = "Bob"
25
+ rescue => e
26
+ raised = true
27
+ assert_match /user[.]rb[:]6[:]/, e.backtrace[0]
28
+ end
29
+ assert raised, "Error wasn't raised"
30
+ end
31
+
32
+ def test_raises_right_kind_of_exception
33
+ raised = false
34
+ begin
35
+ @user.age = "Bob"
36
+ rescue => e
37
+ raised = true
38
+ assert_kind_of StandardError, e
39
+ end
40
+ assert raised, "Error wasn't raised"
41
+ end
42
+
43
+ end
data/test/user.rb ADDED
@@ -0,0 +1,10 @@
1
+ class User
2
+
3
+ include IsAssertions
4
+
5
+ def age=(age)
6
+ is age, Fixnum
7
+ end
8
+
9
+ end
10
+
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: is_assertions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Sunny Hirai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.0'
55
+ description: Lets you add asssertions to your code, not just your tests, using a very
56
+ clean and simple syntax
57
+ email:
58
+ - thesunny@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - is_assertions.gemspec
71
+ - lib/is_assertions.rb
72
+ - lib/is_assertions/is_assertions_error.rb
73
+ - lib/is_assertions/version.rb
74
+ - test/is_assertions_test.rb
75
+ - test/user.rb
76
+ homepage: ''
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.2.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Add assertions in your code, not just in your tests
100
+ test_files:
101
+ - test/is_assertions_test.rb
102
+ - test/user.rb