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,15 @@
|
|
1
|
+
require 'mspec/mocks'
|
2
|
+
require 'mspec/runner/mspec'
|
3
|
+
require 'mspec/runner/context'
|
4
|
+
require 'mspec/runner/example'
|
5
|
+
require 'mspec/runner/object'
|
6
|
+
require 'mspec/runner/formatters'
|
7
|
+
require 'mspec/runner/actions'
|
8
|
+
require 'mspec/runner/filters'
|
9
|
+
require 'mspec/runner/shared'
|
10
|
+
require 'mspec/runner/tag'
|
11
|
+
|
12
|
+
def $stderr.write(str)
|
13
|
+
# The 'useless use of' warnings are a crime against OO.
|
14
|
+
str =~ /useless use of/ ? nil : super
|
15
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'mspec/runner/actions/tally'
|
2
|
+
require 'mspec/runner/actions/timer'
|
3
|
+
require 'mspec/runner/actions/filter'
|
4
|
+
require 'mspec/runner/actions/tag'
|
5
|
+
require 'mspec/runner/actions/taglist'
|
6
|
+
require 'mspec/runner/actions/tagpurge'
|
7
|
+
require 'mspec/runner/actions/debug'
|
8
|
+
require 'mspec/runner/actions/gdb'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mspec/runner/actions/filter'
|
2
|
+
|
3
|
+
class DebugAction < ActionFilter
|
4
|
+
def before(state)
|
5
|
+
Kernel.debugger if self === state.description
|
6
|
+
end
|
7
|
+
|
8
|
+
def register
|
9
|
+
super
|
10
|
+
MSpec.register :before, self
|
11
|
+
end
|
12
|
+
|
13
|
+
def unregister
|
14
|
+
super
|
15
|
+
MSpec.unregister :before, self
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'mspec/runner/filters/match'
|
2
|
+
|
3
|
+
# ActionFilter is a base class for actions that are triggered by
|
4
|
+
# specs that match the filter. The filter may be specified by
|
5
|
+
# strings that match spec descriptions or by tags for strings
|
6
|
+
# that match spec descriptions.
|
7
|
+
#
|
8
|
+
# Unlike TagFilter and RegexpFilter, ActionFilter instances do
|
9
|
+
# not affect the specs that are run. The filter is only used to
|
10
|
+
# trigger the action.
|
11
|
+
|
12
|
+
class ActionFilter
|
13
|
+
def initialize(tags=nil, descs=nil)
|
14
|
+
@tags = Array(tags)
|
15
|
+
descs = Array(descs)
|
16
|
+
@sfilter = MatchFilter.new(nil, *descs) unless descs.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
def ===(string)
|
20
|
+
@sfilter === string or @tfilter === string
|
21
|
+
end
|
22
|
+
|
23
|
+
def load
|
24
|
+
@tfilter = nil
|
25
|
+
return if @tags.empty?
|
26
|
+
|
27
|
+
desc = MSpec.read_tags(@tags).map { |t| t.description }
|
28
|
+
return if desc.empty?
|
29
|
+
|
30
|
+
@tfilter = MatchFilter.new(nil, *desc)
|
31
|
+
end
|
32
|
+
|
33
|
+
def register
|
34
|
+
MSpec.register :load, self
|
35
|
+
end
|
36
|
+
|
37
|
+
def unregister
|
38
|
+
MSpec.unregister :load, self
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mspec/runner/actions/filter'
|
2
|
+
|
3
|
+
class GdbAction < ActionFilter
|
4
|
+
def before(state)
|
5
|
+
Kernel.yield_gdb(true) if self === state.description
|
6
|
+
end
|
7
|
+
|
8
|
+
def register
|
9
|
+
super
|
10
|
+
MSpec.register :before, self
|
11
|
+
end
|
12
|
+
|
13
|
+
def unregister
|
14
|
+
super
|
15
|
+
MSpec.unregister :before, self
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'mspec/runner/actions/filter'
|
2
|
+
|
3
|
+
# TagAction - Write tagged spec description string to a
|
4
|
+
# tag file associated with each spec file.
|
5
|
+
#
|
6
|
+
# The action is triggered by specs whose descriptions
|
7
|
+
# match the filter created with 'tags' and/or 'desc'
|
8
|
+
#
|
9
|
+
# The action fires in the :after event, after the spec
|
10
|
+
# had been run. The action fires if the outcome of
|
11
|
+
# running the spec matches 'outcome'.
|
12
|
+
#
|
13
|
+
# The arguments are:
|
14
|
+
#
|
15
|
+
# action: :add, :del
|
16
|
+
# outcome: :pass, :fail, :all
|
17
|
+
# tag: the tag to create/delete
|
18
|
+
# comment: the comment to create
|
19
|
+
# tags: zero or more tags to get matching
|
20
|
+
# spec description strings from
|
21
|
+
# desc: zero or more strings to match the
|
22
|
+
# spec description strings
|
23
|
+
|
24
|
+
class TagAction < ActionFilter
|
25
|
+
def initialize(action, outcome, tag, comment, tags=nil, descs=nil)
|
26
|
+
super tags, descs
|
27
|
+
@action = action
|
28
|
+
@outcome = outcome
|
29
|
+
@tag = tag
|
30
|
+
@comment = comment
|
31
|
+
@report = []
|
32
|
+
@exception = false
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns true if there are no _tag_ or _description_ filters. This
|
36
|
+
# means that a TagAction matches any example by default. Otherwise,
|
37
|
+
# returns true if either the _tag_ or the _description_ filter
|
38
|
+
# matches +string+.
|
39
|
+
def ===(string)
|
40
|
+
return true unless @sfilter or @tfilter
|
41
|
+
@sfilter === string or @tfilter === string
|
42
|
+
end
|
43
|
+
|
44
|
+
# Callback for the MSpec :before event. Resets the +#exception?+
|
45
|
+
# flag to false.
|
46
|
+
def before(state)
|
47
|
+
@exception = false
|
48
|
+
end
|
49
|
+
|
50
|
+
# Callback for the MSpec :exception event. Sets the +#exception?+
|
51
|
+
# flag to true.
|
52
|
+
def exception(exception)
|
53
|
+
@exception = true
|
54
|
+
end
|
55
|
+
|
56
|
+
# Callback for the MSpec :after event. Performs the tag action
|
57
|
+
# depending on the type of action and the outcome of evaluating
|
58
|
+
# the example. See +TagAction+ for a description of the actions.
|
59
|
+
def after(state)
|
60
|
+
if self === state.description and outcome?
|
61
|
+
tag = SpecTag.new
|
62
|
+
tag.tag = @tag
|
63
|
+
tag.comment = @comment
|
64
|
+
tag.description = state.description
|
65
|
+
|
66
|
+
case @action
|
67
|
+
when :add
|
68
|
+
changed = MSpec.write_tag tag
|
69
|
+
when :del
|
70
|
+
changed = MSpec.delete_tag tag
|
71
|
+
end
|
72
|
+
|
73
|
+
@report << state.description if changed
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns true if the result of evaluating the example matches
|
78
|
+
# the _outcome_ registered for this tag action. See +TagAction+
|
79
|
+
# for a description of the _outcome_ types.
|
80
|
+
def outcome?
|
81
|
+
@outcome == :all or
|
82
|
+
(@outcome == :pass and not exception?) or
|
83
|
+
(@outcome == :fail and exception?)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns true if an exception was raised while evaluating the
|
87
|
+
# current example.
|
88
|
+
def exception?
|
89
|
+
@exception
|
90
|
+
end
|
91
|
+
|
92
|
+
def report
|
93
|
+
@report.join("\n") + "\n"
|
94
|
+
end
|
95
|
+
private :report
|
96
|
+
|
97
|
+
# Callback for the MSpec :finish event. Prints the actions
|
98
|
+
# performed while evaluating the examples.
|
99
|
+
def finish
|
100
|
+
case @action
|
101
|
+
when :add
|
102
|
+
if @report.empty?
|
103
|
+
print "\nTagAction: no specs were tagged with '#{@tag}'\n"
|
104
|
+
else
|
105
|
+
print "\nTagAction: specs tagged with '#{@tag}':\n\n"
|
106
|
+
print report
|
107
|
+
end
|
108
|
+
when :del
|
109
|
+
if @report.empty?
|
110
|
+
print "\nTagAction: no tags '#{@tag}' were deleted\n"
|
111
|
+
else
|
112
|
+
print "\nTagAction: tag '#{@tag}' deleted for specs:\n\n"
|
113
|
+
print report
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def register
|
119
|
+
super
|
120
|
+
MSpec.register :before, self
|
121
|
+
MSpec.register :exception, self
|
122
|
+
MSpec.register :after, self
|
123
|
+
MSpec.register :finish, self
|
124
|
+
end
|
125
|
+
|
126
|
+
def unregister
|
127
|
+
super
|
128
|
+
MSpec.unregister :before, self
|
129
|
+
MSpec.unregister :exception, self
|
130
|
+
MSpec.unregister :after, self
|
131
|
+
MSpec.unregister :finish, self
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'mspec/runner/actions/filter'
|
2
|
+
|
3
|
+
# TagListAction - prints out the descriptions for any specs
|
4
|
+
# tagged with +tags+. If +tags+ is an empty list, prints out
|
5
|
+
# descriptions for any specs that are tagged.
|
6
|
+
class TagListAction
|
7
|
+
def initialize(tags=nil)
|
8
|
+
@tags = tags.nil? || tags.empty? ? nil : Array(tags)
|
9
|
+
@filter = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns true. This enables us to match any tag when loading
|
13
|
+
# tags from the file.
|
14
|
+
def include?(arg)
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns true if any tagged descriptions matches +string+.
|
19
|
+
def ===(string)
|
20
|
+
@filter === string
|
21
|
+
end
|
22
|
+
|
23
|
+
# Prints a banner about matching tagged specs.
|
24
|
+
def start
|
25
|
+
if @tags
|
26
|
+
print "\nListing specs tagged with #{@tags.map { |t| "'#{t}'" }.join(", ") }\n\n"
|
27
|
+
else
|
28
|
+
print "\nListing all tagged specs\n\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates a MatchFilter for specific tags or for all tags.
|
33
|
+
def load
|
34
|
+
@filter = nil
|
35
|
+
desc = MSpec.read_tags(@tags || self).map { |t| t.description }
|
36
|
+
@filter = MatchFilter.new(nil, *desc) unless desc.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
# Prints the spec description if it matches the filter.
|
40
|
+
def after(state)
|
41
|
+
return unless self === state.description
|
42
|
+
print state.description, "\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
def register
|
46
|
+
MSpec.register :start, self
|
47
|
+
MSpec.register :load, self
|
48
|
+
MSpec.register :after, self
|
49
|
+
end
|
50
|
+
|
51
|
+
def unregister
|
52
|
+
MSpec.unregister :start, self
|
53
|
+
MSpec.unregister :load, self
|
54
|
+
MSpec.unregister :after, self
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'mspec/runner/actions/filter'
|
2
|
+
require 'mspec/runner/actions/taglist'
|
3
|
+
|
4
|
+
# TagPurgeAction - removes all tags not matching any spec
|
5
|
+
# descriptions.
|
6
|
+
class TagPurgeAction < TagListAction
|
7
|
+
attr_reader :matching
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@matching = []
|
11
|
+
@filter = nil
|
12
|
+
@tags = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
# Prints a banner about purging tags.
|
16
|
+
def start
|
17
|
+
print "\nRemoving tags not matching any specs\n\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Creates a MatchFilter for all tags.
|
21
|
+
def load
|
22
|
+
@filter = nil
|
23
|
+
@tags = MSpec.read_tags self
|
24
|
+
desc = @tags.map { |t| t.description }
|
25
|
+
@filter = MatchFilter.new(nil, *desc) unless desc.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
# Saves any matching tags
|
29
|
+
def after(state)
|
30
|
+
@matching << state.description if self === state.description
|
31
|
+
end
|
32
|
+
|
33
|
+
# Rewrites any matching tags. Prints non-matching tags.
|
34
|
+
# Deletes the tag file if there were no tags (this cleans
|
35
|
+
# up empty or malformed tag files).
|
36
|
+
def unload
|
37
|
+
if @filter
|
38
|
+
matched = @tags.select { |t| @matching.any? { |s| s == t.description } }
|
39
|
+
MSpec.write_tags matched
|
40
|
+
|
41
|
+
(@tags - matched).each { |t| print t.description, "\n" }
|
42
|
+
else
|
43
|
+
MSpec.delete_tags
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def register
|
48
|
+
super
|
49
|
+
MSpec.register :unload, self
|
50
|
+
end
|
51
|
+
|
52
|
+
def unregister
|
53
|
+
super
|
54
|
+
MSpec.unregister :unload, self
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
class Tally
|
2
|
+
attr_accessor :files, :examples, :expectations, :failures, :errors, :guards
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@files = @examples = @expectations = @failures = @errors = @guards = 0
|
6
|
+
end
|
7
|
+
|
8
|
+
def files!(add=1)
|
9
|
+
@files += add
|
10
|
+
end
|
11
|
+
|
12
|
+
def examples!(add=1)
|
13
|
+
@examples += add
|
14
|
+
end
|
15
|
+
|
16
|
+
def expectations!(add=1)
|
17
|
+
@expectations += add
|
18
|
+
end
|
19
|
+
|
20
|
+
def failures!(add=1)
|
21
|
+
@failures += add
|
22
|
+
end
|
23
|
+
|
24
|
+
def errors!(add=1)
|
25
|
+
@errors += add
|
26
|
+
end
|
27
|
+
|
28
|
+
def guards!(add=1)
|
29
|
+
@guards += add
|
30
|
+
end
|
31
|
+
|
32
|
+
def file
|
33
|
+
pluralize files, "file"
|
34
|
+
end
|
35
|
+
|
36
|
+
def example
|
37
|
+
pluralize examples, "example"
|
38
|
+
end
|
39
|
+
|
40
|
+
def expectation
|
41
|
+
pluralize expectations, "expectation"
|
42
|
+
end
|
43
|
+
|
44
|
+
def failure
|
45
|
+
pluralize failures, "failure"
|
46
|
+
end
|
47
|
+
|
48
|
+
def error
|
49
|
+
pluralize errors, "error"
|
50
|
+
end
|
51
|
+
|
52
|
+
def guard
|
53
|
+
pluralize guards, "guard"
|
54
|
+
end
|
55
|
+
|
56
|
+
def format
|
57
|
+
results = [ file, example, expectation, failure, error ]
|
58
|
+
results << guard if [:report, :report_on, :verify].any? { |m| MSpec.mode? m }
|
59
|
+
results.join(", ")
|
60
|
+
end
|
61
|
+
|
62
|
+
alias_method :to_s, :format
|
63
|
+
|
64
|
+
def pluralize(count, singular)
|
65
|
+
"#{count} #{singular}#{'s' unless count == 1}"
|
66
|
+
end
|
67
|
+
private :pluralize
|
68
|
+
end
|
69
|
+
|
70
|
+
class TallyAction
|
71
|
+
attr_reader :counter
|
72
|
+
|
73
|
+
def initialize
|
74
|
+
@counter = Tally.new
|
75
|
+
end
|
76
|
+
|
77
|
+
def register
|
78
|
+
MSpec.register :load, self
|
79
|
+
MSpec.register :exception, self
|
80
|
+
MSpec.register :example, self
|
81
|
+
MSpec.register :expectation, self
|
82
|
+
end
|
83
|
+
|
84
|
+
def unregister
|
85
|
+
MSpec.unregister :load, self
|
86
|
+
MSpec.unregister :exception, self
|
87
|
+
MSpec.unregister :example, self
|
88
|
+
MSpec.unregister :expectation, self
|
89
|
+
end
|
90
|
+
|
91
|
+
def load
|
92
|
+
@counter.files!
|
93
|
+
end
|
94
|
+
|
95
|
+
# Callback for the MSpec :expectation event. Increments the
|
96
|
+
# tally of expectations (e.g. #should, #should_receive, etc.).
|
97
|
+
def expectation(state)
|
98
|
+
@counter.expectations!
|
99
|
+
end
|
100
|
+
|
101
|
+
# Callback for the MSpec :exception event. Increments the
|
102
|
+
# tally of errors and failures.
|
103
|
+
def exception(exception)
|
104
|
+
exception.failure? ? @counter.failures! : @counter.errors!
|
105
|
+
end
|
106
|
+
|
107
|
+
# Callback for the MSpec :example event. Increments the tally
|
108
|
+
# of examples.
|
109
|
+
def example(state, block)
|
110
|
+
@counter.examples!
|
111
|
+
end
|
112
|
+
|
113
|
+
def format
|
114
|
+
@counter.format
|
115
|
+
end
|
116
|
+
end
|