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,16 @@
|
|
1
|
+
require 'mspec/utils/ruby_name'
|
2
|
+
require 'mspec/guards/background'
|
3
|
+
require 'mspec/guards/bug'
|
4
|
+
require 'mspec/guards/compliance'
|
5
|
+
require 'mspec/guards/conflict'
|
6
|
+
require 'mspec/guards/endian'
|
7
|
+
require 'mspec/guards/extensions'
|
8
|
+
require 'mspec/guards/guard'
|
9
|
+
require 'mspec/guards/noncompliance'
|
10
|
+
require 'mspec/guards/platform'
|
11
|
+
require 'mspec/guards/quarantine'
|
12
|
+
require 'mspec/guards/runner'
|
13
|
+
require 'mspec/guards/support'
|
14
|
+
require 'mspec/guards/superuser'
|
15
|
+
require 'mspec/guards/tty'
|
16
|
+
require 'mspec/guards/version'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
# Some specs, notably those for Readline, will block under certain
|
4
|
+
# circumstances when run as background or subprocesses. Use this guard for
|
5
|
+
# such specs.
|
6
|
+
|
7
|
+
class BackgroundGuard < SpecGuard
|
8
|
+
def match?
|
9
|
+
MSpec.mode? :background
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Object
|
14
|
+
def process_is_foreground
|
15
|
+
g = BackgroundGuard.new
|
16
|
+
g.name = :process_is_foreground
|
17
|
+
yield if g.yield? true
|
18
|
+
ensure
|
19
|
+
g.unregister
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mspec/guards/version'
|
2
|
+
|
3
|
+
class BugGuard < VersionGuard
|
4
|
+
def initialize(bug, version)
|
5
|
+
@bug = bug
|
6
|
+
@version = SpecVersion.new version, true
|
7
|
+
self.parameters = [@bug, @version]
|
8
|
+
end
|
9
|
+
|
10
|
+
def match?
|
11
|
+
return false if MSpec.mode? :no_ruby_bug
|
12
|
+
standard? && ruby_version <= @version
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Object
|
17
|
+
def ruby_bug(bug, version)
|
18
|
+
g = BugGuard.new bug, version
|
19
|
+
g.name = :ruby_bug
|
20
|
+
yield if g.yield? true
|
21
|
+
ensure
|
22
|
+
g.unregister
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class CompliantOnGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
if @args.include? :ruby
|
6
|
+
raise Exception, "improper use of compliant_on guard"
|
7
|
+
end
|
8
|
+
standard? or implementation?(*@args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class NotCompliantOnGuard < SpecGuard
|
13
|
+
def match?
|
14
|
+
if @args.include? :ruby
|
15
|
+
raise Exception, "improper use of not_compliant_on guard"
|
16
|
+
end
|
17
|
+
standard? or !implementation?(*@args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Object
|
22
|
+
def compliant_on(*args)
|
23
|
+
g = CompliantOnGuard.new(*args)
|
24
|
+
g.name = :compliant_on
|
25
|
+
yield if g.yield?
|
26
|
+
ensure
|
27
|
+
g.unregister
|
28
|
+
end
|
29
|
+
|
30
|
+
def not_compliant_on(*args)
|
31
|
+
g = NotCompliantOnGuard.new(*args)
|
32
|
+
g.name = :not_compliant_on
|
33
|
+
yield if g.yield?
|
34
|
+
ensure
|
35
|
+
g.unregister
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class ConflictsGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
constants = Object.constants
|
6
|
+
@args.any? { |mod| constants.include? mod.to_s }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Object
|
11
|
+
def conflicts_with(*modules)
|
12
|
+
g = ConflictsGuard.new(*modules)
|
13
|
+
g.name = :conflicts_with
|
14
|
+
yield if g.yield? true
|
15
|
+
ensure
|
16
|
+
g.unregister
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
# Despite that these are inverses, the two classes are
|
4
|
+
# used to simplify MSpec guard reporting modes
|
5
|
+
|
6
|
+
class BigEndianGuard < SpecGuard
|
7
|
+
def pattern
|
8
|
+
[1].pack('L')
|
9
|
+
end
|
10
|
+
private :pattern
|
11
|
+
|
12
|
+
def match?
|
13
|
+
pattern[-1] == ?\001
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class LittleEndianGuard < SpecGuard
|
18
|
+
def pattern
|
19
|
+
[1].pack('L')
|
20
|
+
end
|
21
|
+
private :pattern
|
22
|
+
|
23
|
+
def match?
|
24
|
+
pattern[-1] == ?\000
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Object
|
29
|
+
def big_endian
|
30
|
+
g = BigEndianGuard.new
|
31
|
+
g.name = :big_endian
|
32
|
+
yield if g.yield?
|
33
|
+
ensure
|
34
|
+
g.unregister
|
35
|
+
end
|
36
|
+
|
37
|
+
def little_endian
|
38
|
+
g = LittleEndianGuard.new
|
39
|
+
g.name = :little_endian
|
40
|
+
yield if g.yield?
|
41
|
+
ensure
|
42
|
+
g.unregister
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class ExtensionsGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
if @args.include? :ruby
|
6
|
+
raise Exception, "improper use of extended_on guard"
|
7
|
+
end
|
8
|
+
!standard? and implementation?(*@args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Object
|
13
|
+
def extended_on(*args)
|
14
|
+
g = ExtensionsGuard.new(*args)
|
15
|
+
g.name = :extended_on
|
16
|
+
yield if g.yield?
|
17
|
+
ensure
|
18
|
+
g.unregister
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'mspec/runner/mspec'
|
2
|
+
require 'mspec/runner/actions/tally'
|
3
|
+
|
4
|
+
class SpecGuard
|
5
|
+
def self.report
|
6
|
+
@report ||= Hash.new { |h,k| h[k] = [] }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.clear
|
10
|
+
@report = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.finish
|
14
|
+
report.keys.sort.each do |key|
|
15
|
+
desc = report[key]
|
16
|
+
size = desc.size
|
17
|
+
spec = size == 1 ? "spec" : "specs"
|
18
|
+
print "\n\n#{size} #{spec} omitted by guard: #{key}:\n"
|
19
|
+
desc.each { |description| print "\n", description; }
|
20
|
+
end
|
21
|
+
|
22
|
+
print "\n\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.guards
|
26
|
+
@guards ||= []
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.clear_guards
|
30
|
+
@guards = []
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns a partial Ruby version string based on +which+. For example,
|
34
|
+
# if RUBY_VERSION = 8.2.3 and RUBY_PATCHLEVEL = 71:
|
35
|
+
#
|
36
|
+
# :major => "8"
|
37
|
+
# :minor => "8.2"
|
38
|
+
# :tiny => "8.2.3"
|
39
|
+
# :teeny => "8.2.3"
|
40
|
+
# :full => "8.2.3.71"
|
41
|
+
def self.ruby_version(which = :minor)
|
42
|
+
case which
|
43
|
+
when :major
|
44
|
+
n = 1
|
45
|
+
when :minor
|
46
|
+
n = 2
|
47
|
+
when :tiny, :teeny
|
48
|
+
n = 3
|
49
|
+
else
|
50
|
+
n = 4
|
51
|
+
end
|
52
|
+
|
53
|
+
patch = RUBY_PATCHLEVEL.to_i
|
54
|
+
patch = 0 if patch < 0
|
55
|
+
version = "#{RUBY_VERSION}.#{patch}"
|
56
|
+
version.split('.')[0,n].join('.')
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.windows?(key = RUBY_PLATFORM)
|
60
|
+
!!key.match(/(mswin|mingw)/)
|
61
|
+
end
|
62
|
+
|
63
|
+
attr_accessor :name, :parameters
|
64
|
+
|
65
|
+
def initialize(*args)
|
66
|
+
self.parameters = @args = args
|
67
|
+
end
|
68
|
+
|
69
|
+
def yield?(invert=false)
|
70
|
+
return true if MSpec.mode? :unguarded
|
71
|
+
|
72
|
+
allow = match? ^ invert
|
73
|
+
|
74
|
+
if not allow and reporting?
|
75
|
+
MSpec.guard
|
76
|
+
MSpec.register :finish, SpecGuard
|
77
|
+
MSpec.register :add, self
|
78
|
+
return true
|
79
|
+
elsif MSpec.mode? :verify
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
allow
|
84
|
+
end
|
85
|
+
|
86
|
+
def ===(other)
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def reporting?
|
91
|
+
MSpec.mode?(:report) or
|
92
|
+
(MSpec.mode?(:report_on) and SpecGuard.guards.include?(name))
|
93
|
+
end
|
94
|
+
|
95
|
+
def report_key
|
96
|
+
"#{name} #{parameters.join(", ")}"
|
97
|
+
end
|
98
|
+
|
99
|
+
def record(description)
|
100
|
+
SpecGuard.report[report_key] << description
|
101
|
+
end
|
102
|
+
|
103
|
+
def add(example)
|
104
|
+
record example.description
|
105
|
+
MSpec.retrieve(:formatter).tally.counter.guards!
|
106
|
+
end
|
107
|
+
|
108
|
+
def unregister
|
109
|
+
MSpec.unguard
|
110
|
+
MSpec.unregister :add, self
|
111
|
+
end
|
112
|
+
|
113
|
+
def implementation?(*args)
|
114
|
+
args.any? do |name|
|
115
|
+
!!case name
|
116
|
+
when :rubinius
|
117
|
+
RUBY_NAME =~ /^rbx/
|
118
|
+
when :ruby
|
119
|
+
RUBY_NAME =~ /^ruby/
|
120
|
+
when :jruby
|
121
|
+
RUBY_NAME =~ /^jruby/
|
122
|
+
when :ironruby
|
123
|
+
RUBY_NAME =~ /^ironruby/
|
124
|
+
when :macruby
|
125
|
+
RUBY_NAME =~ /^macruby/
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def standard?
|
133
|
+
implementation? :ruby
|
134
|
+
end
|
135
|
+
|
136
|
+
def windows?(sym, key)
|
137
|
+
sym == :windows && SpecGuard.windows?(key)
|
138
|
+
end
|
139
|
+
|
140
|
+
def platform?(*args)
|
141
|
+
args.any? do |platform|
|
142
|
+
if platform != :java && RUBY_PLATFORM.match('java') && os?(platform)
|
143
|
+
true
|
144
|
+
else
|
145
|
+
RUBY_PLATFORM.match(platform.to_s) || windows?(platform, RUBY_PLATFORM)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def wordsize?(size)
|
151
|
+
size == 8 * 1.size
|
152
|
+
end
|
153
|
+
|
154
|
+
def os?(*oses)
|
155
|
+
require 'rbconfig'
|
156
|
+
oses.any? do |os|
|
157
|
+
host_os = Config::CONFIG['host_os'] || RUBY_PLATFORM
|
158
|
+
host_os.downcase!
|
159
|
+
host_os.match(os.to_s) || windows?(os, host_os)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def match?
|
164
|
+
implementation?(*@args) or platform?(*@args)
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class NonComplianceGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
if @args.include? :ruby
|
6
|
+
raise Exception, "improper use of deviates_on guard"
|
7
|
+
end
|
8
|
+
!standard? and implementation?(*@args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Object
|
13
|
+
def deviates_on(*args)
|
14
|
+
g = NonComplianceGuard.new(*args)
|
15
|
+
g.name = :deviates_on
|
16
|
+
yield if g.yield?
|
17
|
+
ensure
|
18
|
+
g.unregister
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class PlatformGuard < SpecGuard
|
4
|
+
def initialize(*args)
|
5
|
+
if args.last.is_a?(Hash)
|
6
|
+
@options, @platforms = args.last, args[0..-2]
|
7
|
+
else
|
8
|
+
@options, @platforms = {}, args
|
9
|
+
end
|
10
|
+
self.parameters = args
|
11
|
+
end
|
12
|
+
|
13
|
+
def match?
|
14
|
+
match = @platforms.empty? ? true : platform?(*@platforms)
|
15
|
+
@options.each do |key, value|
|
16
|
+
case key
|
17
|
+
when :os
|
18
|
+
match &&= os?(*value)
|
19
|
+
when :wordsize
|
20
|
+
match &&= wordsize? value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
match
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Object
|
28
|
+
def platform_is(*args)
|
29
|
+
g = PlatformGuard.new(*args)
|
30
|
+
g.name = :platform_is
|
31
|
+
yield if g.yield?
|
32
|
+
ensure
|
33
|
+
g.unregister
|
34
|
+
end
|
35
|
+
|
36
|
+
def platform_is_not(*args)
|
37
|
+
g = PlatformGuard.new(*args)
|
38
|
+
g.name = :platform_is_not
|
39
|
+
yield if g.yield? true
|
40
|
+
ensure
|
41
|
+
g.unregister
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class QuarantineGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
false
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Object
|
10
|
+
def quarantine!
|
11
|
+
g = QuarantineGuard.new
|
12
|
+
g.name = :quarantine!
|
13
|
+
yield if g.yield?
|
14
|
+
ensure
|
15
|
+
g.unregister
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class RunnerGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
@args.any? do |runner|
|
6
|
+
case runner
|
7
|
+
when :mspec
|
8
|
+
ENV['MSPEC_RUNNER'] == '1'
|
9
|
+
when :rspec
|
10
|
+
ENV['RSPEC_RUNNER'] == '1' or Object.const_defined?(:Spec)
|
11
|
+
else
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Object
|
19
|
+
def runner_is(*args)
|
20
|
+
g = RunnerGuard.new(*args)
|
21
|
+
g.name = :runner_is
|
22
|
+
yield if g.yield?
|
23
|
+
ensure
|
24
|
+
g.unregister
|
25
|
+
end
|
26
|
+
|
27
|
+
def runner_is_not(*args)
|
28
|
+
g = RunnerGuard.new(*args)
|
29
|
+
g.name = :runner_is_not
|
30
|
+
yield if g.yield? true
|
31
|
+
ensure
|
32
|
+
g.unregister
|
33
|
+
end
|
34
|
+
end
|