-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEMULATION
62 lines (46 loc) · 1.73 KB
/
EMULATION
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
== EMULATION
Detest can emulate several popular testing libraries:
<%
emulation_layers = {
'detest/spec' => '<<RSpec>>',
'detest/unit' => '<<Test::Unit>>',
'detest/mini' => '<<Minitest>>',
'detest/long' => 'Readability',
}
%>
[horizontal]
% emulation_layers.each do |layer, title|
<%= layer %>:: <%= title %> emulation layer
Simply require one of these emulation layers into your test suite and you can
write your tests using the familiar syntax of the testing library it emulates.
//////////////////////////////////////////////////////////////////////////////
// list all methods provided by the various emulation layers
//////////////////////////////////////////////////////////////////////////////
% require 'detest'
% before = Detest.instance_methods(false)
% sandbox = Object.new.extend(Detest)
% emulation_layers.each do |layer, title|
% require layer
% after = Detest.instance_methods(false)
% unless before == after
=== <%= layer %>
This library emulates <%= title %> by adding the following methods to the
`Detest` module.
[horizontal]
% (after - before).sort.each do |method_name|
% method = sandbox.method(method_name)
% file, line = method.source_location
% file = file.sub(Detest::INSTDIR, '').sub(%r(^/+), '')
% url = "#{@code_repo_url}/tree/master/#{file}#L#{line}"
<%= method.name %>(<%=
method.parameters.map do |type, name|
name = "__#{name}__" # unconstrained italics in AsciiDoc
case type
when :opt then name + '=nil'
when :rest then '*' + name
when :block then '&' + name
else name
end
end.join(', ')
%>):: <%= url %>[<%= file %>:<%= line %>]
% before = after