rhodes-framework 1.0.10 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +159 -30
- data/Rakefile +3 -19
- data/lib/erb.rb +1 -1
- data/lib/rho/rho.rb +94 -107
- data/lib/rho/rhofsconnector.rb +4 -0
- data/lib/rho/rhoutils.rb +26 -0
- data/lib/rho/rhoviewhelpers.rb +1 -1
- data/lib/rhodes.rb +2 -2
- data/lib/rhoframework.rb +9 -9
- data/lib/rhom/rhom.rb +1 -1
- data/lib/rhom/rhom_db_adapter.rb +36 -15
- data/lib/rhom/rhom_db_adapterME.rb +2 -3
- data/lib/rhom/rhom_object.rb +14 -2
- data/lib/rhom/rhom_object_factory.rb +42 -11
- data/lib/version.rb +2 -2
- data/spec/README +1 -0
- data/spec/Rakefile +1 -0
- data/spec/{configs/account.rb → app/Account/config.rb} +0 -0
- data/spec/{configs/case.rb → app/Case/config.rb} +0 -0
- data/spec/app/Question/config.rb +3 -0
- data/spec/app/Settings/controller.rb +10 -0
- data/spec/app/Settings/index.erb +11 -0
- data/spec/app/SpecRunner/controller.rb +15 -0
- data/spec/app/SpecRunner/index.erb +14 -0
- data/spec/app/application.rb +4 -0
- data/spec/app/index.erb +17 -0
- data/spec/app/layout.erb +27 -0
- data/spec/app/loading.html +11 -0
- data/spec/app/mspec.rb +11 -0
- data/spec/app/mspec/expectations.rb +2 -0
- data/spec/app/mspec/expectations/expectations.rb +17 -0
- data/spec/app/mspec/expectations/should.rb +25 -0
- data/spec/app/mspec/fileutils.rb +1590 -0
- data/spec/app/mspec/guards.rb +16 -0
- data/spec/app/mspec/guards/background.rb +21 -0
- data/spec/app/mspec/guards/bug.rb +24 -0
- data/spec/app/mspec/guards/compliance.rb +37 -0
- data/spec/app/mspec/guards/conflict.rb +18 -0
- data/spec/app/mspec/guards/endian.rb +44 -0
- data/spec/app/mspec/guards/extensions.rb +20 -0
- data/spec/app/mspec/guards/guard.rb +166 -0
- data/spec/app/mspec/guards/noncompliance.rb +20 -0
- data/spec/app/mspec/guards/platform.rb +43 -0
- data/spec/app/mspec/guards/quarantine.rb +17 -0
- data/spec/app/mspec/guards/runner.rb +34 -0
- data/spec/app/mspec/guards/superuser.rb +17 -0
- data/spec/app/mspec/guards/support.rb +20 -0
- data/spec/app/mspec/guards/tty.rb +20 -0
- data/spec/app/mspec/guards/version.rb +38 -0
- data/spec/app/mspec/helpers.rb +11 -0
- data/spec/app/mspec/helpers/argv.rb +43 -0
- data/spec/app/mspec/helpers/bignum.rb +5 -0
- data/spec/app/mspec/helpers/const_lookup.rb +9 -0
- data/spec/app/mspec/helpers/environment.rb +23 -0
- data/spec/app/mspec/helpers/fixture.rb +20 -0
- data/spec/app/mspec/helpers/flunk.rb +5 -0
- data/spec/app/mspec/helpers/io.rb +17 -0
- data/spec/app/mspec/helpers/language_version.rb +20 -0
- data/spec/app/mspec/helpers/ruby_exe.rb +123 -0
- data/spec/app/mspec/helpers/scratch.rb +17 -0
- data/spec/app/mspec/helpers/tmp.rb +32 -0
- data/spec/app/mspec/matchers.rb +23 -0
- data/spec/app/mspec/matchers/base.rb +95 -0
- data/spec/app/mspec/matchers/be_an_instance_of.rb +26 -0
- data/spec/app/mspec/matchers/be_ancestor_of.rb +24 -0
- data/spec/app/mspec/matchers/be_close.rb +27 -0
- data/spec/app/mspec/matchers/be_empty.rb +20 -0
- data/spec/app/mspec/matchers/be_false.rb +20 -0
- data/spec/app/mspec/matchers/be_kind_of.rb +24 -0
- data/spec/app/mspec/matchers/be_nil.rb +20 -0
- data/spec/app/mspec/matchers/be_true.rb +20 -0
- data/spec/app/mspec/matchers/complain.rb +56 -0
- data/spec/app/mspec/matchers/eql.rb +26 -0
- data/spec/app/mspec/matchers/equal.rb +26 -0
- data/spec/app/mspec/matchers/equal_element.rb +78 -0
- data/spec/app/mspec/matchers/equal_utf16.rb +34 -0
- data/spec/app/mspec/matchers/have_constant.rb +30 -0
- data/spec/app/mspec/matchers/have_instance_method.rb +24 -0
- data/spec/app/mspec/matchers/have_method.rb +24 -0
- data/spec/app/mspec/matchers/have_private_instance_method.rb +24 -0
- data/spec/app/mspec/matchers/include.rb +32 -0
- data/spec/app/mspec/matchers/match_yaml.rb +47 -0
- data/spec/app/mspec/matchers/method.rb +14 -0
- data/spec/app/mspec/matchers/output.rb +67 -0
- data/spec/app/mspec/matchers/output_to_fd.rb +71 -0
- data/spec/app/mspec/matchers/raise_error.rb +48 -0
- data/spec/app/mspec/matchers/respond_to.rb +24 -0
- data/spec/app/mspec/matchers/stringsymboladapter.rb +8 -0
- data/spec/app/mspec/mocks.rb +3 -0
- data/spec/app/mspec/mocks/mock.rb +159 -0
- data/spec/app/mspec/mocks/object.rb +20 -0
- data/spec/app/mspec/mocks/proxy.rb +136 -0
- data/spec/app/mspec/pp.rb +893 -0
- data/spec/app/mspec/runner.rb +15 -0
- data/spec/app/mspec/runner/actions.rb +8 -0
- data/spec/app/mspec/runner/actions/debug.rb +17 -0
- data/spec/app/mspec/runner/actions/filter.rb +40 -0
- data/spec/app/mspec/runner/actions/gdb.rb +17 -0
- data/spec/app/mspec/runner/actions/tag.rb +133 -0
- data/spec/app/mspec/runner/actions/taglist.rb +56 -0
- data/spec/app/mspec/runner/actions/tagpurge.rb +56 -0
- data/spec/app/mspec/runner/actions/tally.rb +116 -0
- data/spec/app/mspec/runner/actions/timer.rb +22 -0
- data/spec/app/mspec/runner/context.rb +188 -0
- data/spec/app/mspec/runner/example.rb +34 -0
- data/spec/app/mspec/runner/exception.rb +43 -0
- data/spec/app/mspec/runner/filters.rb +4 -0
- data/spec/app/mspec/runner/filters/match.rb +22 -0
- data/spec/app/mspec/runner/filters/profile.rb +54 -0
- data/spec/app/mspec/runner/filters/regexp.rb +7 -0
- data/spec/app/mspec/runner/filters/tag.rb +29 -0
- data/spec/app/mspec/runner/formatters.rb +10 -0
- data/spec/app/mspec/runner/formatters/describe.rb +24 -0
- data/spec/app/mspec/runner/formatters/dotted.rb +98 -0
- data/spec/app/mspec/runner/formatters/file.rb +19 -0
- data/spec/app/mspec/runner/formatters/html.rb +81 -0
- data/spec/app/mspec/runner/formatters/method.rb +93 -0
- data/spec/app/mspec/runner/formatters/specdoc.rb +41 -0
- data/spec/app/mspec/runner/formatters/spinner.rb +99 -0
- data/spec/app/mspec/runner/formatters/summary.rb +11 -0
- data/spec/app/mspec/runner/formatters/unit.rb +21 -0
- data/spec/app/mspec/runner/formatters/yaml.rb +44 -0
- data/spec/app/mspec/runner/mspec.rb +361 -0
- data/spec/app/mspec/runner/object.rb +24 -0
- data/spec/app/mspec/runner/shared.rb +12 -0
- data/spec/app/mspec/runner/tag.rb +32 -0
- data/spec/app/mspec/utils/name_map.rb +129 -0
- data/spec/app/mspec/utils/options.rb +441 -0
- data/spec/app/mspec/utils/ruby_name.rb +8 -0
- data/spec/app/mspec/utils/script.rb +220 -0
- data/spec/app/mspec/utils/version.rb +53 -0
- data/spec/app/mspec/version.rb +5 -0
- data/spec/app/spec/fixtures/client_info.txt +2 -0
- data/spec/app/spec/fixtures/object_values.txt +90 -0
- data/spec/{rho_controller_spec.rb → app/spec/rho_controller_spec.rb} +4 -7
- data/spec/{rho_spec.rb → app/spec/rho_spec.rb} +15 -36
- data/spec/{rhom_object_factory_spec.rb → app/spec/rhom_object_factory_spec.rb} +108 -72
- data/spec/{rhom_spec.rb → app/spec/rhom_spec.rb} +8 -4
- data/spec/app/spec/spec_helper.rb +15 -0
- data/spec/app/spec/webview_spec.rb +27 -0
- data/spec/app/spec_runner.rb +26 -0
- data/spec/build.yml +28 -0
- data/spec/public/css/base.css +39 -0
- data/spec/public/css/blackberry.css +99 -0
- data/spec/public/css/iphone.css +392 -0
- data/spec/public/css/rho.css +3 -0
- data/spec/public/css/xhtml.css +114 -0
- data/spec/public/images/IUI_LICENSE.txt +21 -0
- data/spec/public/images/backButton.png +0 -0
- data/spec/public/images/blueButton.png +0 -0
- data/spec/public/images/cancel.png +0 -0
- data/spec/public/images/grayButton.png +0 -0
- data/spec/public/images/iui-logo-touch-icon.png +0 -0
- data/spec/public/images/listArrow.png +0 -0
- data/spec/public/images/listArrowSel.png +0 -0
- data/spec/public/images/listGroup.png +0 -0
- data/spec/public/images/loading.gif +0 -0
- data/spec/public/images/pinstripes.png +0 -0
- data/spec/public/images/right_button.png +0 -0
- data/spec/public/images/selection.png +0 -0
- data/spec/public/images/thumb.png +0 -0
- data/spec/public/images/toggle.png +0 -0
- data/spec/public/images/toggleOn.png +0 -0
- data/spec/public/images/toolButton.png +0 -0
- data/spec/public/images/toolButton_new.png +0 -0
- data/spec/public/images/toolbar.png +0 -0
- data/spec/public/images/whiteButton.png +0 -0
- data/spec/public/js/application.js +1 -0
- data/spec/public/js/jquery-1.2.6.min.js +32 -0
- data/spec/public/js/rho.js +4 -0
- data/spec/public/js/rhogeolocation-wm.js +59 -0
- data/spec/public/js/rhogeolocation.js +11 -0
- data/spec/rhoconfig.txt +19 -0
- metadata +169 -39
- data/History.txt +0 -37
- data/README.rdoc +0 -2
- data/lib/TestServe.rb +0 -9
- data/res/sqlite3/constants.rb +0 -49
- data/res/sqlite3/database.rb +0 -715
- data/res/sqlite3/driver/dl/api.rb +0 -154
- data/res/sqlite3/driver/dl/driver.rb +0 -307
- data/res/sqlite3/driver/native/driver.rb +0 -257
- data/res/sqlite3/errors.rb +0 -68
- data/res/sqlite3/pragmas.rb +0 -271
- data/res/sqlite3/resultset.rb +0 -176
- data/res/sqlite3/sqlite3_api.rb +0 -0
- data/res/sqlite3/statement.rb +0 -230
- data/res/sqlite3/translator.rb +0 -109
- data/res/sqlite3/value.rb +0 -57
- data/res/sqlite3/version.rb +0 -14
- data/rhodes.gemspec +0 -18
- data/spec/app_manifest.txt +0 -4
- data/spec/configs/contact.rb +0 -3
- data/spec/configs/employee.rb +0 -3
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -49
- data/spec/stubs.rb +0 -39
- data/spec/syncdbtest.sqlite +0 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'mspec/expectations/expectations'
|
2
|
+
require 'mspec/runner/actions/timer'
|
3
|
+
require 'mspec/runner/actions/tally'
|
4
|
+
|
5
|
+
class DottedFormatter
|
6
|
+
attr_reader :exceptions, :timer, :tally
|
7
|
+
|
8
|
+
def initialize(out=nil)
|
9
|
+
@exception = @failure = false
|
10
|
+
@exceptions = []
|
11
|
+
@count = 0
|
12
|
+
if out.nil?
|
13
|
+
@out = $stdout
|
14
|
+
else
|
15
|
+
@out = File.open out, "w"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Creates the +TimerAction+ and +TallyAction+ instances and
|
20
|
+
# registers them. Registers +self+ for the +:exception+,
|
21
|
+
# +:before+, +:after+, and +:finish+ actions.
|
22
|
+
def register
|
23
|
+
(@timer = TimerAction.new).register
|
24
|
+
(@tally = TallyAction.new).register
|
25
|
+
@counter = @tally.counter
|
26
|
+
|
27
|
+
MSpec.register :exception, self
|
28
|
+
MSpec.register :before, self
|
29
|
+
MSpec.register :after, self
|
30
|
+
MSpec.register :finish, self
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns true if any exception is raised while running
|
34
|
+
# an example. This flag is reset before each example
|
35
|
+
# is evaluated.
|
36
|
+
def exception?
|
37
|
+
@exception
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns true if all exceptions during the evaluation
|
41
|
+
# of an example are failures rather than errors. See
|
42
|
+
# <tt>ExceptionState#failure</tt>. This flag is reset
|
43
|
+
# before each example is evaluated.
|
44
|
+
def failure?
|
45
|
+
@failure
|
46
|
+
end
|
47
|
+
|
48
|
+
# Callback for the MSpec :before event. Resets the
|
49
|
+
# +#exception?+ and +#failure+ flags.
|
50
|
+
def before(state = nil)
|
51
|
+
@failure = @exception = false
|
52
|
+
end
|
53
|
+
|
54
|
+
# Callback for the MSpec :exception event. Stores the
|
55
|
+
# +ExceptionState+ object to generate the list of backtraces
|
56
|
+
# after all the specs are run. Also updates the internal
|
57
|
+
# +#exception?+ and +#failure?+ flags.
|
58
|
+
def exception(exception)
|
59
|
+
@count += 1
|
60
|
+
@failure = @exception ? @failure && exception.failure? : exception.failure?
|
61
|
+
@exception = true
|
62
|
+
@exceptions << exception
|
63
|
+
end
|
64
|
+
|
65
|
+
# Callback for the MSpec :after event. Prints an indicator
|
66
|
+
# for the result of evaluating this example as follows:
|
67
|
+
# . = No failure or error
|
68
|
+
# F = An ExpectationNotMetError was raised
|
69
|
+
# E = Any exception other than ExpectationNotMetError
|
70
|
+
def after(state = nil)
|
71
|
+
unless exception?
|
72
|
+
print "."
|
73
|
+
else
|
74
|
+
print failure? ? "F" : "E"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Callback for the MSpec :finish event. Prints a description
|
79
|
+
# and backtrace for every exception that occurred while
|
80
|
+
# evaluating the examples.
|
81
|
+
def finish
|
82
|
+
print "\n"
|
83
|
+
count = 0
|
84
|
+
@exceptions.each do |exc|
|
85
|
+
outcome = exc.failure? ? "FAILED" : "ERROR"
|
86
|
+
print "\n#{count += 1})\n#{exc.description} #{outcome}\n"
|
87
|
+
print exc.message, "\n"
|
88
|
+
print exc.backtrace, "\n"
|
89
|
+
end
|
90
|
+
print "\n#{@timer.format}\n\n#{@tally.format}\n"
|
91
|
+
end
|
92
|
+
|
93
|
+
# A convenience method to allow printing to different outputs.
|
94
|
+
def print(*args)
|
95
|
+
@out.print(*args)
|
96
|
+
@out.flush rescue nil #IronRuby throws a .NET exception on IO.flush
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'mspec/runner/formatters/dotted'
|
2
|
+
|
3
|
+
class FileFormatter < DottedFormatter
|
4
|
+
# Unregisters DottedFormatter#before, #after methods and
|
5
|
+
# registers #load, #unload, which perform the same duties
|
6
|
+
# as #before, #after in DottedFormatter.
|
7
|
+
def register
|
8
|
+
super
|
9
|
+
|
10
|
+
MSpec.unregister :before, self
|
11
|
+
MSpec.unregister :after, self
|
12
|
+
|
13
|
+
MSpec.register :load, self
|
14
|
+
MSpec.register :unload, self
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method :load, :before
|
18
|
+
alias_method :unload, :after
|
19
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'mspec/expectations/expectations'
|
2
|
+
require 'mspec/runner/formatters/dotted'
|
3
|
+
|
4
|
+
class HtmlFormatter < DottedFormatter
|
5
|
+
def register
|
6
|
+
super
|
7
|
+
MSpec.register :start, self
|
8
|
+
MSpec.register :enter, self
|
9
|
+
MSpec.register :leave, self
|
10
|
+
end
|
11
|
+
|
12
|
+
def start
|
13
|
+
print <<-EOH
|
14
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
15
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
16
|
+
<html>
|
17
|
+
<head>
|
18
|
+
<title>Spec Output For #{RUBY_NAME} (#{RUBY_VERSION})</title>
|
19
|
+
<style type="text/css">
|
20
|
+
ul {
|
21
|
+
list-style: none;
|
22
|
+
}
|
23
|
+
.fail {
|
24
|
+
color: red;
|
25
|
+
}
|
26
|
+
.pass {
|
27
|
+
color: green;
|
28
|
+
}
|
29
|
+
#details :target {
|
30
|
+
background-color: #ffffe0;
|
31
|
+
}
|
32
|
+
</style>
|
33
|
+
</head>
|
34
|
+
<body>
|
35
|
+
EOH
|
36
|
+
end
|
37
|
+
|
38
|
+
def enter(describe)
|
39
|
+
print "<div><p>#{describe}</p>\n<ul>\n"
|
40
|
+
end
|
41
|
+
|
42
|
+
def leave
|
43
|
+
print "</ul>\n</div>\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
def exception(exception)
|
47
|
+
super
|
48
|
+
outcome = exception.failure? ? "FAILED" : "ERROR"
|
49
|
+
print %[<li class="fail">- #{exception.it} (<a href="#details-#{@count}">]
|
50
|
+
print %[#{outcome} - #{@count}</a>)</li>\n]
|
51
|
+
end
|
52
|
+
|
53
|
+
def after(state)
|
54
|
+
print %[<li class="pass">- #{state.it}</li>\n] unless exception?
|
55
|
+
end
|
56
|
+
|
57
|
+
def finish
|
58
|
+
success = @exceptions.empty?
|
59
|
+
unless success
|
60
|
+
print "<hr>\n"
|
61
|
+
print %[<ol id="details">]
|
62
|
+
count = 0
|
63
|
+
@exceptions.each do |exc|
|
64
|
+
outcome = exc.failure? ? "FAILED" : "ERROR"
|
65
|
+
print %[\n<li id="details-#{count += 1}"><p>#{escape(exc.description)} #{outcome}</p>\n<p>]
|
66
|
+
print escape(exc.message)
|
67
|
+
print "</p>\n<pre>\n"
|
68
|
+
print escape(exc.backtrace)
|
69
|
+
print "</pre>\n</li>\n"
|
70
|
+
end
|
71
|
+
print "</ol>\n"
|
72
|
+
end
|
73
|
+
print %[<p>#{@timer.format}</p>\n]
|
74
|
+
print %[<p class="#{success ? "pass" : "fail"}">#{@tally.format}</p>\n]
|
75
|
+
print "</body>\n</html>\n"
|
76
|
+
end
|
77
|
+
|
78
|
+
def escape(string)
|
79
|
+
string.gsub("&", " ").gsub("<", "<").gsub(">", ">")
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'mspec/runner/formatters/dotted'
|
2
|
+
|
3
|
+
class MethodFormatter < DottedFormatter
|
4
|
+
attr_accessor :methods
|
5
|
+
|
6
|
+
def initialize(out=nil)
|
7
|
+
super
|
8
|
+
@methods = Hash.new do |h, k|
|
9
|
+
hash = {}
|
10
|
+
hash[:examples] = 0
|
11
|
+
hash[:expectations] = 0
|
12
|
+
hash[:failures] = 0
|
13
|
+
hash[:errors] = 0
|
14
|
+
hash[:exceptions] = []
|
15
|
+
h[k] = hash
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns the type of method as a "class", "instance",
|
20
|
+
# or "unknown".
|
21
|
+
def method_type(sep)
|
22
|
+
case sep
|
23
|
+
when '.', '::'
|
24
|
+
"class"
|
25
|
+
when '#'
|
26
|
+
"instance"
|
27
|
+
else
|
28
|
+
"unknown"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Callback for the MSpec :before event. Parses the
|
33
|
+
# describe string into class and method if possible.
|
34
|
+
# Resets the tallies so the counts are only for this
|
35
|
+
# example.
|
36
|
+
def before(state)
|
37
|
+
super
|
38
|
+
|
39
|
+
# The pattern for a method name is not correctly
|
40
|
+
# restrictive but it is simplistic and useful
|
41
|
+
# for our purpose.
|
42
|
+
/^([A-Za-z_]+\w*)(\.|#|::)([^ ]+)/ =~ state.describe
|
43
|
+
@key = $1 && $2 && $3 ? "#{$1}#{$2}#{$3}" : state.describe
|
44
|
+
|
45
|
+
unless methods.key? @key
|
46
|
+
h = methods[@key]
|
47
|
+
h[:class] = "#{$1}"
|
48
|
+
h[:method] = "#{$3}"
|
49
|
+
h[:type] = method_type $2
|
50
|
+
h[:description] = state.description
|
51
|
+
end
|
52
|
+
|
53
|
+
tally.counter.examples = 0
|
54
|
+
tally.counter.expectations = 0
|
55
|
+
tally.counter.failures = 0
|
56
|
+
tally.counter.errors = 0
|
57
|
+
|
58
|
+
@exceptions = []
|
59
|
+
end
|
60
|
+
|
61
|
+
# Callback for the MSpec :after event. Sets or adds to
|
62
|
+
# tallies for the example block.
|
63
|
+
def after(state)
|
64
|
+
h = methods[@key]
|
65
|
+
h[:examples] += tally.counter.examples
|
66
|
+
h[:expectations] += tally.counter.expectations
|
67
|
+
h[:failures] += tally.counter.failures
|
68
|
+
h[:errors] += tally.counter.errors
|
69
|
+
@exceptions.each do |exc|
|
70
|
+
h[:exceptions] << "#{exc.message}\n#{exc.backtrace}\n"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Callback for the MSpec :finish event. Prints out the
|
75
|
+
# summary information in YAML format for all the methods.
|
76
|
+
def finish
|
77
|
+
print "---\n"
|
78
|
+
|
79
|
+
methods.each do |key, hash|
|
80
|
+
print key.inspect, ":\n"
|
81
|
+
print " class: ", hash[:class].inspect, "\n"
|
82
|
+
print " method: ", hash[:method].inspect, "\n"
|
83
|
+
print " type: ", hash[:type], "\n"
|
84
|
+
print " description: ", hash[:description].inspect, "\n"
|
85
|
+
print " examples: ", hash[:examples], "\n"
|
86
|
+
print " expectations: ", hash[:expectations], "\n"
|
87
|
+
print " failures: ", hash[:failures], "\n"
|
88
|
+
print " errors: ", hash[:errors], "\n"
|
89
|
+
print " exceptions:\n"
|
90
|
+
hash[:exceptions].each { |exc| print " - ", exc.inspect, "\n" }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'mspec/expectations/expectations'
|
2
|
+
require 'mspec/runner/formatters/dotted'
|
3
|
+
|
4
|
+
class SpecdocFormatter < DottedFormatter
|
5
|
+
def register
|
6
|
+
super
|
7
|
+
MSpec.register :enter, self
|
8
|
+
end
|
9
|
+
|
10
|
+
# Callback for the MSpec :enter event. Prints the
|
11
|
+
# +describe+ block string.
|
12
|
+
def enter(describe)
|
13
|
+
print "\n#{describe}\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Callback for the MSpec :before event. Prints the
|
17
|
+
# +it+ block string.
|
18
|
+
def before(state)
|
19
|
+
super
|
20
|
+
print "- #{state.it}"
|
21
|
+
end
|
22
|
+
|
23
|
+
# Callback for the MSpec :exception event. Prints
|
24
|
+
# either 'ERROR - X' or 'FAILED - X' where _X_ is
|
25
|
+
# the sequential number of the exception raised. If
|
26
|
+
# there has already been an exception raised while
|
27
|
+
# evaluating this example, it prints another +it+
|
28
|
+
# block description string so that each discription
|
29
|
+
# string has an associated 'ERROR' or 'FAILED'
|
30
|
+
def exception(exception)
|
31
|
+
print "\n- #{exception.it}" if exception?
|
32
|
+
super
|
33
|
+
print " (#{exception.failure? ? 'FAILED' : 'ERROR'} - #{@count})"
|
34
|
+
end
|
35
|
+
|
36
|
+
# Callback for the MSpec :after event. Prints a
|
37
|
+
# newline to finish the description string output.
|
38
|
+
def after(state)
|
39
|
+
print "\n"
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'mspec/expectations/expectations'
|
2
|
+
require 'mspec/runner/formatters/dotted'
|
3
|
+
|
4
|
+
class SpinnerFormatter < DottedFormatter
|
5
|
+
attr_reader :length
|
6
|
+
|
7
|
+
Spins = %w!| / - \\!
|
8
|
+
HOUR = 3600
|
9
|
+
MIN = 60
|
10
|
+
|
11
|
+
def initialize(out=nil)
|
12
|
+
@exception = @failure = false
|
13
|
+
@exceptions = []
|
14
|
+
@count = 0
|
15
|
+
@out = $stdout
|
16
|
+
|
17
|
+
@which = 0
|
18
|
+
@loaded = 0
|
19
|
+
self.length = 40
|
20
|
+
@percent = 0
|
21
|
+
@start = Time.now
|
22
|
+
|
23
|
+
term = ENV['TERM']
|
24
|
+
@color = (term != "dumb")
|
25
|
+
@fail_color = "32"
|
26
|
+
@error_color = "32"
|
27
|
+
end
|
28
|
+
|
29
|
+
def register
|
30
|
+
super
|
31
|
+
|
32
|
+
MSpec.register :start, self
|
33
|
+
MSpec.register :load, self
|
34
|
+
end
|
35
|
+
|
36
|
+
def length=(length)
|
37
|
+
@length = length
|
38
|
+
@ratio = 100.0 / length
|
39
|
+
@position = length / 2 - 2
|
40
|
+
end
|
41
|
+
|
42
|
+
def etr
|
43
|
+
return "00:00:00" if @percent == 0
|
44
|
+
elapsed = Time.now - @start
|
45
|
+
remain = (100 * elapsed / @percent) - elapsed
|
46
|
+
|
47
|
+
hour = remain >= HOUR ? (remain / HOUR).to_i : 0
|
48
|
+
remain -= hour * HOUR
|
49
|
+
min = remain >= MIN ? (remain / MIN).to_i : 0
|
50
|
+
sec = remain - min * MIN
|
51
|
+
|
52
|
+
"%02d:%02d:%02d" % [hour, min, sec]
|
53
|
+
end
|
54
|
+
|
55
|
+
def percentage
|
56
|
+
@percent = @loaded * 100 / @total
|
57
|
+
bar = ("=" * (@percent / @ratio)).ljust @length
|
58
|
+
label = "%d%%" % @percent
|
59
|
+
bar[@position, label.size] = label
|
60
|
+
bar
|
61
|
+
end
|
62
|
+
|
63
|
+
def spin
|
64
|
+
@which = (@which + 1) % Spins.size
|
65
|
+
if @color
|
66
|
+
print "\r[%s | %s | %s] \033[0;#{@fail_color}m%6dF \033[0;#{@error_color}m%6dE\033[0m" %
|
67
|
+
[Spins[@which], percentage, etr, @counter.failures, @counter.errors]
|
68
|
+
else
|
69
|
+
print "\r[%s | %s | %s] %6dF %6dE" %
|
70
|
+
[Spins[@which], percentage, etr, @counter.failures, @counter.errors]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Callback for the MSpec :start event. Stores the total
|
75
|
+
# number of files that will be processed.
|
76
|
+
def start
|
77
|
+
@total = MSpec.retrieve(:files).size
|
78
|
+
end
|
79
|
+
|
80
|
+
# Callback for the MSpec :load event. Increments the number
|
81
|
+
# of files that have been loaded.
|
82
|
+
def load
|
83
|
+
@loaded += 1
|
84
|
+
end
|
85
|
+
|
86
|
+
# Callback for the MSpec :exception event. Changes the color
|
87
|
+
# used to display the tally of errors and failures
|
88
|
+
def exception(exception)
|
89
|
+
super
|
90
|
+
@fail_color = "31" if exception.failure?
|
91
|
+
@error_color = "33" unless exception.failure?
|
92
|
+
end
|
93
|
+
|
94
|
+
# Callback for the MSpec :after event. Updates the spinner
|
95
|
+
# and progress bar.
|
96
|
+
def after(state)
|
97
|
+
spin
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'mspec/expectations/expectations'
|
2
|
+
require 'mspec/runner/formatters/dotted'
|
3
|
+
|
4
|
+
class SummaryFormatter < DottedFormatter
|
5
|
+
# Callback for the MSpec :after event. Overrides the
|
6
|
+
# callback provided by +DottedFormatter+ and does not
|
7
|
+
# print any output for each example evaluated.
|
8
|
+
def after(state)
|
9
|
+
# do nothing
|
10
|
+
end
|
11
|
+
end
|