muack 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,120 @@
1
+
2
+ require 'muack/test'
3
+
4
+ describe 'retain visibility' do
5
+ after do
6
+ expect(Muack.verify).eq true
7
+ end
8
+
9
+ def verify obj, visibility
10
+ expect(Muack.verify).eq true
11
+
12
+ if visibility == :public
13
+ expect(obj).respond_to? :hello
14
+ else
15
+ expect(obj).not.respond_to? :hello
16
+ expect(obj).respond_to? :hello, true
17
+ end
18
+ end
19
+
20
+ def generate visibility
21
+ klass = Class.new do
22
+ def greet
23
+ 'hi'
24
+ end
25
+ end
26
+
27
+ mod = Module.new do
28
+ def greet
29
+ hello
30
+ end
31
+
32
+ def hello
33
+ 'hello'
34
+ end
35
+ send visibility, :hello
36
+ end
37
+
38
+ perform(klass, mod)
39
+ end
40
+
41
+ copy :test do
42
+ %i[public protected private].each do |visibility|
43
+ would "stub with #{visibility}" do
44
+ obj = generate(visibility)
45
+
46
+ stub(obj).hello{'stubbed'}
47
+
48
+ verify(obj, visibility)
49
+ end
50
+
51
+ would "stub proxy with #{visibility}" do
52
+ obj = generate(visibility)
53
+
54
+ stub(obj).hello
55
+
56
+ verify(obj, visibility)
57
+ end
58
+ end
59
+ end
60
+
61
+ describe 'prepend on class stub with object' do
62
+ def perform(klass, mod)
63
+ klass.prepend(mod)
64
+ klass.new
65
+ end
66
+
67
+ paste :test
68
+ end
69
+
70
+ describe 'extend on object stub with object' do
71
+ def perform(klass, mod)
72
+ obj = klass.new
73
+ obj.extend(mod)
74
+ obj
75
+ end
76
+
77
+ paste :test
78
+ end
79
+
80
+ describe 'include on singleton_class stub with object' do
81
+ def perform(klass, mod)
82
+ obj = klass.new
83
+ obj.singleton_class.include(mod)
84
+ obj
85
+ end
86
+
87
+ paste :test
88
+ end
89
+
90
+ describe 'prepend on singleton_class stub with object' do
91
+ def perform(klass, mod)
92
+ obj = klass.new
93
+ obj.singleton_class.prepend(mod)
94
+ obj
95
+ end
96
+
97
+ paste :test
98
+ end
99
+
100
+ # Brought from rspec-mocks
101
+ would "correctly restore the visibility of methods whose visibility has been tweaked on the singleton class" do
102
+ # hello is a private method when mixed in, but public on the module
103
+ # itself
104
+ mod = Module.new do
105
+ extend self
106
+ def hello; :hello; end
107
+
108
+ private :hello
109
+ class << self; public :hello; end
110
+ end
111
+
112
+ expect(mod.hello).eq :hello
113
+
114
+ stub(mod).hello{ :stub }
115
+
116
+ Muack.reset
117
+
118
+ expect(mod.hello).eq :hello
119
+ end
120
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-21 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Muack -- A fast, small, yet powerful mocking library.
@@ -35,6 +35,8 @@ files:
35
35
  - lib/muack.rb
36
36
  - lib/muack/any_instance_of.rb
37
37
  - lib/muack/block.rb
38
+ - lib/muack/block_26.rb
39
+ - lib/muack/block_27.rb
38
40
  - lib/muack/coat.rb
39
41
  - lib/muack/definition.rb
40
42
  - lib/muack/error.rb
@@ -53,17 +55,20 @@ files:
53
55
  - test/test_any_instance_of.rb
54
56
  - test/test_coat.rb
55
57
  - test/test_from_readme.rb
58
+ - test/test_keyargs.rb
56
59
  - test/test_mock.rb
57
60
  - test/test_modifier.rb
61
+ - test/test_prepend.rb
58
62
  - test/test_proxy.rb
59
63
  - test/test_satisfying.rb
60
64
  - test/test_spy.rb
61
65
  - test/test_stub.rb
66
+ - test/test_visibility.rb
62
67
  homepage: https://github.com/godfat/muack
63
68
  licenses:
64
- - Apache License 2.0
69
+ - Apache-2.0
65
70
  metadata: {}
66
- post_install_message:
71
+ post_install_message:
67
72
  rdoc_options: []
68
73
  require_paths:
69
74
  - lib
@@ -78,18 +83,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
83
  - !ruby/object:Gem::Version
79
84
  version: '0'
80
85
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.5.0
83
- signing_key:
86
+ rubygems_version: 3.1.4
87
+ signing_key:
84
88
  specification_version: 4
85
89
  summary: Muack -- A fast, small, yet powerful mocking library.
86
90
  test_files:
87
91
  - test/test_any_instance_of.rb
88
92
  - test/test_coat.rb
89
93
  - test/test_from_readme.rb
94
+ - test/test_keyargs.rb
90
95
  - test/test_mock.rb
91
96
  - test/test_modifier.rb
97
+ - test/test_prepend.rb
92
98
  - test/test_proxy.rb
93
99
  - test/test_satisfying.rb
94
100
  - test/test_spy.rb
95
101
  - test/test_stub.rb
102
+ - test/test_visibility.rb