assert-send 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/assert_send.gemspec +4 -1
- data/test/mocoso_test.rb +54 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bd140e68ef99ffc71adfb02515caadcd5c69d08
|
4
|
+
data.tar.gz: adbc8339046c349abd2550980c6a0c7b271bae51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7fdd2c909e21f63230342d7d76b1deb4297c0f68977098aebb225f4a1222266e5584bba25f9b41dbdd841bb05aec7d2eae461b791502ef99d1e68e6940566c
|
7
|
+
data.tar.gz: c11bbd2001adbb979742911da1304ffc81513c70d99a798fb2e07fdc50e307cd808b98f1d8b7b0c451229905c7787df491b32fe094fffb55e85075430ac38849
|
data/assert_send.gemspec
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "assert-send"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.3"
|
4
4
|
s.summary = "Easy message expectation for tests in Ruby"
|
5
5
|
s.description = s.summary
|
6
6
|
s.authors = ["Lucas Tolchinsky"]
|
7
7
|
s.email = ["lucas.tolchinsky@gmail.com"]
|
8
8
|
s.homepage = "https://github.com/tonchis/assert-send"
|
9
9
|
s.license = "MIT"
|
10
|
+
|
10
11
|
s.files = `git ls-files`.split("\n")
|
12
|
+
|
11
13
|
s.add_development_dependency "cutest"
|
14
|
+
s.add_development_dependency "mocoso"
|
12
15
|
end
|
data/test/mocoso_test.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require "cutest"
|
2
|
+
require "mocoso"
|
3
|
+
require_relative "../lib/assert_send"
|
4
|
+
|
5
|
+
include Mocoso
|
6
|
+
include AssertSend
|
7
|
+
|
8
|
+
class Foo
|
9
|
+
def self.foo
|
10
|
+
"le foo"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.bar
|
14
|
+
Foo.foo
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.baz(arg)
|
18
|
+
arg
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
test "Mocoso#stub" do
|
23
|
+
stub(Foo, :foo, "wow") do
|
24
|
+
assert_equal "wow", assert_send(Foo, :foo) { Foo.bar }
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_equal "le foo", assert_send(Foo, :foo) { Foo.bar }
|
28
|
+
end
|
29
|
+
|
30
|
+
test "Mocoso#expect" do
|
31
|
+
# Mocoso will raise an exception because the argument used is not the same as the one in the expectation.
|
32
|
+
# However, AssertSend will not throw any errors because the message was indeed passed.
|
33
|
+
assert_raise(Mocoso::ExpectationError) do
|
34
|
+
expect(Foo, :baz, with: ["wat"]) do
|
35
|
+
assert_send(Foo, :baz) { Foo.baz("not") }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Now, Mocoso won't raise an error because the stub set in the expectation is never invoked,
|
40
|
+
# but AssertSend is going to throw an error because it was expecting Foo to receive :baz.
|
41
|
+
assert_raise(AssertSend::ExpectationError) do
|
42
|
+
expect(Foo, :baz, with: ["wat"]) do
|
43
|
+
assert_send(Foo, :baz) {}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
test "using Mocoso inside AssertSend will raise AssertSend::ExpectationError" do
|
49
|
+
assert_raise(AssertSend::ExpectationError) do
|
50
|
+
assert_send(Foo, :foo) do
|
51
|
+
stub(Foo, :foo, "wow") { Foo.bar }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert-send
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Tolchinsky
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocoso
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Easy message expectation for tests in Ruby
|
28
42
|
email:
|
29
43
|
- lucas.tolchinsky@gmail.com
|
@@ -37,6 +51,7 @@ files:
|
|
37
51
|
- assert_send.gemspec
|
38
52
|
- lib/assert_send.rb
|
39
53
|
- test/assert_send_test.rb
|
54
|
+
- test/mocoso_test.rb
|
40
55
|
homepage: https://github.com/tonchis/assert-send
|
41
56
|
licenses:
|
42
57
|
- MIT
|