expectation 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,6 +4,14 @@
4
4
 
5
5
  gem install expectations
6
6
 
7
+ ## Presentation
8
+
9
+ A short presentation is hosted at [Github](http://radiospiel.github.com/expectation).
10
+
11
+ ## Documentation
12
+
13
+ Documentation is available at [rubydoc.info](http://rubydoc.info/gems/expectation).
14
+
7
15
  ## Getting started
8
16
 
9
17
  This function expects a String argument starting with "http:", an Integer or Float argument, and a Hash
@@ -0,0 +1,57 @@
1
+ #--
2
+ # Author:: radiospiel (mailto:eno@radiospiel.org)
3
+ # Copyright:: Copyright (c) 2011, 2012 radiospiel
4
+ # License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
5
+ #++
6
+ # By requiring "expectation/assertions" you add expect! und unexpect! assertions
7
+ # to your test/unit testcases.
8
+
9
+ if !defined?(::Expectation::Assertions)
10
+
11
+ if !defined?(::Expectation)
12
+ require_relative "../expectation"
13
+ end
14
+
15
+ # The Expectation::Assertions module provides expect! and inexpect!
16
+ # assertions to use from within test cases.
17
+ #
18
+ # == Example
19
+ #
20
+ # require_relative 'test_helper'
21
+ # require 'expectation/assertions'
22
+ #
23
+ # class ExpectationTest < Test::Unit::TestCase
24
+ # def test_one
25
+ # end
26
+ # end
27
+ #
28
+ module Expectation::Assertions
29
+ alias_method :original_expect!, :expect! #:nodoc:
30
+
31
+ def assert_expectation(should_succeed, *expectation, &block) #:nodoc:
32
+ original_expect! *expectation, &block
33
+ assert_block { should_succeed }
34
+ rescue ArgumentError
35
+ assert_block($!.to_s) { !should_succeed }
36
+ end
37
+
38
+ # verifies the passed in expectations
39
+ def expect!(*expectation, &block)
40
+ assert_expectation true, *expectation, &block
41
+ end
42
+
43
+ # verifies the failure of the passed in expectations
44
+ def inexpect!(*expectation, &block)
45
+ assert_expectation false, *expectation, &block
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ if !defined?(Test::Unit)
52
+ STDERR.puts "Please load 'test/unit' first"
53
+ end
54
+
55
+ class Test::Unit::TestCase
56
+ include Expectation::Assertions
57
+ end
@@ -4,5 +4,5 @@
4
4
  # License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
5
5
  module Expectation
6
6
  # The expectation gem's version.
7
- VERSION="0.1.1"
7
+ VERSION="0.2.0"
8
8
  end
@@ -0,0 +1,12 @@
1
+ # Author:: radiospiel (mailto:eno@radiospiel.org)
2
+ # Copyright:: Copyright (c) 2011, 2012 radiospiel
3
+ # License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
4
+ require_relative 'test_helper'
5
+ require "expectation/assertions"
6
+
7
+ class AssertionsTest < Test::Unit::TestCase
8
+ def test_expectations
9
+ expect! 1 => 1
10
+ inexpect! 1 => 2
11
+ end
12
+ end
data/test/test_helper.rb CHANGED
@@ -9,7 +9,7 @@ class Test::Unit::UI::Console::TestRunner
9
9
  def guess_color_availability; true; end
10
10
  end
11
11
 
12
- require 'mocha'
12
+ require 'mocha/setup'
13
13
 
14
14
  SimpleCov.start do
15
15
  add_filter "test/*.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expectation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-30 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Defensive programming with expectations
15
15
  email: eno@radiospiel.org
@@ -17,9 +17,11 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - lib/expectation/assertions.rb
20
21
  - lib/expectation/version.rb
21
22
  - lib/expectation.rb
22
23
  - README.md
24
+ - test/assertions_test.rb
23
25
  - test/expect_test.rb
24
26
  - test/test_helper.rb
25
27
  homepage: http://github.com/radiospiel/expectation
@@ -36,7 +38,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
38
  version: '0'
37
39
  segments:
38
40
  - 0
39
- hash: 2234163165414067055
41
+ hash: 2749941318204507479
40
42
  required_rubygems_version: !ruby/object:Gem::Requirement
41
43
  none: false
42
44
  requirements:
@@ -45,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
47
  version: '0'
46
48
  segments:
47
49
  - 0
48
- hash: 2234163165414067055
50
+ hash: 2749941318204507479
49
51
  requirements: []
50
52
  rubyforge_project:
51
53
  rubygems_version: 1.8.24