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,23 @@
|
|
1
|
+
require 'mspec/matchers/base'
|
2
|
+
require 'mspec/matchers/be_ancestor_of'
|
3
|
+
require 'mspec/matchers/be_close'
|
4
|
+
require 'mspec/matchers/be_empty'
|
5
|
+
require 'mspec/matchers/be_false'
|
6
|
+
require 'mspec/matchers/be_kind_of'
|
7
|
+
require 'mspec/matchers/be_nil'
|
8
|
+
require 'mspec/matchers/be_true'
|
9
|
+
require 'mspec/matchers/complain'
|
10
|
+
require 'mspec/matchers/eql'
|
11
|
+
require 'mspec/matchers/equal'
|
12
|
+
require 'mspec/matchers/equal_element'
|
13
|
+
require 'mspec/matchers/equal_utf16'
|
14
|
+
require 'mspec/matchers/have_constant'
|
15
|
+
require 'mspec/matchers/have_instance_method'
|
16
|
+
require 'mspec/matchers/have_method'
|
17
|
+
require 'mspec/matchers/have_private_instance_method'
|
18
|
+
require 'mspec/matchers/include'
|
19
|
+
require 'mspec/matchers/match_yaml'
|
20
|
+
require 'mspec/matchers/raise_error'
|
21
|
+
require 'mspec/matchers/output'
|
22
|
+
require 'mspec/matchers/output_to_fd'
|
23
|
+
require 'mspec/matchers/respond_to'
|
@@ -0,0 +1,95 @@
|
|
1
|
+
class PositiveOperatorMatcher
|
2
|
+
def initialize(actual)
|
3
|
+
@actual = actual
|
4
|
+
end
|
5
|
+
|
6
|
+
def ==(expected)
|
7
|
+
unless @actual == expected
|
8
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
9
|
+
"to equal #{expected.pretty_inspect}")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def <(expected)
|
14
|
+
unless @actual < expected
|
15
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
16
|
+
"to be less than #{expected.pretty_inspect}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def <=(expected)
|
21
|
+
unless @actual <= expected
|
22
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
23
|
+
"to be less than or equal to #{expected.pretty_inspect}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def >(expected)
|
28
|
+
unless @actual > expected
|
29
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
30
|
+
"to be greater than #{expected.pretty_inspect}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def >=(expected)
|
35
|
+
unless @actual >= expected
|
36
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
37
|
+
"to be greater than or equal to #{expected.pretty_inspect}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def =~(expected)
|
42
|
+
unless @actual =~ expected
|
43
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
44
|
+
"to match #{expected.pretty_inspect}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class NegativeOperatorMatcher
|
50
|
+
def initialize(actual)
|
51
|
+
@actual = actual
|
52
|
+
end
|
53
|
+
|
54
|
+
def ==(expected)
|
55
|
+
if @actual == expected
|
56
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
57
|
+
"not to equal #{expected.pretty_inspect}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def <(expected)
|
62
|
+
if @actual < expected
|
63
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
64
|
+
"not to be less than #{expected.pretty_inspect}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def <=(expected)
|
69
|
+
if @actual <= expected
|
70
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
71
|
+
"not to be less than or equal to #{expected.pretty_inspect}")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def >(expected)
|
76
|
+
if @actual > expected
|
77
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
78
|
+
"not to be greater than #{expected.pretty_inspect}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def >=(expected)
|
83
|
+
if @actual >= expected
|
84
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
85
|
+
"not to be greater than or equal to #{expected.pretty_inspect}")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def =~(expected)
|
90
|
+
if @actual =~ expected
|
91
|
+
Expectation.fail_with("Expected #{@actual.pretty_inspect}",
|
92
|
+
"not to match #{expected.pretty_inspect}")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class BeAnInstanceOfMatcher
|
2
|
+
def initialize(expected)
|
3
|
+
@expected = expected
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?(actual)
|
7
|
+
@actual = actual
|
8
|
+
@actual.instance_of?(@expected)
|
9
|
+
end
|
10
|
+
|
11
|
+
def failure_message
|
12
|
+
["Expected #{@actual.inspect} (#{@actual.class})",
|
13
|
+
"to be an instance of #{@expected}"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def negative_failure_message
|
17
|
+
["Expected #{@actual.inspect} (#{@actual.class})",
|
18
|
+
"not to be an instance of #{@expected}"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Object
|
23
|
+
def be_an_instance_of(expected)
|
24
|
+
BeAnInstanceOfMatcher.new(expected)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class BeAncestorOfMatcher
|
2
|
+
def initialize(expected)
|
3
|
+
@expected = expected
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?(actual)
|
7
|
+
@actual = actual
|
8
|
+
@expected.ancestors.include? @actual
|
9
|
+
end
|
10
|
+
|
11
|
+
def failure_message
|
12
|
+
["Expected #{@actual}", "to be an ancestor of #{@expected}"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def negative_failure_message
|
16
|
+
["Expected #{@actual}", "not to be an ancestor of #{@expected}"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Object
|
21
|
+
def be_ancestor_of(expected)
|
22
|
+
BeAncestorOfMatcher.new(expected)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
TOLERANCE = 0.00003 unless Object.const_defined?(:TOLERANCE)
|
2
|
+
|
3
|
+
class BeCloseMatcher
|
4
|
+
def initialize(expected, tolerance)
|
5
|
+
@expected = expected
|
6
|
+
@tolerance = tolerance
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(actual)
|
10
|
+
@actual = actual
|
11
|
+
(@actual - @expected).abs < @tolerance
|
12
|
+
end
|
13
|
+
|
14
|
+
def failure_message
|
15
|
+
["Expected #{@expected}", "to be within +/- #{@tolerance} of #{@actual}"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def negative_failure_message
|
19
|
+
["Expected #{@expected}", "not to be within +/- #{@tolerance} of #{@actual}"]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Object
|
24
|
+
def be_close(expected, tolerance)
|
25
|
+
BeCloseMatcher.new(expected, tolerance)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class BeEmptyMatcher
|
2
|
+
def matches?(actual)
|
3
|
+
@actual = actual
|
4
|
+
@actual.empty?
|
5
|
+
end
|
6
|
+
|
7
|
+
def failure_message
|
8
|
+
["Expected #{@actual.inspect}", "to be empty"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def negative_failure_message
|
12
|
+
["Expected #{@actual.inspect}", "not to be empty"]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Object
|
17
|
+
def be_empty
|
18
|
+
BeEmptyMatcher.new
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class BeFalseMatcher
|
2
|
+
def matches?(actual)
|
3
|
+
@actual = actual
|
4
|
+
@actual == false
|
5
|
+
end
|
6
|
+
|
7
|
+
def failure_message
|
8
|
+
["Expected #{@actual.inspect}", "to be false"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def negative_failure_message
|
12
|
+
["Expected #{@actual.inspect}", "not to be false"]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Object
|
17
|
+
def be_false
|
18
|
+
BeFalseMatcher.new
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class BeKindOfMatcher
|
2
|
+
def initialize(expected)
|
3
|
+
@expected = expected
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?(actual)
|
7
|
+
@actual = actual
|
8
|
+
@actual.is_a?(@expected)
|
9
|
+
end
|
10
|
+
|
11
|
+
def failure_message
|
12
|
+
["Expected #{@actual.inspect} (#{@actual.class})", "to be kind of #{@expected}"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def negative_failure_message
|
16
|
+
["Expected #{@actual.inspect} (#{@actual.class})", "not to be kind of #{@expected}"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Object
|
21
|
+
def be_kind_of(expected)
|
22
|
+
BeKindOfMatcher.new(expected)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class BeNilMatcher
|
2
|
+
def matches?(actual)
|
3
|
+
@actual = actual
|
4
|
+
@actual.nil?
|
5
|
+
end
|
6
|
+
|
7
|
+
def failure_message
|
8
|
+
["Expected #{@actual.inspect}", "to be nil"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def negative_failure_message
|
12
|
+
["Expected #{@actual.inspect}", "not to be nil"]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Object
|
17
|
+
def be_nil
|
18
|
+
BeNilMatcher.new
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class BeTrueMatcher
|
2
|
+
def matches?(actual)
|
3
|
+
@actual = actual
|
4
|
+
@actual == true
|
5
|
+
end
|
6
|
+
|
7
|
+
def failure_message
|
8
|
+
["Expected #{@actual.inspect}", "to be true"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def negative_failure_message
|
12
|
+
["Expected #{@actual.inspect}", "not to be true"]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Object
|
17
|
+
def be_true
|
18
|
+
BeTrueMatcher.new
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'mspec/helpers/io'
|
2
|
+
|
3
|
+
class ComplainMatcher
|
4
|
+
def initialize(complaint)
|
5
|
+
@complaint = complaint
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(proc)
|
9
|
+
@saved_err = $stderr
|
10
|
+
@stderr = $stderr = IOStub.new
|
11
|
+
@verbose = $VERBOSE
|
12
|
+
$VERBOSE = false
|
13
|
+
|
14
|
+
proc.call
|
15
|
+
|
16
|
+
unless @complaint.nil?
|
17
|
+
case @complaint
|
18
|
+
when Regexp
|
19
|
+
return false unless $stderr =~ @complaint
|
20
|
+
else
|
21
|
+
return false unless $stderr == @complaint
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
return $stderr.empty? ? false : true
|
26
|
+
ensure
|
27
|
+
$VERBOSE = @verbose
|
28
|
+
$stderr = @saved_err
|
29
|
+
end
|
30
|
+
|
31
|
+
def failure_message
|
32
|
+
if @complaint.nil?
|
33
|
+
["Expected a warning", "but received none"]
|
34
|
+
elsif @complaint.kind_of? Regexp
|
35
|
+
["Expected warning to match:", @complaint.inspect]
|
36
|
+
else
|
37
|
+
["Expected warning: #{@complaint.inspect}", "but got: #{@stderr.chomp.inspect}"]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def negative_failure_message
|
42
|
+
if @complaint.nil?
|
43
|
+
["Unexpected warning: ", @stderr.chomp.inspect]
|
44
|
+
elsif @complaint.kind_of? Regexp
|
45
|
+
["Expected warning not to match:", @complaint.inspect]
|
46
|
+
else
|
47
|
+
["Expected warning: #{@complaint.inspect}", "but got: #{@stderr.chomp.inspect}"]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Object
|
53
|
+
def complain(complaint=nil)
|
54
|
+
ComplainMatcher.new(complaint)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class EqlMatcher
|
2
|
+
def initialize(expected)
|
3
|
+
@expected = expected
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?(actual)
|
7
|
+
@actual = actual
|
8
|
+
@actual.eql?(@expected)
|
9
|
+
end
|
10
|
+
|
11
|
+
def failure_message
|
12
|
+
["Expected #{@actual.pretty_inspect}",
|
13
|
+
"to have same value and type as #{@expected.pretty_inspect}"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def negative_failure_message
|
17
|
+
["Expected #{@actual.pretty_inspect}",
|
18
|
+
"not to have same value or type as #{@expected.pretty_inspect}"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Object
|
23
|
+
def eql(expected)
|
24
|
+
EqlMatcher.new(expected)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class EqualMatcher
|
2
|
+
def initialize(expected)
|
3
|
+
@expected = expected
|
4
|
+
end
|
5
|
+
|
6
|
+
def matches?(actual)
|
7
|
+
@actual = actual
|
8
|
+
@actual.equal?(@expected)
|
9
|
+
end
|
10
|
+
|
11
|
+
def failure_message
|
12
|
+
["Expected #{@actual.pretty_inspect}",
|
13
|
+
"to be identical to #{@expected.pretty_inspect}"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def negative_failure_message
|
17
|
+
["Expected #{@actual.pretty_inspect}",
|
18
|
+
"not to be identical to #{@expected.pretty_inspect}"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Object
|
23
|
+
def equal(expected)
|
24
|
+
EqualMatcher.new(expected)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
class EqualElementMatcher
|
2
|
+
def initialize(element, attributes = nil, content = nil, options = {})
|
3
|
+
@element = element
|
4
|
+
@attributes = attributes
|
5
|
+
@content = content
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(actual)
|
10
|
+
@actual = actual
|
11
|
+
|
12
|
+
matched = true
|
13
|
+
|
14
|
+
if @options[:not_closed]
|
15
|
+
matched &&= actual =~ /^#{Regexp.quote("<" + @element)}.*#{Regexp.quote(">" + (@content || ''))}$/
|
16
|
+
else
|
17
|
+
matched &&= actual =~ /^#{Regexp.quote("<" + @element)}/
|
18
|
+
matched &&= actual =~ /#{Regexp.quote("</" + @element + ">")}$/
|
19
|
+
matched &&= actual =~ /#{Regexp.quote(">" + @content + "</")}/ if @content
|
20
|
+
end
|
21
|
+
|
22
|
+
if @attributes
|
23
|
+
if @attributes.empty?
|
24
|
+
matched &&= actual.scan(/\w+\=\"(.*)\"/).size == 0
|
25
|
+
else
|
26
|
+
@attributes.each do |key, value|
|
27
|
+
if value == true
|
28
|
+
matched &&= (actual.scan(/#{Regexp.quote(key)}(\s|>)/).size == 1)
|
29
|
+
else
|
30
|
+
matched &&= (actual.scan(%Q{ #{key}="#{value}"}).size == 1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
!!matched
|
37
|
+
end
|
38
|
+
|
39
|
+
def failure_message
|
40
|
+
["Expected #{@actual.pretty_inspect}",
|
41
|
+
"to be a '#{@element}' element with #{attributes_for_failure_message} and #{content_for_failure_message}"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def negative_failure_message
|
45
|
+
["Expected #{@actual.pretty_inspect}",
|
46
|
+
"not to be a '#{@element}' element with #{attributes_for_failure_message} and #{content_for_failure_message}"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def attributes_for_failure_message
|
50
|
+
if @attributes
|
51
|
+
if @attributes.empty?
|
52
|
+
"no attributes"
|
53
|
+
else
|
54
|
+
@attributes.inject([]) { |memo, n| memo << %Q{#{n[0]}="#{n[1]}"} }.join(" ")
|
55
|
+
end
|
56
|
+
else
|
57
|
+
"any attributes"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def content_for_failure_message
|
62
|
+
if @content
|
63
|
+
if @content.empty?
|
64
|
+
"no content"
|
65
|
+
else
|
66
|
+
"#{@content.inspect} as content"
|
67
|
+
end
|
68
|
+
else
|
69
|
+
"any content"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Object
|
75
|
+
def equal_element(*args)
|
76
|
+
EqualElementMatcher.new(*args)
|
77
|
+
end
|
78
|
+
end
|