minispec 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.pryrc +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +2140 -0
  6. data/Rakefile +11 -0
  7. data/bin/minispec +4 -0
  8. data/lib/minispec.rb +175 -0
  9. data/lib/minispec/api.rb +2 -0
  10. data/lib/minispec/api/class.rb +195 -0
  11. data/lib/minispec/api/class/after.rb +49 -0
  12. data/lib/minispec/api/class/around.rb +54 -0
  13. data/lib/minispec/api/class/before.rb +101 -0
  14. data/lib/minispec/api/class/helpers.rb +116 -0
  15. data/lib/minispec/api/class/let.rb +44 -0
  16. data/lib/minispec/api/class/tests.rb +33 -0
  17. data/lib/minispec/api/instance.rb +158 -0
  18. data/lib/minispec/api/instance/mocks/doubles.rb +36 -0
  19. data/lib/minispec/api/instance/mocks/mocks.rb +319 -0
  20. data/lib/minispec/api/instance/mocks/spies.rb +17 -0
  21. data/lib/minispec/api/instance/mocks/stubs.rb +105 -0
  22. data/lib/minispec/helpers.rb +1 -0
  23. data/lib/minispec/helpers/array.rb +56 -0
  24. data/lib/minispec/helpers/booleans.rb +108 -0
  25. data/lib/minispec/helpers/generic.rb +24 -0
  26. data/lib/minispec/helpers/mocks/expectations.rb +29 -0
  27. data/lib/minispec/helpers/mocks/spies.rb +36 -0
  28. data/lib/minispec/helpers/raise.rb +44 -0
  29. data/lib/minispec/helpers/throw.rb +29 -0
  30. data/lib/minispec/mocks.rb +11 -0
  31. data/lib/minispec/mocks/expectations.rb +77 -0
  32. data/lib/minispec/mocks/stubs.rb +178 -0
  33. data/lib/minispec/mocks/validations.rb +80 -0
  34. data/lib/minispec/mocks/validations/amount.rb +63 -0
  35. data/lib/minispec/mocks/validations/arguments.rb +161 -0
  36. data/lib/minispec/mocks/validations/caller.rb +43 -0
  37. data/lib/minispec/mocks/validations/order.rb +47 -0
  38. data/lib/minispec/mocks/validations/raise.rb +111 -0
  39. data/lib/minispec/mocks/validations/return.rb +74 -0
  40. data/lib/minispec/mocks/validations/throw.rb +91 -0
  41. data/lib/minispec/mocks/validations/yield.rb +141 -0
  42. data/lib/minispec/proxy.rb +201 -0
  43. data/lib/minispec/reporter.rb +185 -0
  44. data/lib/minispec/utils.rb +139 -0
  45. data/lib/minispec/utils/differ.rb +325 -0
  46. data/lib/minispec/utils/pretty_print.rb +51 -0
  47. data/lib/minispec/utils/raise.rb +123 -0
  48. data/lib/minispec/utils/throw.rb +140 -0
  49. data/minispec.gemspec +27 -0
  50. data/test/mocks/expectations/amount.rb +67 -0
  51. data/test/mocks/expectations/arguments.rb +126 -0
  52. data/test/mocks/expectations/caller.rb +55 -0
  53. data/test/mocks/expectations/generic.rb +35 -0
  54. data/test/mocks/expectations/order.rb +46 -0
  55. data/test/mocks/expectations/raise.rb +166 -0
  56. data/test/mocks/expectations/return.rb +71 -0
  57. data/test/mocks/expectations/throw.rb +113 -0
  58. data/test/mocks/expectations/yield.rb +109 -0
  59. data/test/mocks/spies/amount.rb +68 -0
  60. data/test/mocks/spies/arguments.rb +57 -0
  61. data/test/mocks/spies/generic.rb +61 -0
  62. data/test/mocks/spies/order.rb +38 -0
  63. data/test/mocks/spies/raise.rb +158 -0
  64. data/test/mocks/spies/return.rb +71 -0
  65. data/test/mocks/spies/throw.rb +113 -0
  66. data/test/mocks/spies/yield.rb +101 -0
  67. data/test/mocks/test__doubles.rb +98 -0
  68. data/test/mocks/test__expectations.rb +27 -0
  69. data/test/mocks/test__mocks.rb +197 -0
  70. data/test/mocks/test__proxies.rb +61 -0
  71. data/test/mocks/test__spies.rb +43 -0
  72. data/test/mocks/test__stubs.rb +427 -0
  73. data/test/proxified_asserts.rb +34 -0
  74. data/test/setup.rb +53 -0
  75. data/test/test__around.rb +58 -0
  76. data/test/test__assert.rb +510 -0
  77. data/test/test__before_and_after.rb +117 -0
  78. data/test/test__before_and_after_all.rb +71 -0
  79. data/test/test__helpers.rb +197 -0
  80. data/test/test__raise.rb +104 -0
  81. data/test/test__skip.rb +41 -0
  82. data/test/test__throw.rb +103 -0
  83. metadata +196 -0
@@ -0,0 +1,41 @@
1
+ class MinispecTest
2
+ class Skip < self
3
+ class Generic
4
+ include Minispec
5
+
6
+ test :skip do
7
+ is(1) == 1
8
+ skip
9
+ is(1) == 2
10
+ end
11
+ end
12
+
13
+ def test_skip
14
+ result = msrun(Generic)
15
+ assert_equal -1, result.status[:skip]
16
+ end
17
+
18
+ class Conditionally
19
+ include Minispec
20
+
21
+ OPTS = {}
22
+ test :skip do
23
+ is(1) == 1
24
+ skip if OPTS[:skipped?]
25
+ is(1) == 2
26
+ end
27
+ end
28
+
29
+ def test_conditional_skip_when_skipped
30
+ Conditionally::OPTS[:skipped?] = true
31
+ result = msrun(Conditionally)
32
+ assert_equal -1, result.status[:skip]
33
+ end
34
+
35
+ def test_conditional_skip_when_not_skipped
36
+ Conditionally::OPTS[:skipped?] = false
37
+ result = msrun(Conditionally)
38
+ assert_equal 1, result.status[:skip]
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,103 @@
1
+ class MinispecTest
2
+ class Throw < self
3
+
4
+ class Unit
5
+ include Minispec
6
+ continue_on_failures true
7
+
8
+ begin
9
+ should 'pass when symbol expected and thrown' do
10
+ does { throw :something }.throw_symbol? :something
11
+ end
12
+
13
+ should ':fail when symbol expected but NOT thrown' do
14
+ does { }.throw_symbol :something
15
+ end
16
+
17
+ should 'pass when NO symbol thrown though expected but negation used' do
18
+ refute { }.throw_symbol :something
19
+ assure { }.does_not.throw :something
20
+ end
21
+
22
+ should ':fail when symbol thrown but NOT expected' do
23
+ refute { throw :something }.throw_symbol
24
+ end
25
+ should ':fail when symbol thrown but NOT expected - alternate syntax' do
26
+ assure { throw :something }.does_not.throw_symbol
27
+ end
28
+
29
+ should 'pass when NO symbol expected and NO symbol thrown' do
30
+ refute { }.throw_symbol
31
+ end
32
+ end
33
+
34
+ begin
35
+ should 'pass when thrown symbol match expected one' do
36
+ does { throw :something }.throw :something
37
+ end
38
+
39
+ should ':fail when thrown symbol match expected one but negation used' do
40
+ refute { throw :something }.throw :something
41
+ end
42
+
43
+ should ':fail when thrown symbol DOES NOT match expected one' do
44
+ does { throw :something }.throw :something_else
45
+ end
46
+
47
+ should 'pass when thrown symbol DOES NOT match expected one and negation used' do
48
+ refute { throw :a }.throw :b
49
+ assure { throw :a }.does_not.throw :b
50
+ end
51
+ end
52
+
53
+ begin
54
+ should 'pass when thrown symbol and value matches expected ones' do
55
+ does { throw :symbol, :value }.throw :symbol, :value
56
+ end
57
+
58
+ should ':fail when thrown symbol and value matches expected ones but negation used' do
59
+ refute { throw :symbol, :value }.throw :symbol, :value
60
+ assure { throw :symbol, :value }.does_not.throw :symbol, :value
61
+ end
62
+
63
+ should 'pass when symbol and value DOES NOT matches expected ones and negation used' do
64
+ refute { throw :a, :b }.throw :x, :y
65
+ assure { throw :a, :b }.does_not.throw :x, :y
66
+ end
67
+ end
68
+
69
+ begin
70
+ should ':fail when symbols matches but values DOES NOT' do
71
+ does { throw :symbol, :value }.throw :symbol, :blah
72
+ end
73
+ end
74
+
75
+ begin
76
+ should ':fail when values matches but symbols DOES NOT' do
77
+ does { throw :a, :b }.throw :c, :b
78
+ end
79
+
80
+ should 'pass when values matches but symbols DOES NOT and negation used' do
81
+ refute { throw :a, :b }.throw :c, :b
82
+ assure { throw :a, :b }.does_not.throw :c, :b
83
+ end
84
+ end
85
+
86
+ begin
87
+ should 'pass when given block validates thrown symbol' do
88
+ does { throw :a }.throw? {|s| s == :a}
89
+ end
90
+
91
+ should ':fail when given block does not validate thrown symbol' do
92
+ does { throw :a }.throw? {false}
93
+ end
94
+ end
95
+
96
+ should 'raise ArgumentError when both arguments and block given' do
97
+ does { expect { }.to_throw(:blah) {} }.raise? ArgumentError
98
+ end
99
+ end
100
+
101
+ define_tests(Unit)
102
+ end
103
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minispec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Slee Woo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: diff-lcs
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coderay
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Simple, Intuitive, Full-featured Testing Framework
84
+ email:
85
+ - mail@sleewoo.com
86
+ executables:
87
+ - minispec
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".pryrc"
92
+ - Gemfile
93
+ - LICENSE
94
+ - README.md
95
+ - Rakefile
96
+ - bin/minispec
97
+ - lib/minispec.rb
98
+ - lib/minispec/api.rb
99
+ - lib/minispec/api/class.rb
100
+ - lib/minispec/api/class/after.rb
101
+ - lib/minispec/api/class/around.rb
102
+ - lib/minispec/api/class/before.rb
103
+ - lib/minispec/api/class/helpers.rb
104
+ - lib/minispec/api/class/let.rb
105
+ - lib/minispec/api/class/tests.rb
106
+ - lib/minispec/api/instance.rb
107
+ - lib/minispec/api/instance/mocks/doubles.rb
108
+ - lib/minispec/api/instance/mocks/mocks.rb
109
+ - lib/minispec/api/instance/mocks/spies.rb
110
+ - lib/minispec/api/instance/mocks/stubs.rb
111
+ - lib/minispec/helpers.rb
112
+ - lib/minispec/helpers/array.rb
113
+ - lib/minispec/helpers/booleans.rb
114
+ - lib/minispec/helpers/generic.rb
115
+ - lib/minispec/helpers/mocks/expectations.rb
116
+ - lib/minispec/helpers/mocks/spies.rb
117
+ - lib/minispec/helpers/raise.rb
118
+ - lib/minispec/helpers/throw.rb
119
+ - lib/minispec/mocks.rb
120
+ - lib/minispec/mocks/expectations.rb
121
+ - lib/minispec/mocks/stubs.rb
122
+ - lib/minispec/mocks/validations.rb
123
+ - lib/minispec/mocks/validations/amount.rb
124
+ - lib/minispec/mocks/validations/arguments.rb
125
+ - lib/minispec/mocks/validations/caller.rb
126
+ - lib/minispec/mocks/validations/order.rb
127
+ - lib/minispec/mocks/validations/raise.rb
128
+ - lib/minispec/mocks/validations/return.rb
129
+ - lib/minispec/mocks/validations/throw.rb
130
+ - lib/minispec/mocks/validations/yield.rb
131
+ - lib/minispec/proxy.rb
132
+ - lib/minispec/reporter.rb
133
+ - lib/minispec/utils.rb
134
+ - lib/minispec/utils/differ.rb
135
+ - lib/minispec/utils/pretty_print.rb
136
+ - lib/minispec/utils/raise.rb
137
+ - lib/minispec/utils/throw.rb
138
+ - minispec.gemspec
139
+ - test/mocks/expectations/amount.rb
140
+ - test/mocks/expectations/arguments.rb
141
+ - test/mocks/expectations/caller.rb
142
+ - test/mocks/expectations/generic.rb
143
+ - test/mocks/expectations/order.rb
144
+ - test/mocks/expectations/raise.rb
145
+ - test/mocks/expectations/return.rb
146
+ - test/mocks/expectations/throw.rb
147
+ - test/mocks/expectations/yield.rb
148
+ - test/mocks/spies/amount.rb
149
+ - test/mocks/spies/arguments.rb
150
+ - test/mocks/spies/generic.rb
151
+ - test/mocks/spies/order.rb
152
+ - test/mocks/spies/raise.rb
153
+ - test/mocks/spies/return.rb
154
+ - test/mocks/spies/throw.rb
155
+ - test/mocks/spies/yield.rb
156
+ - test/mocks/test__doubles.rb
157
+ - test/mocks/test__expectations.rb
158
+ - test/mocks/test__mocks.rb
159
+ - test/mocks/test__proxies.rb
160
+ - test/mocks/test__spies.rb
161
+ - test/mocks/test__stubs.rb
162
+ - test/proxified_asserts.rb
163
+ - test/setup.rb
164
+ - test/test__around.rb
165
+ - test/test__assert.rb
166
+ - test/test__before_and_after.rb
167
+ - test/test__before_and_after_all.rb
168
+ - test/test__helpers.rb
169
+ - test/test__raise.rb
170
+ - test/test__skip.rb
171
+ - test/test__throw.rb
172
+ homepage: https://github.com/sleewoo/minispec
173
+ licenses:
174
+ - MIT
175
+ metadata: {}
176
+ post_install_message:
177
+ rdoc_options: []
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: 1.9.2
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ requirements: []
191
+ rubyforge_project:
192
+ rubygems_version: 2.2.2
193
+ signing_key:
194
+ specification_version: 4
195
+ summary: minispec-0.0.1
196
+ test_files: []