simple_assertions 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode
5
+ - rbx-19mode
data/README.rdoc CHANGED
@@ -1,10 +1,15 @@
1
- = Assertions for test/unit
1
+ = Assertions for minitest or test/unit
2
2
 
3
- Useful assertions for test/unit
3
+ A collection of usefull assertions.
4
4
 
5
5
  Gem[https://rubygems.org/gems/simple_assertions] |
6
6
  Source[https://github.com/neopoly/simple_assertions] |
7
- RDoc[http://rubydoc.info/github/neopoly/simple_assertions/master/file/README.rdoc]
7
+ RDoc[http://rubydoc.info/github/neopoly/simple_assertions/master/file/README.rdoc] |
8
+ {<img src="https://secure.travis-ci.org/neopoly/simple_assertions.png?branch=master" alt="Build Status" />}[http://travis-ci.org/neopoly/simple_assertions]
9
+
10
+ == Only 1.9.3 suported!
11
+
12
+ Note that only ruby version >= 1.9.3 is supported.
8
13
 
9
14
  == Usage
10
15
 
data/Rakefile CHANGED
@@ -1 +1,12 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ # Test
4
+ require 'rake/testtask'
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ Rake::TestTask.new(:test) do |test|
9
+ test.test_files = FileList.new('test/*_test.rb')
10
+ test.libs << 'test'
11
+ test.verbose = true
12
+ end
@@ -20,7 +20,8 @@ module SimpleAssertions
20
20
  attributes = args.last.is_a?(Hash) ? args.pop : {}
21
21
  exception = super(*args, &block).tap do |exception|
22
22
  attributes.each do |attribute, expected|
23
- actual = exception.send(attribute)
23
+ assert_respond_to exception, attribute
24
+ actual = exception.public_send(attribute)
24
25
  assert_operator expected, :===, actual
25
26
  end
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleAssertions
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -11,12 +11,13 @@ Gem::Specification.new do |s|
11
11
  s.summary = %q{Useful assertions for test/unit}
12
12
  s.description = %q{}
13
13
 
14
+ s.required_ruby_version = '>= 1.9.3'
15
+
14
16
  s.files = `git ls-files`.split("\n")
15
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
19
  s.require_paths = ["lib"]
18
20
 
19
- # specify any dependencies here; for example:
20
- # s.add_development_dependency "rspec"
21
- # s.add_runtime_dependency "test-unit"
21
+ s.add_runtime_dependency "rake"
22
+ s.add_runtime_dependency "minitest", "~> 3.2.0"
22
23
  end
data/test/helper.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'minitest/spec'
4
+ require 'minitest/autorun'
5
+
6
+ require 'simple_assertions'
7
+
8
+ class Spec < MiniTest::Spec
9
+ class << self
10
+ alias :context :describe
11
+ alias :test :it
12
+ end
13
+ end
@@ -0,0 +1,74 @@
1
+ require 'helper'
2
+
3
+ class SimpleAssertionsAssertRaisesTest < Spec
4
+ class MyError < StandardError
5
+ attr_reader :param
6
+
7
+ def initialize(param)
8
+ super "Param: #{param}"
9
+ @param = param
10
+ end
11
+
12
+ def paula
13
+ :sir
14
+ end
15
+ private :paula
16
+
17
+ def enemy
18
+ :war
19
+ end
20
+ protected :enemy
21
+ end
22
+
23
+ def my_error!(param=nil)
24
+ raise MyError, param
25
+ end
26
+
27
+ include SimpleAssertions::AssertRaises
28
+
29
+ context :assert_raises do
30
+ test "exact param match" do
31
+ assert_raises MyError, :param => "string" do
32
+ my_error! "string"
33
+ end
34
+ end
35
+
36
+ test "regexp param match" do
37
+ assert_raises MyError, :param => /string/i do
38
+ my_error! "my STRING rocks"
39
+ end
40
+ end
41
+
42
+ test "param does not match on === operator" do
43
+ assert_raises MiniTest::Assertion, :message => /"foo".*=== "bar"/ do
44
+ assert_raises MyError, :param => "foo" do
45
+ my_error! "bar"
46
+ end
47
+ end
48
+ end
49
+
50
+ test "exception does not respond to invalid param" do
51
+ assert_raises MiniTest::Assertion, :message => /to respond to #invalid/ do
52
+ assert_raises MyError, :invalid => "foo" do
53
+ my_error!
54
+ end
55
+ end
56
+ end
57
+
58
+ test "access to private exception param" do
59
+ assert_raises MiniTest::Assertion, :message => /to respond to #paula/ do
60
+ assert_raises MyError, :paula => :sir do
61
+ my_error!
62
+ end
63
+ end
64
+ end
65
+
66
+ test "access to protected exception param" do
67
+ assert_raises NoMethodError do
68
+ assert_raises MyError, :enemy => :war do
69
+ my_error!
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+
3
+ class SimpleAssertionsTest < Spec
4
+ context :all do
5
+ let(:all) { SimpleAssertions.all }
6
+
7
+ test "returns all autoloaded modules except VERSION" do
8
+ refute all.empty?
9
+ refute all.include?(SimpleAssertions::VERSION)
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_assertions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-29 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-07-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: minitest
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 3.2.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 3.2.0
14
46
  description: ''
15
47
  email:
16
48
  - ps@neopoly.de
@@ -20,6 +52,7 @@ extra_rdoc_files: []
20
52
  files:
21
53
  - .gitignore
22
54
  - .rvmrc
55
+ - .travis.yml
23
56
  - Gemfile
24
57
  - README.rdoc
25
58
  - Rakefile
@@ -30,6 +63,9 @@ files:
30
63
  - lib/simple_assertions/testunit.rb
31
64
  - lib/simple_assertions/version.rb
32
65
  - simple_assertions.gemspec
66
+ - test/helper.rb
67
+ - test/simple_assertions_assert_raises_test.rb
68
+ - test/simple_assertions_test.rb
33
69
  homepage: https://github.com/neopoly/simple_assertions
34
70
  licenses: []
35
71
  post_install_message:
@@ -41,13 +77,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
77
  requirements:
42
78
  - - ! '>='
43
79
  - !ruby/object:Gem::Version
44
- version: '0'
80
+ version: 1.9.3
45
81
  required_rubygems_version: !ruby/object:Gem::Requirement
46
82
  none: false
47
83
  requirements:
48
84
  - - ! '>='
49
85
  - !ruby/object:Gem::Version
50
86
  version: '0'
87
+ segments:
88
+ - 0
89
+ hash: -188214961
51
90
  requirements: []
52
91
  rubyforge_project:
53
92
  rubygems_version: 1.8.24