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,17 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class SuperUserGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
Process.euid == 0
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Object
|
10
|
+
def as_superuser
|
11
|
+
g = SuperUserGuard.new
|
12
|
+
g.name = :as_superuser
|
13
|
+
yield if g.yield?
|
14
|
+
ensure
|
15
|
+
g.unregister
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class SupportedGuard < SpecGuard
|
4
|
+
def match?
|
5
|
+
if @args.include? :ruby
|
6
|
+
raise Exception, "improper use of not_supported_on guard"
|
7
|
+
end
|
8
|
+
standard? or !implementation?(*@args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Object
|
13
|
+
def not_supported_on(*args)
|
14
|
+
g = SupportedGuard.new(*args)
|
15
|
+
g.name = :not_supported_on
|
16
|
+
yield if g.yield?
|
17
|
+
ensure
|
18
|
+
g.unregister
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
# If a spec depends on STDOUT being a tty, use this guard. For specs that may
|
4
|
+
# block if run as a background process, see BackgroundGuard.
|
5
|
+
|
6
|
+
class TTYGuard < SpecGuard
|
7
|
+
def match?
|
8
|
+
STDOUT.tty?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Object
|
13
|
+
def with_tty
|
14
|
+
g = TTYGuard.new
|
15
|
+
g.name = :with_tty
|
16
|
+
yield if g.yield?
|
17
|
+
ensure
|
18
|
+
g.unregister
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'mspec/utils/version'
|
2
|
+
require 'mspec/guards/guard'
|
3
|
+
|
4
|
+
class VersionGuard < SpecGuard
|
5
|
+
def initialize(version)
|
6
|
+
case version
|
7
|
+
when String
|
8
|
+
@version = SpecVersion.new version
|
9
|
+
when Range
|
10
|
+
a = SpecVersion.new version.first
|
11
|
+
b = SpecVersion.new version.last
|
12
|
+
@version = version.exclude_end? ? a...b : a..b
|
13
|
+
end
|
14
|
+
self.parameters = [version]
|
15
|
+
end
|
16
|
+
|
17
|
+
def ruby_version
|
18
|
+
@ruby_version ||= SpecVersion.new self.class.ruby_version(:full)
|
19
|
+
end
|
20
|
+
|
21
|
+
def match?
|
22
|
+
if Range === @version
|
23
|
+
@version.include? ruby_version
|
24
|
+
else
|
25
|
+
ruby_version >= @version
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Object
|
31
|
+
def ruby_version_is(*args)
|
32
|
+
g = VersionGuard.new(*args)
|
33
|
+
g.name = :ruby_version_is
|
34
|
+
yield if g.yield?
|
35
|
+
ensure
|
36
|
+
g.unregister
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'mspec/helpers/argv'
|
2
|
+
require 'mspec/helpers/bignum'
|
3
|
+
require 'mspec/helpers/const_lookup'
|
4
|
+
require 'mspec/helpers/environment'
|
5
|
+
require 'mspec/helpers/fixture'
|
6
|
+
require 'mspec/helpers/flunk'
|
7
|
+
require 'mspec/helpers/io'
|
8
|
+
require 'mspec/helpers/language_version'
|
9
|
+
require 'mspec/helpers/ruby_exe'
|
10
|
+
require 'mspec/helpers/scratch'
|
11
|
+
require 'mspec/helpers/tmp'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Object
|
2
|
+
# Convenience helper for altering ARGV. Saves the
|
3
|
+
# value of ARGV and sets it to +args+. If a block
|
4
|
+
# is given, yields to the block and then restores
|
5
|
+
# the value of ARGV. The previously saved value of
|
6
|
+
# ARGV can be restored by passing +:restore+. The
|
7
|
+
# former is useful in a single spec. The latter is
|
8
|
+
# useful in before/after actions. For example:
|
9
|
+
#
|
10
|
+
# describe "This" do
|
11
|
+
# before do
|
12
|
+
# argv ['a', 'b']
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# after do
|
16
|
+
# argv :restore
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# it "does something" do
|
20
|
+
# # do something
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# describe "That" do
|
25
|
+
# it "does something" do
|
26
|
+
# argv ['a', 'b'] do
|
27
|
+
# # do something
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
def argv(args)
|
32
|
+
if args == :restore
|
33
|
+
ARGV.replace(@__mspec_saved_argv__ || [])
|
34
|
+
else
|
35
|
+
@__mspec_saved_argv__ = ARGV
|
36
|
+
ARGV.replace args
|
37
|
+
if block_given?
|
38
|
+
yield
|
39
|
+
argv :restore
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class Object
|
4
|
+
def env
|
5
|
+
env = ""
|
6
|
+
if SpecGuard.windows?
|
7
|
+
env = Hash[*`cmd.exe /C set`.split("\n").map { |e| e.split("=", 2) }.flatten]
|
8
|
+
else
|
9
|
+
env = Hash[*`env`.split("\n").map { |e| e.split("=", 2) }.flatten]
|
10
|
+
end
|
11
|
+
env
|
12
|
+
end
|
13
|
+
|
14
|
+
def username
|
15
|
+
user = ""
|
16
|
+
if SpecGuard.windows?
|
17
|
+
user = `cmd.exe /C ECHO %USERNAME%`.strip
|
18
|
+
else
|
19
|
+
user = `whoami`.strip
|
20
|
+
end
|
21
|
+
user
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Object
|
2
|
+
# Returns the name of a fixture file by adjoining the directory
|
3
|
+
# of the +dir+ argument with "fixtures" and the contents of the
|
4
|
+
# +args+ array. For example,
|
5
|
+
#
|
6
|
+
# +dir+ == "some/path"
|
7
|
+
#
|
8
|
+
# and
|
9
|
+
#
|
10
|
+
# +args+ == ["dir", "file.txt"]
|
11
|
+
#
|
12
|
+
# then the result is the expanded path of
|
13
|
+
#
|
14
|
+
# "some/fixtures/dir/file.txt".
|
15
|
+
def fixture(dir, *args)
|
16
|
+
path = File.dirname(dir)
|
17
|
+
path = path[0..-7] if path[-7..-1] == "/shared"
|
18
|
+
File.expand_path(File.join(path, "fixtures", args))
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class IOStub < String
|
2
|
+
def write(*str)
|
3
|
+
self << str.to_s
|
4
|
+
end
|
5
|
+
|
6
|
+
def print(*str)
|
7
|
+
write(str.to_s + $\.to_s)
|
8
|
+
end
|
9
|
+
|
10
|
+
def puts(*str)
|
11
|
+
write(str.collect { |s| s.to_s.chomp }.concat([nil]).join("\n"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def flush
|
15
|
+
self
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mspec/guards/guard'
|
2
|
+
|
3
|
+
class Object
|
4
|
+
# Helper for syntax-sensitive specs. The specs should be placed in a file in
|
5
|
+
# the +versions+ subdirectory. For example, suppose language/method_spec.rb
|
6
|
+
# contains specs whose syntax depends on the Ruby version. In the
|
7
|
+
# language/method_spec.rb use the helper as follows:
|
8
|
+
#
|
9
|
+
# language_version __FILE__, "method"
|
10
|
+
#
|
11
|
+
# Then add a file "language/versions/method_1.8.rb" for the specs that are
|
12
|
+
# syntax-compatible with Ruby 1.8.x.
|
13
|
+
def language_version(dir, name)
|
14
|
+
path = File.dirname(File.expand_path(dir))
|
15
|
+
name = "#{name}_#{SpecGuard.ruby_version}.rb"
|
16
|
+
file = File.join path, "versions", name
|
17
|
+
|
18
|
+
require file if File.exists? file
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# require 'mspec/utils/ruby_name'
|
2
|
+
# require 'mspec/guards/guard'
|
3
|
+
#
|
4
|
+
# # The ruby_exe helper provides a wrapper for invoking the
|
5
|
+
# # same Ruby interpreter as the one running the specs and
|
6
|
+
# # getting the output from running the code. If +code+ is a
|
7
|
+
# # file that exists, it will be run. Otherwise, +code+ should
|
8
|
+
# # be Ruby code that will be run with the -e command line
|
9
|
+
# # option. For example:
|
10
|
+
# #
|
11
|
+
# # ruby_exe('path/to/some/file.rb')
|
12
|
+
# #
|
13
|
+
# # will be executed as
|
14
|
+
# #
|
15
|
+
# # `#{RUBY_EXE} #{'path/to/some/file.rb'}`
|
16
|
+
# #
|
17
|
+
# # while
|
18
|
+
# #
|
19
|
+
# # ruby_exe('puts "hello, world."')
|
20
|
+
# #
|
21
|
+
# # will be executed as
|
22
|
+
# #
|
23
|
+
# # `#{RUBY_EXE} -e #{'puts "hello, world."'}`
|
24
|
+
# #
|
25
|
+
# # The ruby_exe helper also accepts an options hash with two
|
26
|
+
# # keys: :options and :args. For example:
|
27
|
+
# #
|
28
|
+
# # ruby_exe('file.rb', :options => "-w", :args => "> file.txt")
|
29
|
+
# #
|
30
|
+
# # will be executed as
|
31
|
+
# #
|
32
|
+
# # `#{RUBY_EXE} -w #{'file.rb'} > file.txt`
|
33
|
+
# #
|
34
|
+
# # If +nil+ is passed for the first argument, the command line
|
35
|
+
# # will be built only from the options hash.
|
36
|
+
# #
|
37
|
+
# # The RUBY_EXE constant can be set explicitly since the value
|
38
|
+
# # is used each time ruby_exe is invoked. The mspec runner script
|
39
|
+
# # will set ENV['RUBY_EXE'] to the name of the executable used
|
40
|
+
# # to invoke the mspec-run script. The value of RUBY_EXE will be
|
41
|
+
# # constructed as follows:
|
42
|
+
# #
|
43
|
+
# # 1. the value of ENV['RUBY_EXE']
|
44
|
+
# # 2. an explicit value based on RUBY_NAME
|
45
|
+
# # 3. cwd/(RUBY_NAME + $(EXEEXT) || $(exeext) || '')
|
46
|
+
# # 4. $(bindir)/$(RUBY_INSTALL_NAME)
|
47
|
+
# #
|
48
|
+
# # The value will only be used if the file exists and is executable.
|
49
|
+
# #
|
50
|
+
# # These 4 ways correspond to the following scenarios:
|
51
|
+
# #
|
52
|
+
# # 1. Using the MSpec runner scripts, the name of the
|
53
|
+
# # executable is explicitly passed by ENV['RUBY_EXE']
|
54
|
+
# # so there is no ambiguity.
|
55
|
+
# #
|
56
|
+
# # Otherwise, if using RSpec (or something else)
|
57
|
+
# #
|
58
|
+
# # 2. Running the specs while developing an alternative
|
59
|
+
# # Ruby implementation. This explicitly names the
|
60
|
+
# # executable in the development directory based on
|
61
|
+
# # the value of RUBY_NAME, which is probably initialized
|
62
|
+
# # from the value of RUBY_ENGINE.
|
63
|
+
# # 3. Running the specs within the source directory for
|
64
|
+
# # some implementation. (E.g. a local build directory.)
|
65
|
+
# # 4. Running the specs against some installed Ruby
|
66
|
+
# # implementation.
|
67
|
+
#
|
68
|
+
# class Object
|
69
|
+
# def ruby_exe_options(option)
|
70
|
+
# case option
|
71
|
+
# when :env
|
72
|
+
# ENV['RUBY_EXE']
|
73
|
+
# when :engine
|
74
|
+
# case RUBY_NAME
|
75
|
+
# when 'rbx'
|
76
|
+
# "bin/rbx"
|
77
|
+
# when 'jruby'
|
78
|
+
# "bin/jruby"
|
79
|
+
# when 'ironruby'
|
80
|
+
# "ir"
|
81
|
+
# end
|
82
|
+
# when :name
|
83
|
+
# bin = RUBY_NAME + (Config::CONFIG['EXEEXT'] || Config::CONFIG['exeext'] || '')
|
84
|
+
# File.join(".", bin)
|
85
|
+
# when :install_name
|
86
|
+
# bin = Config::CONFIG["RUBY_INSTALL_NAME"] || Config::CONFIG["ruby_install_name"]
|
87
|
+
# bin << (Config::CONFIG['EXEEXT'] || Config::CONFIG['exeext'] || '')
|
88
|
+
# File.join(Config::CONFIG['bindir'], bin)
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# def resolve_ruby_exe
|
93
|
+
# [:env, :engine, :name, :install_name].each do |option|
|
94
|
+
# next unless cmd = ruby_exe_options(option)
|
95
|
+
# exe = cmd.split.first
|
96
|
+
#
|
97
|
+
# # It has been reported that File.executable is not reliable
|
98
|
+
# # on Windows platforms (see commit 56bc555c). So, we check the
|
99
|
+
# # platform.
|
100
|
+
# if File.exists?(exe) and (SpecGuard.windows? or File.executable?(exe))
|
101
|
+
# return cmd
|
102
|
+
# end
|
103
|
+
# end
|
104
|
+
# nil
|
105
|
+
# end
|
106
|
+
#
|
107
|
+
# def ruby_exe(code, opts = {})
|
108
|
+
# body = code
|
109
|
+
# working_dir = opts[:dir] || "."
|
110
|
+
# Dir.chdir(working_dir) do
|
111
|
+
# body = "-e #{code.inspect}" if code and not File.exists?(code)
|
112
|
+
# cmd = [RUBY_EXE, ENV['RUBY_FLAGS'], opts[:options], body, opts[:args]]
|
113
|
+
# `#{cmd.compact.join(' ')}`
|
114
|
+
# end
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
|
118
|
+
# require 'rbconfig'
|
119
|
+
#
|
120
|
+
# RUBY_EXE = resolve_ruby_exe or
|
121
|
+
# raise Exception, "Unable to find a suitable ruby executable."
|
122
|
+
# end
|
123
|
+
# end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# The #tmp method provides a similar functionality
|
2
|
+
# to that of Dir.tmpdir. This helper can be overridden
|
3
|
+
# by different implementations to provide a more useful
|
4
|
+
# behavior if needed.
|
5
|
+
#
|
6
|
+
# Usage in a spec:
|
7
|
+
#
|
8
|
+
# File.open(tmp("tags.txt"), "w") { |f| f.puts "" }
|
9
|
+
#
|
10
|
+
# The order of directories below with "/private/tmp"
|
11
|
+
# preceding "/tmp" is significant. On OS X, the directory
|
12
|
+
# "/tmp" is a symlink to "private/tmp" with no leading
|
13
|
+
# "/". Rather than futzing with what constitutes an
|
14
|
+
# absolute path, we just look for "/private/tmp" first.
|
15
|
+
|
16
|
+
class Object
|
17
|
+
def tmp(name)
|
18
|
+
unless @spec_temp_directory
|
19
|
+
[ "/private/tmp", "/tmp", "/var/tmp", ENV["TMPDIR"], ENV["TMP"],
|
20
|
+
ENV["TEMP"], ENV["USERPROFILE"] ].each do |dir|
|
21
|
+
if dir and File.directory?(dir) and File.writable?(dir)
|
22
|
+
temp = File.expand_path dir
|
23
|
+
temp = File.readlink temp if File.symlink? temp
|
24
|
+
@spec_temp_directory = temp
|
25
|
+
break
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
File.join @spec_temp_directory, name
|
31
|
+
end
|
32
|
+
end
|