assert-mocha 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/Gemfile +3 -3
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +0 -1
- data/assert-mocha.gemspec +12 -10
- data/lib/assert-mocha.rb +21 -26
- data/lib/assert-mocha/version.rb +1 -1
- data/test/helper.rb +9 -0
- data/test/unit/{assert-mocha_test.rb → assert-mocha_tests.rb} +4 -2
- metadata +17 -16
- data/README.markdown +0 -60
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2011-Present Collin Redding and Kelly Redding
|
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,47 @@
|
|
1
|
+
# Assert-Mocha
|
2
|
+
|
3
|
+
The [assert](https://github.com/teaminsight/assert) gem with [mocha](https://github.com/floehopper/mocha). This gem just mixes in the Mocha API into the Assert context, giving you all the power of Mocha while using Assert.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Use assert as you normally would. Inherit from a context and use mocha's methods in your tests:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
class BaseTest < Asset::Context
|
11
|
+
desc "some test"
|
12
|
+
setup do
|
13
|
+
@user = mock()
|
14
|
+
@user.expects(:some_method).once
|
15
|
+
@user.stubs(:name).returns("Someone")
|
16
|
+
end
|
17
|
+
subject{ @user }
|
18
|
+
|
19
|
+
should have_instance_methods :name
|
20
|
+
|
21
|
+
should "call the expected method" do
|
22
|
+
assert_nothing_raised{ subject.another_method } # assuming another_method calls #some_method
|
23
|
+
end
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
Add this line to your application's Gemfile:
|
30
|
+
|
31
|
+
gem 'logsly'
|
32
|
+
|
33
|
+
And then execute:
|
34
|
+
|
35
|
+
$ bundle
|
36
|
+
|
37
|
+
Or install it yourself as:
|
38
|
+
|
39
|
+
$ gem install logsly
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/assert-mocha.gemspec
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "assert-mocha/version"
|
3
5
|
|
4
6
|
Gem::Specification.new do |gem|
|
5
|
-
gem.
|
6
|
-
gem.
|
7
|
+
gem.name = "assert-mocha"
|
8
|
+
gem.version = Assert::Mocha::VERSION
|
9
|
+
gem.authors = ["Collin Redding", "Kelly Redding"]
|
10
|
+
gem.email = ["collin.redding@me.com, kelly@kellyredding.com"]
|
7
11
|
gem.description = %q{Assert with Mocha}
|
8
12
|
gem.summary = %q{Assert with Mocha}
|
9
13
|
gem.homepage = "https://github.com/redding/assert-mocha"
|
10
14
|
|
11
|
-
gem.
|
12
|
-
gem.
|
13
|
-
gem.test_files =
|
14
|
-
gem.name = "assert-mocha"
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
18
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = Assert::Mocha::VERSION
|
17
19
|
|
18
|
-
gem.add_dependency("assert", ["~>2.0"])
|
19
|
-
gem.add_dependency("mocha", ["~>0.13"])
|
20
|
+
gem.add_dependency("assert", ["~> 2.0"])
|
21
|
+
gem.add_dependency("mocha", ["~> 0.13"])
|
20
22
|
end
|
data/lib/assert-mocha.rb
CHANGED
@@ -1,40 +1,35 @@
|
|
1
|
-
require 'assert'
|
2
|
-
require 'mocha/api'
|
3
|
-
|
4
1
|
require 'assert-mocha/version'
|
2
|
+
require 'assert/context'
|
3
|
+
require 'mocha/api'
|
5
4
|
|
6
|
-
module Assert
|
7
|
-
module Mocha
|
8
|
-
|
9
|
-
def self.included(klass)
|
10
|
-
klass.class_eval do
|
11
|
-
include ::Mocha::API
|
12
|
-
include Assertions
|
5
|
+
module Assert::Mocha
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
mocha_teardown
|
19
|
-
end
|
7
|
+
def self.included(klass)
|
8
|
+
klass.class_eval do
|
9
|
+
include ::Mocha::API
|
10
|
+
include Assertions
|
20
11
|
|
12
|
+
setup do
|
13
|
+
mocha_setup
|
14
|
+
end
|
15
|
+
teardown do
|
16
|
+
mocha_teardown
|
21
17
|
end
|
18
|
+
|
22
19
|
end
|
20
|
+
end
|
23
21
|
|
24
|
-
|
22
|
+
module Assertions
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
24
|
+
def assert_mocks(counter = nil)
|
25
|
+
assert_nothing_raised do
|
26
|
+
yield
|
27
|
+
mocha_verify(counter)
|
31
28
|
end
|
32
|
-
|
33
29
|
end
|
34
30
|
|
35
31
|
end
|
36
|
-
end
|
37
32
|
|
38
|
-
Assert::Context.class_eval do
|
39
|
-
include Assert::Mocha
|
40
33
|
end
|
34
|
+
|
35
|
+
Assert::Context.class_eval{ include Assert::Mocha }
|
data/lib/assert-mocha/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# this file is automatically required when you run `assert`
|
2
|
+
# put any test helpers here
|
3
|
+
|
4
|
+
# add the root dir to the load path
|
5
|
+
$LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
6
|
+
|
7
|
+
# require pry for debugging (`binding.pry`)
|
8
|
+
require 'pry'
|
9
|
+
|
1
10
|
require 'assert-mocha'
|
2
11
|
|
3
12
|
TEST_ASSERT_SUITE = Assert::Suite.new
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'assert'
|
2
|
+
require 'assert/context'
|
3
|
+
require 'mocha/api'
|
2
4
|
|
3
5
|
module Assert::Mocha
|
4
6
|
|
5
|
-
class
|
7
|
+
class BaseTests < Assert::Context
|
6
8
|
desc "Assert::Context"
|
7
9
|
setup do
|
8
10
|
@class = Assert::Context
|
@@ -17,7 +19,7 @@ module Assert::Mocha
|
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
class
|
22
|
+
class AssertMocksTests < BaseTests
|
21
23
|
desc "assert_mocks"
|
22
24
|
setup do
|
23
25
|
object = Class.new do
|
metadata
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert-mocha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
- Kelly Redding
|
14
13
|
- Collin Redding
|
14
|
+
- Kelly Redding
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-03-25 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
name: assert
|
22
23
|
prerelease: false
|
23
|
-
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
25
|
none: false
|
25
26
|
requirements:
|
26
27
|
- - ~>
|
@@ -30,12 +31,12 @@ dependencies:
|
|
30
31
|
- 2
|
31
32
|
- 0
|
32
33
|
version: "2.0"
|
33
|
-
requirement: *id001
|
34
|
-
name: assert
|
35
34
|
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
+
name: mocha
|
37
38
|
prerelease: false
|
38
|
-
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ~>
|
@@ -45,12 +46,11 @@ dependencies:
|
|
45
46
|
- 0
|
46
47
|
- 13
|
47
48
|
version: "0.13"
|
48
|
-
requirement: *id002
|
49
|
-
name: mocha
|
50
49
|
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
51
|
description: Assert with Mocha
|
52
52
|
email:
|
53
|
-
- kelly@
|
53
|
+
- collin.redding@me.com, kelly@kellyredding.com
|
54
54
|
executables: []
|
55
55
|
|
56
56
|
extensions: []
|
@@ -60,13 +60,14 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- .gitignore
|
62
62
|
- Gemfile
|
63
|
-
-
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
64
65
|
- Rakefile
|
65
66
|
- assert-mocha.gemspec
|
66
67
|
- lib/assert-mocha.rb
|
67
68
|
- lib/assert-mocha/version.rb
|
68
69
|
- test/helper.rb
|
69
|
-
- test/unit/assert-
|
70
|
+
- test/unit/assert-mocha_tests.rb
|
70
71
|
homepage: https://github.com/redding/assert-mocha
|
71
72
|
licenses: []
|
72
73
|
|
@@ -96,10 +97,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
97
|
requirements: []
|
97
98
|
|
98
99
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.24
|
100
101
|
signing_key:
|
101
102
|
specification_version: 3
|
102
103
|
summary: Assert with Mocha
|
103
104
|
test_files:
|
104
105
|
- test/helper.rb
|
105
|
-
- test/unit/assert-
|
106
|
+
- test/unit/assert-mocha_tests.rb
|
data/README.markdown
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# Assert-Mocha
|
2
|
-
|
3
|
-
The [assert](https://github.com/teaminsight/assert) gem with [mocha](https://github.com/floehopper/mocha). This gem just mixes in the Mocha API into the Assert context, giving you all the power of Mocha while using Assert.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
In your Gemfile add:
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'assert-mocha'
|
11
|
-
end
|
12
|
-
|
13
|
-
Then run `bundle install` to install the gem.
|
14
|
-
|
15
|
-
## Usage
|
16
|
-
|
17
|
-
Use assert as you normally would. Inherit from a context and use mocha's methods in your tests:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
class BaseTest < Asset::Context
|
21
|
-
desc "some test"
|
22
|
-
setup do
|
23
|
-
@user = mock()
|
24
|
-
@user.expects(:some_method).once
|
25
|
-
@user.stubs(:name).returns("Someone")
|
26
|
-
end
|
27
|
-
subject{ @user }
|
28
|
-
|
29
|
-
should have_instance_methods :name
|
30
|
-
|
31
|
-
should "call the expected method" do
|
32
|
-
assert_nothing_raised{ subject.another_method } # assuming another_method calls #some_method
|
33
|
-
end
|
34
|
-
end
|
35
|
-
```
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
Copyright (c) 2011 Kelly Redding, Collin Redding, and Team Insight
|
40
|
-
|
41
|
-
Permission is hereby granted, free of charge, to any person
|
42
|
-
obtaining a copy of this software and associated documentation
|
43
|
-
files (the "Software"), to deal in the Software without
|
44
|
-
restriction, including without limitation the rights to use,
|
45
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
46
|
-
copies of the Software, and to permit persons to whom the
|
47
|
-
Software is furnished to do so, subject to the following
|
48
|
-
conditions:
|
49
|
-
|
50
|
-
The above copyright notice and this permission notice shall be
|
51
|
-
included in all copies or substantial portions of the Software.
|
52
|
-
|
53
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
54
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
55
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
56
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
57
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
58
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
59
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
60
|
-
OTHER DEALINGS IN THE SOFTWARE.
|