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,22 @@
|
|
1
|
+
class TimerAction
|
2
|
+
def register
|
3
|
+
MSpec.register :start, self
|
4
|
+
MSpec.register :finish, self
|
5
|
+
end
|
6
|
+
|
7
|
+
def start
|
8
|
+
@start = Time.now
|
9
|
+
end
|
10
|
+
|
11
|
+
def finish
|
12
|
+
@stop = Time.now
|
13
|
+
end
|
14
|
+
|
15
|
+
def elapsed
|
16
|
+
@stop - @start
|
17
|
+
end
|
18
|
+
|
19
|
+
def format
|
20
|
+
"Finished in %f seconds" % elapsed
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
# Holds the state of the +describe+ block that is being
|
2
|
+
# evaluated. Every example (i.e. +it+ block) is evaluated
|
3
|
+
# in a context, which may include state set up in <tt>before
|
4
|
+
# :each</tt> or <tt>before :all</tt> blocks.
|
5
|
+
#
|
6
|
+
#--
|
7
|
+
# A note on naming: this is named _ContextState_ rather
|
8
|
+
# than _DescribeState_ because +describe+ is the keyword
|
9
|
+
# in the DSL for refering to the context in which an example
|
10
|
+
# is evaluated, just as +it+ refers to the example itself.
|
11
|
+
#++
|
12
|
+
class ContextState
|
13
|
+
attr_reader :state, :parent, :parents, :children, :examples, :to_s
|
14
|
+
|
15
|
+
def initialize(mod, options=nil)
|
16
|
+
@to_s = mod.to_s
|
17
|
+
if options.is_a? Hash
|
18
|
+
@options = options
|
19
|
+
else
|
20
|
+
@to_s += "#{".:#".include?(options[0,1]) ? "" : " "}#{options}" if options
|
21
|
+
@options = { }
|
22
|
+
end
|
23
|
+
@options[:shared] ||= false
|
24
|
+
|
25
|
+
@parsed = false
|
26
|
+
@before = { :all => [], :each => [] }
|
27
|
+
@after = { :all => [], :each => [] }
|
28
|
+
@pre = {}
|
29
|
+
@post = {}
|
30
|
+
@examples = []
|
31
|
+
@parent = nil
|
32
|
+
@parents = [self]
|
33
|
+
@children = []
|
34
|
+
|
35
|
+
@mock_verify = lambda { Mock.verify_count }
|
36
|
+
@mock_cleanup = lambda { Mock.cleanup }
|
37
|
+
@expectation_missing = lambda { raise ExpectationNotFoundError }
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns true if this is a shared +ContextState+. Essentially, when
|
41
|
+
# created with: describe "Something", :shared => true { ... }
|
42
|
+
def shared?
|
43
|
+
return @options[:shared]
|
44
|
+
end
|
45
|
+
|
46
|
+
# Set the parent (enclosing) +ContextState+ for this state. Creates
|
47
|
+
# the +parents+ list.
|
48
|
+
def parent=(parent)
|
49
|
+
@description = nil
|
50
|
+
@parent = parent
|
51
|
+
parent.child self if parent and not shared?
|
52
|
+
|
53
|
+
state = parent
|
54
|
+
while state
|
55
|
+
parents.unshift state
|
56
|
+
state = state.parent
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Add the ContextState instance +child+ to the list of nested
|
61
|
+
# describe blocks.
|
62
|
+
def child(child)
|
63
|
+
@children << child
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns a list of all before(+what+) blocks from self and any parents.
|
67
|
+
def pre(what)
|
68
|
+
@pre[what] ||= parents.inject([]) { |l, s| l.push(*s.before(what)) }
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns a list of all after(+what+) blocks from self and any parents.
|
72
|
+
# The list is in reverse order. In other words, the blocks defined in
|
73
|
+
# inner describes are in the list before those defined in outer describes,
|
74
|
+
# and in a particular describe block those defined later are in the list
|
75
|
+
# before those defined earlier.
|
76
|
+
def post(what)
|
77
|
+
@post[what] ||= parents.inject([]) { |l, s| l.unshift(*s.after(what)) }
|
78
|
+
end
|
79
|
+
|
80
|
+
# Records before(:each) and before(:all) blocks.
|
81
|
+
def before(what, &block)
|
82
|
+
return if MSpec.guarded?
|
83
|
+
block ? @before[what].push(block) : @before[what]
|
84
|
+
end
|
85
|
+
|
86
|
+
# Records after(:each) and after(:all) blocks.
|
87
|
+
def after(what, &block)
|
88
|
+
return if MSpec.guarded?
|
89
|
+
block ? @after[what].unshift(block) : @after[what]
|
90
|
+
end
|
91
|
+
|
92
|
+
# Creates an ExampleState instance for the block and stores it
|
93
|
+
# in a list of examples to evaluate unless the example is filtered.
|
94
|
+
def it(desc, &block)
|
95
|
+
puts "- it \"#{desc}\""
|
96
|
+
example = ExampleState.new(self, desc, block)
|
97
|
+
MSpec.actions :add, example
|
98
|
+
return if MSpec.guarded?
|
99
|
+
@examples << example
|
100
|
+
end
|
101
|
+
|
102
|
+
# Evaluates the block and resets the toplevel +ContextState+ to #parent.
|
103
|
+
def describe(&block)
|
104
|
+
puts "describe \"#{self.to_s}\""
|
105
|
+
@parsed = protect @to_s, block, false
|
106
|
+
MSpec.register_current parent
|
107
|
+
MSpec.register_shared self if shared?
|
108
|
+
end
|
109
|
+
|
110
|
+
# Returns a description string generated from self and all parents
|
111
|
+
def description
|
112
|
+
@description ||= parents.map { |p| p.to_s }.join(" ")
|
113
|
+
end
|
114
|
+
|
115
|
+
# Injects the before/after blocks and examples from the shared
|
116
|
+
# describe block into this +ContextState+ instance.
|
117
|
+
def it_should_behave_like(desc)
|
118
|
+
return if MSpec.guarded?
|
119
|
+
|
120
|
+
unless state = MSpec.retrieve_shared(desc)
|
121
|
+
raise Exception, "Unable to find shared 'describe' for #{desc}"
|
122
|
+
end
|
123
|
+
|
124
|
+
state.examples.each { |ex| ex.context = self; @examples << ex }
|
125
|
+
state.before(:all).each { |b| before :all, &b }
|
126
|
+
state.before(:each).each { |b| before :each, &b }
|
127
|
+
state.after(:each).each { |b| after :each, &b }
|
128
|
+
state.after(:all).each { |b| after :all, &b }
|
129
|
+
end
|
130
|
+
|
131
|
+
# Evaluates each block in +blocks+ using the +MSpec.protect+ method
|
132
|
+
# so that exceptions are handled and tallied. Returns true and does
|
133
|
+
# NOT evaluate any blocks if +check+ is true and
|
134
|
+
# <tt>MSpec.mode?(:pretend)</tt> is true.
|
135
|
+
def protect(what, blocks, check=true)
|
136
|
+
return true if check and MSpec.mode? :pretend
|
137
|
+
Array(blocks).all? { |block| MSpec.protect what, &block }
|
138
|
+
end
|
139
|
+
|
140
|
+
# Removes filtered examples. Returns true if there are examples
|
141
|
+
# left to evaluate.
|
142
|
+
def filter_examples
|
143
|
+
@examples.reject! { |ex| ex.filtered? }
|
144
|
+
not @examples.empty?
|
145
|
+
end
|
146
|
+
|
147
|
+
# Evaluates the examples in a +ContextState+. Invokes the MSpec events
|
148
|
+
# for :enter, :before, :after, :leave.
|
149
|
+
def process
|
150
|
+
MSpec.register_current self
|
151
|
+
|
152
|
+
if @parsed and filter_examples
|
153
|
+
MSpec.shuffle @examples if MSpec.randomize?
|
154
|
+
MSpec.actions :enter, description
|
155
|
+
|
156
|
+
if protect "before :all", pre(:all)
|
157
|
+
@examples.each do |state|
|
158
|
+
@state = state
|
159
|
+
example = state.example
|
160
|
+
MSpec.actions :before, state
|
161
|
+
|
162
|
+
if protect "before :each", pre(:each)
|
163
|
+
MSpec.clear_expectations
|
164
|
+
if example
|
165
|
+
passed = protect nil, example
|
166
|
+
MSpec.actions :example, state, example
|
167
|
+
protect nil, @expectation_missing unless MSpec.expectation? or not passed
|
168
|
+
end
|
169
|
+
protect "after :each", post(:each)
|
170
|
+
protect "Mock.verify_count", @mock_verify
|
171
|
+
end
|
172
|
+
|
173
|
+
protect "Mock.cleanup", @mock_cleanup
|
174
|
+
MSpec.actions :after, state
|
175
|
+
@state = nil
|
176
|
+
end
|
177
|
+
protect "after :all", post(:all)
|
178
|
+
else
|
179
|
+
protect "Mock.cleanup", @mock_cleanup
|
180
|
+
end
|
181
|
+
|
182
|
+
MSpec.actions :leave
|
183
|
+
end
|
184
|
+
|
185
|
+
MSpec.register_current nil
|
186
|
+
children.each { |child| child.process }
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'mspec/runner/mspec'
|
2
|
+
|
3
|
+
# Holds some of the state of the example (i.e. +it+ block) that is
|
4
|
+
# being evaluated. See also +ContextState+.
|
5
|
+
class ExampleState
|
6
|
+
attr_reader :context, :it, :example
|
7
|
+
|
8
|
+
def initialize(context, it, example=nil)
|
9
|
+
@context = context
|
10
|
+
@it = it
|
11
|
+
@example = example
|
12
|
+
end
|
13
|
+
|
14
|
+
def context=(context)
|
15
|
+
@description = nil
|
16
|
+
@context = context
|
17
|
+
end
|
18
|
+
|
19
|
+
def describe
|
20
|
+
@context.description
|
21
|
+
end
|
22
|
+
|
23
|
+
def description
|
24
|
+
@description ||= "#{describe} #{@it}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def filtered?
|
28
|
+
incl = MSpec.retrieve(:include) || []
|
29
|
+
excl = MSpec.retrieve(:exclude) || []
|
30
|
+
included = incl.empty? || incl.any? { |f| f === description }
|
31
|
+
included &&= excl.empty? || !excl.any? { |f| f === description }
|
32
|
+
not included
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class ExceptionState
|
2
|
+
attr_reader :description, :describe, :it, :exception
|
3
|
+
|
4
|
+
PATH = /#{File.expand_path(File.dirname(__FILE__) + '/../../..')}/
|
5
|
+
|
6
|
+
def initialize(state, location, exception)
|
7
|
+
@exception = exception
|
8
|
+
|
9
|
+
@description = location ? "An exception occurred during: #{location}" : ""
|
10
|
+
if state
|
11
|
+
@description << "\n" unless @description.empty?
|
12
|
+
@description << state.description
|
13
|
+
@describe = state.describe
|
14
|
+
@it = state.it
|
15
|
+
else
|
16
|
+
@describe = @it = ""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure?
|
21
|
+
[ExpectationNotMetError, ExpectationNotFoundError].any? { |e| @exception.is_a? e }
|
22
|
+
end
|
23
|
+
|
24
|
+
def message
|
25
|
+
if @exception.message.empty?
|
26
|
+
"<No message>"
|
27
|
+
elsif @exception.class == ExpectationNotMetError ||
|
28
|
+
@exception.class == ExpectationNotFoundError
|
29
|
+
@exception.message
|
30
|
+
else
|
31
|
+
"#{@exception.class}: #{@exception.message}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def backtrace
|
36
|
+
begin
|
37
|
+
bt = @exception.awesome_backtrace.show.split "\n"
|
38
|
+
rescue Exception
|
39
|
+
bt = @exception.backtrace || []
|
40
|
+
end
|
41
|
+
bt.reject { |line| PATH =~ line }.join("\n")
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class MatchFilter
|
2
|
+
def initialize(what, *strings)
|
3
|
+
@what = what
|
4
|
+
@descriptions = to_regexp(*strings)
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_regexp(*strings)
|
8
|
+
strings.map { |str| Regexp.new Regexp.escape(str) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def ===(string)
|
12
|
+
@descriptions.any? { |d| d === string }
|
13
|
+
end
|
14
|
+
|
15
|
+
def register
|
16
|
+
MSpec.register @what, self
|
17
|
+
end
|
18
|
+
|
19
|
+
def unregister
|
20
|
+
MSpec.unregister @what, self
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class ProfileFilter
|
2
|
+
def initialize(what, *files)
|
3
|
+
@what = what
|
4
|
+
@methods = load(*files)
|
5
|
+
@pattern = /([^ .#]+[.#])([^ ]+)/
|
6
|
+
end
|
7
|
+
|
8
|
+
def find(name)
|
9
|
+
return name if File.exist?(File.expand_path(name))
|
10
|
+
|
11
|
+
["spec/profiles", "spec", "profiles", "."].each do |dir|
|
12
|
+
file = File.join dir, name
|
13
|
+
return file if File.exist? file
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse(file)
|
18
|
+
pattern = /(\S+):\s*/
|
19
|
+
key = ""
|
20
|
+
file.inject(Hash.new { |h,k| h[k] = [] }) do |hash, line|
|
21
|
+
line.chomp!
|
22
|
+
if line[0,2] == "- "
|
23
|
+
hash[key] << line[2..-1].gsub(/[ '"]/, "")
|
24
|
+
elsif m = pattern.match(line)
|
25
|
+
key = m[1]
|
26
|
+
end
|
27
|
+
hash
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def load(*files)
|
32
|
+
files.inject({}) do |hash, file|
|
33
|
+
next hash unless name = find(file)
|
34
|
+
|
35
|
+
File.open name, "r" do |f|
|
36
|
+
hash.merge parse(f)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def ===(string)
|
42
|
+
return false unless m = @pattern.match(string)
|
43
|
+
return false unless l = @methods[m[1]]
|
44
|
+
l.include? m[2]
|
45
|
+
end
|
46
|
+
|
47
|
+
def register
|
48
|
+
MSpec.register @what, self
|
49
|
+
end
|
50
|
+
|
51
|
+
def unregister
|
52
|
+
MSpec.unregister @what, self
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'mspec/runner/filters/match'
|
2
|
+
|
3
|
+
class TagFilter
|
4
|
+
def initialize(what, *tags)
|
5
|
+
@what = what
|
6
|
+
@tags = tags
|
7
|
+
end
|
8
|
+
|
9
|
+
def load
|
10
|
+
desc = MSpec.read_tags(@tags).map { |t| t.description }
|
11
|
+
|
12
|
+
@filter = MatchFilter.new(@what, *desc)
|
13
|
+
@filter.register
|
14
|
+
end
|
15
|
+
|
16
|
+
def unload
|
17
|
+
@filter.unregister if @filter
|
18
|
+
end
|
19
|
+
|
20
|
+
def register
|
21
|
+
MSpec.register :load, self
|
22
|
+
MSpec.register :unload, self
|
23
|
+
end
|
24
|
+
|
25
|
+
def unregister
|
26
|
+
MSpec.unregister :load, self
|
27
|
+
MSpec.unregister :unload, self
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'mspec/runner/formatters/describe'
|
2
|
+
require 'mspec/runner/formatters/dotted'
|
3
|
+
require 'mspec/runner/formatters/file'
|
4
|
+
require 'mspec/runner/formatters/specdoc'
|
5
|
+
require 'mspec/runner/formatters/html'
|
6
|
+
require 'mspec/runner/formatters/summary'
|
7
|
+
require 'mspec/runner/formatters/unit'
|
8
|
+
require 'mspec/runner/formatters/spinner'
|
9
|
+
require 'mspec/runner/formatters/method'
|
10
|
+
require 'mspec/runner/formatters/yaml'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mspec/runner/formatters/dotted'
|
2
|
+
require 'mspec/runner/actions/tally'
|
3
|
+
|
4
|
+
class DescribeFormatter < DottedFormatter
|
5
|
+
# Callback for the MSpec :finish event. Prints a summary of
|
6
|
+
# the number of errors and failures for each +describe+ block.
|
7
|
+
def finish
|
8
|
+
describes = Hash.new { |h,k| h[k] = Tally.new }
|
9
|
+
|
10
|
+
@exceptions.each do |exc|
|
11
|
+
desc = describes[exc.describe]
|
12
|
+
exc.failure? ? desc.failures! : desc.errors!
|
13
|
+
end
|
14
|
+
|
15
|
+
print "\n"
|
16
|
+
describes.each do |d, t|
|
17
|
+
text = d.size > 40 ? "#{d[0,37]}..." : d.ljust(40)
|
18
|
+
print "\n#{text} #{t.failure}, #{t.error}"
|
19
|
+
end
|
20
|
+
print "\n" unless describes.empty?
|
21
|
+
|
22
|
+
print "\n#{@timer.format}\n\n#{@tally.format}\n"
|
23
|
+
end
|
24
|
+
end
|