simple_assertions 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Useful assertions for test/unit
4
4
 
5
+ Gem[https://rubygems.org/gems/simple_assertions] |
6
+ Source[https://github.com/neopoly/simple_assertions] |
7
+ RDoc[http://rubydoc.info/github/neopoly/simple_assertions/master/file/README.rdoc]
8
+
5
9
  == Usage
6
10
 
7
11
  === minitest
@@ -23,6 +27,7 @@ Or with more control what to include:
23
27
  require 'simple_assertions'
24
28
 
25
29
  class MiniTest::TestCase
30
+ # include *SimpleAssertions.all
26
31
  include SimpleAssertions::AssertErrorsOn
27
32
  include SimpleAssertions::AssertRaises
28
33
  end
@@ -5,17 +5,19 @@ module SimpleAssertions
5
5
  # Assert errors on given parameters.
6
6
  # It call #valid? on +object+ unless called with a block.
7
7
  #
8
- # assert_errors_on record, :email
9
- # assert_errors_on record, :email => 2
10
- # assert_errors_on record, :email => "is blank"
11
- # assert_errors_on record, :email => /blank/
12
- # assert_errors_on record, :email => ["is blank", "is invalid"]
13
- # assert_errors_on record, :email, :plz => 2
14
- # assert_errors_on record, [:username, :email] => "is blank"
8
+ # == Example
15
9
  #
16
- # assert_errors_on record, :email => 1 do
17
- # assert record.save
18
- # end
10
+ # assert_errors_on record, :email
11
+ # assert_errors_on record, :email => 2
12
+ # assert_errors_on record, :email => "is blank"
13
+ # assert_errors_on record, :email => /blank/
14
+ # assert_errors_on record, :email => ["is blank", "is invalid"]
15
+ # assert_errors_on record, :email, :plz => 2
16
+ # assert_errors_on record, [:username, :email] => "is blank"
17
+ #
18
+ # assert_errors_on record, :email => 1 do
19
+ # assert record.save
20
+ # end
19
21
  def assert_errors_on(object, *attributes_or_hash)
20
22
  if block_given?
21
23
  yield
@@ -20,7 +20,7 @@ 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 = expected.send(attribute)
23
+ actual = exception.send(attribute)
24
24
  assert_operator expected, :===, actual
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  class MiniTest::TestCase
2
- include SimpleAssertions::AssertErrorsOn
2
+ include *SimpleAssertions.all
3
3
  end
@@ -1,3 +1,3 @@
1
- Test::Unit::TestCase.class_eval do
2
- include SimpleAssertions::AssertErrorsOn
1
+ class Test::Unit::TestCase do
2
+ include *SimpleAssertions.all
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleAssertions
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -3,4 +3,9 @@ module SimpleAssertions
3
3
  autoload :AssertRaises, 'simple_assertions/assert_raises'
4
4
 
5
5
  autoload :VERSION, 'simple_assertions/version'
6
+
7
+ def self.all
8
+ mods = constants - [ :VERSION ]
9
+ mods.map { |mod| const_get(mod) }
10
+ end
6
11
  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.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: