mocoso 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 582dde2452597ff29ecf14f4b3b980ca5d53a02a
4
- data.tar.gz: c95e557a539ddf097439ac91f4af19c273e1b47e
3
+ metadata.gz: c12b98f62eb01e570daf1a9101b16a168837ec7d
4
+ data.tar.gz: cafcefb94d91446ff97bfb0e8ab72883be345101
5
5
  SHA512:
6
- metadata.gz: 0f6f811c7c9a6c057e2d6b517062504ab60a04ea04addf464f73d361c41be07415a781946e330a71730193837c6819c01f82641188c017ae3008a3a69e92c689
7
- data.tar.gz: 0235d2b34437f476e9e8989512d038c1db485345df46d2cc5bb053df1e6a6f437c743858da28955a200de503d8fb50d3f8d51ef87d59a2d42321eabe86f176ac
6
+ metadata.gz: af1706795d43d65d19045663aee87eaf42448ef47c6a1147193282bf522000be8dfccb1800bd852c0bb5e09451dbab42d968ca943ba749c70354ca88a19a96f2
7
+ data.tar.gz: 1a2aeaea3ae9b6f2b86a7c922c353c9c4173ffb00638c506921f7715ceba1315b5fac551241097175a15a9738a99a8b851dc04748e5f30cdf0854b451c32a686
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Mocoso [![Build Status](https://travis-ci.org/frodsan/mocoso.png)](https://travis-ci.org/frodsan/mocoso)
2
2
  ======
3
3
 
4
- Yet Another Simple Stub & Mock library. This is inspired by tools such as
4
+ Yet Another Simple Stub & Mock library. This is stolen from tools such as
5
5
  [Minitest::Mock][minitest], [Override][override] and [Mocha][mocha].
6
6
 
7
7
  Motivation
@@ -34,7 +34,7 @@
34
34
  #
35
35
  # Note: this example uses the test framework Cutest[1]:
36
36
  #
37
- # Mocoso is inspired in Override[2], Minitest::Mock[3] and Mocha[4].
37
+ # Mocoso is stolen from Override[2], Minitest::Mock[3] and Mocha[4].
38
38
  #
39
39
  # * [1]: https://github.com/djanowski/cutest/
40
40
  # * [2]: https://github.com/soveran/override/
@@ -97,8 +97,11 @@ module Mocoso
97
97
 
98
98
  methods.each do |method, result|
99
99
  metaclass.send :alias_method, stub_method_name(method), method
100
- metaclass.send :define_method, method do |*args|
101
- result.respond_to?(:call) ? result.call(*args) : result
100
+
101
+ if result.respond_to?(:call)
102
+ metaclass.send(:define_method, method) { |*args| result.call(*args) }
103
+ else
104
+ metaclass.send(:define_method, method) { result }
102
105
  end
103
106
  end
104
107
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'mocoso'
5
- s.version = '0.0.1'
5
+ s.version = '0.0.2'
6
6
  s.summary = 'A simple stub & mock library'
7
7
  s.description = s.summary
8
8
  s.authors = ['Francesco Rodríguez']
@@ -37,7 +37,7 @@ test 'stubs method with a callable object' do |subject|
37
37
  stub subject, foo: -> { 'new foo' }
38
38
 
39
39
  assert subject.foo != before
40
- assert subject.foo == 'new foo'
40
+ assert_equal 'new foo', subject.foo
41
41
  end
42
42
 
43
43
  test 'stubs method with a callable object with arguments' do |subject|
@@ -46,6 +46,7 @@ test 'stubs method with a callable object with arguments' do |subject|
46
46
  stub subject, foo: ->(a) { "new #{a}" }
47
47
 
48
48
  assert subject.foo('foo') != before
49
+ assert_equal 'new foo', subject.foo('foo')
49
50
  end
50
51
 
51
52
  test 'stubs method without side effects if a block is given' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocoso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Rodríguez