assert-mocha 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,2 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
-
4
- require "assert/rake_tasks"
5
- Assert::RakeTasks.install
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["kelly@kelredd.com"]
7
7
  gem.description = %q{Assert with Mocha}
8
8
  gem.summary = %q{Assert with Mocha}
9
- gem.homepage = ""
9
+ gem.homepage = "https://github.com/redding/assert-mocha"
10
10
 
11
11
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
12
  gem.files = `git ls-files`.split("\n")
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Assert::Mocha::VERSION
17
17
 
18
- gem.add_dependency("assert", ["~>1.0"])
18
+ gem.add_dependency("assert", ["~>2.0"])
19
19
  gem.add_dependency("mocha", ["~>0.13"])
20
20
  end
@@ -9,9 +9,29 @@ module Assert
9
9
  def self.included(klass)
10
10
  klass.class_eval do
11
11
  include ::Mocha::API
12
+ include Assertions
13
+
14
+ setup do
15
+ mocha_setup
16
+ end
17
+ teardown do
18
+ mocha_teardown
19
+ end
20
+
12
21
  end
13
22
  end
14
23
 
24
+ module Assertions
25
+
26
+ def assert_mocks(counter = nil)
27
+ assert_nothing_raised do
28
+ yield
29
+ mocha_verify(counter)
30
+ end
31
+ end
32
+
33
+ end
34
+
15
35
  end
16
36
  end
17
37
 
@@ -1,5 +1,5 @@
1
1
  module Assert
2
2
  module Mocha
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -1,5 +1,40 @@
1
- root_path = File.expand_path("../..", __FILE__)
2
- if !$LOAD_PATH.include?(root_path)
3
- $LOAD_PATH.unshift(root_path)
4
- end
5
1
  require 'assert-mocha'
2
+
3
+ TEST_ASSERT_SUITE = Assert::Suite.new
4
+
5
+ module Factory
6
+
7
+ def self.context_info_called_from
8
+ "/path/to_file.rb:1234"
9
+ end
10
+
11
+ def self.context_info(context_class)
12
+ Assert::Suite::ContextInfo.new(context_class, context_info_called_from)
13
+ end
14
+
15
+ # Generate an anonymous `Context` inherited from `TestContext` by default.
16
+ # This provides a common interface for all contexts used in testing.
17
+
18
+ def self.context_class(inherit_from=nil, &block)
19
+ inherit_from ||= Assert::Context
20
+ klass = Class.new(inherit_from, &block)
21
+ default = (const_name = "FactoryAssertContext").dup
22
+
23
+ while(Object.const_defined?(const_name)) do
24
+ const_name = "FactoryAssertContext#{rand(Time.now.to_i)}"
25
+ end
26
+ Object.const_set(const_name, klass)
27
+ klass
28
+ end
29
+
30
+ # Generate a no-op test for use in testing.
31
+
32
+ def self.test(*args, &block)
33
+ name = (args[0] || "a test").to_s
34
+ context_info = args[1] || self.context_info(self.context_class)
35
+ test_block = (block || args[2] || ::Proc.new{})
36
+
37
+ Assert::Test.new(name, context_info, &test_block)
38
+ end
39
+
40
+ end
@@ -17,4 +17,32 @@ module Assert::Mocha
17
17
  end
18
18
  end
19
19
 
20
+ class AssertMocksTest < BaseTest
21
+ desc "assert_mocks"
22
+ setup do
23
+ object = Class.new do
24
+ def self.works
25
+ self.call_this
26
+ self.call_this
27
+ end
28
+ def self.doesnt_work
29
+ self.call_this
30
+ end
31
+ end
32
+ object.expects(:call_this).twice
33
+ @test = Factory.test do
34
+ assert_mocks{ object.works }
35
+ assert_mocks{ object.doesnt_work }
36
+ end
37
+ @test.run
38
+ end
39
+ subject{ @test }
40
+
41
+ should "pass calling #works and fail calling #doesnt_work" do
42
+ assert_equal 1, subject.result_count(:pass)
43
+ assert_equal 1, subject.result_count(:fail)
44
+ end
45
+
46
+ end
47
+
20
48
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert-mocha
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-11-21 00:00:00 Z
19
+ date: 2013-02-27 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false
@@ -25,11 +25,11 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 15
28
+ hash: 3
29
29
  segments:
30
- - 1
30
+ - 2
31
31
  - 0
32
- version: "1.0"
32
+ version: "2.0"
33
33
  requirement: *id001
34
34
  name: assert
35
35
  type: :runtime
@@ -67,7 +67,7 @@ files:
67
67
  - lib/assert-mocha/version.rb
68
68
  - test/helper.rb
69
69
  - test/unit/assert-mocha_test.rb
70
- homepage: ""
70
+ homepage: https://github.com/redding/assert-mocha
71
71
  licenses: []
72
72
 
73
73
  post_install_message: