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.
Files changed (198) hide show
  1. data/Manifest.txt +159 -30
  2. data/Rakefile +3 -19
  3. data/lib/erb.rb +1 -1
  4. data/lib/rho/rho.rb +94 -107
  5. data/lib/rho/rhofsconnector.rb +4 -0
  6. data/lib/rho/rhoutils.rb +26 -0
  7. data/lib/rho/rhoviewhelpers.rb +1 -1
  8. data/lib/rhodes.rb +2 -2
  9. data/lib/rhoframework.rb +9 -9
  10. data/lib/rhom/rhom.rb +1 -1
  11. data/lib/rhom/rhom_db_adapter.rb +36 -15
  12. data/lib/rhom/rhom_db_adapterME.rb +2 -3
  13. data/lib/rhom/rhom_object.rb +14 -2
  14. data/lib/rhom/rhom_object_factory.rb +42 -11
  15. data/lib/version.rb +2 -2
  16. data/spec/README +1 -0
  17. data/spec/Rakefile +1 -0
  18. data/spec/{configs/account.rb → app/Account/config.rb} +0 -0
  19. data/spec/{configs/case.rb → app/Case/config.rb} +0 -0
  20. data/spec/app/Question/config.rb +3 -0
  21. data/spec/app/Settings/controller.rb +10 -0
  22. data/spec/app/Settings/index.erb +11 -0
  23. data/spec/app/SpecRunner/controller.rb +15 -0
  24. data/spec/app/SpecRunner/index.erb +14 -0
  25. data/spec/app/application.rb +4 -0
  26. data/spec/app/index.erb +17 -0
  27. data/spec/app/layout.erb +27 -0
  28. data/spec/app/loading.html +11 -0
  29. data/spec/app/mspec.rb +11 -0
  30. data/spec/app/mspec/expectations.rb +2 -0
  31. data/spec/app/mspec/expectations/expectations.rb +17 -0
  32. data/spec/app/mspec/expectations/should.rb +25 -0
  33. data/spec/app/mspec/fileutils.rb +1590 -0
  34. data/spec/app/mspec/guards.rb +16 -0
  35. data/spec/app/mspec/guards/background.rb +21 -0
  36. data/spec/app/mspec/guards/bug.rb +24 -0
  37. data/spec/app/mspec/guards/compliance.rb +37 -0
  38. data/spec/app/mspec/guards/conflict.rb +18 -0
  39. data/spec/app/mspec/guards/endian.rb +44 -0
  40. data/spec/app/mspec/guards/extensions.rb +20 -0
  41. data/spec/app/mspec/guards/guard.rb +166 -0
  42. data/spec/app/mspec/guards/noncompliance.rb +20 -0
  43. data/spec/app/mspec/guards/platform.rb +43 -0
  44. data/spec/app/mspec/guards/quarantine.rb +17 -0
  45. data/spec/app/mspec/guards/runner.rb +34 -0
  46. data/spec/app/mspec/guards/superuser.rb +17 -0
  47. data/spec/app/mspec/guards/support.rb +20 -0
  48. data/spec/app/mspec/guards/tty.rb +20 -0
  49. data/spec/app/mspec/guards/version.rb +38 -0
  50. data/spec/app/mspec/helpers.rb +11 -0
  51. data/spec/app/mspec/helpers/argv.rb +43 -0
  52. data/spec/app/mspec/helpers/bignum.rb +5 -0
  53. data/spec/app/mspec/helpers/const_lookup.rb +9 -0
  54. data/spec/app/mspec/helpers/environment.rb +23 -0
  55. data/spec/app/mspec/helpers/fixture.rb +20 -0
  56. data/spec/app/mspec/helpers/flunk.rb +5 -0
  57. data/spec/app/mspec/helpers/io.rb +17 -0
  58. data/spec/app/mspec/helpers/language_version.rb +20 -0
  59. data/spec/app/mspec/helpers/ruby_exe.rb +123 -0
  60. data/spec/app/mspec/helpers/scratch.rb +17 -0
  61. data/spec/app/mspec/helpers/tmp.rb +32 -0
  62. data/spec/app/mspec/matchers.rb +23 -0
  63. data/spec/app/mspec/matchers/base.rb +95 -0
  64. data/spec/app/mspec/matchers/be_an_instance_of.rb +26 -0
  65. data/spec/app/mspec/matchers/be_ancestor_of.rb +24 -0
  66. data/spec/app/mspec/matchers/be_close.rb +27 -0
  67. data/spec/app/mspec/matchers/be_empty.rb +20 -0
  68. data/spec/app/mspec/matchers/be_false.rb +20 -0
  69. data/spec/app/mspec/matchers/be_kind_of.rb +24 -0
  70. data/spec/app/mspec/matchers/be_nil.rb +20 -0
  71. data/spec/app/mspec/matchers/be_true.rb +20 -0
  72. data/spec/app/mspec/matchers/complain.rb +56 -0
  73. data/spec/app/mspec/matchers/eql.rb +26 -0
  74. data/spec/app/mspec/matchers/equal.rb +26 -0
  75. data/spec/app/mspec/matchers/equal_element.rb +78 -0
  76. data/spec/app/mspec/matchers/equal_utf16.rb +34 -0
  77. data/spec/app/mspec/matchers/have_constant.rb +30 -0
  78. data/spec/app/mspec/matchers/have_instance_method.rb +24 -0
  79. data/spec/app/mspec/matchers/have_method.rb +24 -0
  80. data/spec/app/mspec/matchers/have_private_instance_method.rb +24 -0
  81. data/spec/app/mspec/matchers/include.rb +32 -0
  82. data/spec/app/mspec/matchers/match_yaml.rb +47 -0
  83. data/spec/app/mspec/matchers/method.rb +14 -0
  84. data/spec/app/mspec/matchers/output.rb +67 -0
  85. data/spec/app/mspec/matchers/output_to_fd.rb +71 -0
  86. data/spec/app/mspec/matchers/raise_error.rb +48 -0
  87. data/spec/app/mspec/matchers/respond_to.rb +24 -0
  88. data/spec/app/mspec/matchers/stringsymboladapter.rb +8 -0
  89. data/spec/app/mspec/mocks.rb +3 -0
  90. data/spec/app/mspec/mocks/mock.rb +159 -0
  91. data/spec/app/mspec/mocks/object.rb +20 -0
  92. data/spec/app/mspec/mocks/proxy.rb +136 -0
  93. data/spec/app/mspec/pp.rb +893 -0
  94. data/spec/app/mspec/runner.rb +15 -0
  95. data/spec/app/mspec/runner/actions.rb +8 -0
  96. data/spec/app/mspec/runner/actions/debug.rb +17 -0
  97. data/spec/app/mspec/runner/actions/filter.rb +40 -0
  98. data/spec/app/mspec/runner/actions/gdb.rb +17 -0
  99. data/spec/app/mspec/runner/actions/tag.rb +133 -0
  100. data/spec/app/mspec/runner/actions/taglist.rb +56 -0
  101. data/spec/app/mspec/runner/actions/tagpurge.rb +56 -0
  102. data/spec/app/mspec/runner/actions/tally.rb +116 -0
  103. data/spec/app/mspec/runner/actions/timer.rb +22 -0
  104. data/spec/app/mspec/runner/context.rb +188 -0
  105. data/spec/app/mspec/runner/example.rb +34 -0
  106. data/spec/app/mspec/runner/exception.rb +43 -0
  107. data/spec/app/mspec/runner/filters.rb +4 -0
  108. data/spec/app/mspec/runner/filters/match.rb +22 -0
  109. data/spec/app/mspec/runner/filters/profile.rb +54 -0
  110. data/spec/app/mspec/runner/filters/regexp.rb +7 -0
  111. data/spec/app/mspec/runner/filters/tag.rb +29 -0
  112. data/spec/app/mspec/runner/formatters.rb +10 -0
  113. data/spec/app/mspec/runner/formatters/describe.rb +24 -0
  114. data/spec/app/mspec/runner/formatters/dotted.rb +98 -0
  115. data/spec/app/mspec/runner/formatters/file.rb +19 -0
  116. data/spec/app/mspec/runner/formatters/html.rb +81 -0
  117. data/spec/app/mspec/runner/formatters/method.rb +93 -0
  118. data/spec/app/mspec/runner/formatters/specdoc.rb +41 -0
  119. data/spec/app/mspec/runner/formatters/spinner.rb +99 -0
  120. data/spec/app/mspec/runner/formatters/summary.rb +11 -0
  121. data/spec/app/mspec/runner/formatters/unit.rb +21 -0
  122. data/spec/app/mspec/runner/formatters/yaml.rb +44 -0
  123. data/spec/app/mspec/runner/mspec.rb +361 -0
  124. data/spec/app/mspec/runner/object.rb +24 -0
  125. data/spec/app/mspec/runner/shared.rb +12 -0
  126. data/spec/app/mspec/runner/tag.rb +32 -0
  127. data/spec/app/mspec/utils/name_map.rb +129 -0
  128. data/spec/app/mspec/utils/options.rb +441 -0
  129. data/spec/app/mspec/utils/ruby_name.rb +8 -0
  130. data/spec/app/mspec/utils/script.rb +220 -0
  131. data/spec/app/mspec/utils/version.rb +53 -0
  132. data/spec/app/mspec/version.rb +5 -0
  133. data/spec/app/spec/fixtures/client_info.txt +2 -0
  134. data/spec/app/spec/fixtures/object_values.txt +90 -0
  135. data/spec/{rho_controller_spec.rb → app/spec/rho_controller_spec.rb} +4 -7
  136. data/spec/{rho_spec.rb → app/spec/rho_spec.rb} +15 -36
  137. data/spec/{rhom_object_factory_spec.rb → app/spec/rhom_object_factory_spec.rb} +108 -72
  138. data/spec/{rhom_spec.rb → app/spec/rhom_spec.rb} +8 -4
  139. data/spec/app/spec/spec_helper.rb +15 -0
  140. data/spec/app/spec/webview_spec.rb +27 -0
  141. data/spec/app/spec_runner.rb +26 -0
  142. data/spec/build.yml +28 -0
  143. data/spec/public/css/base.css +39 -0
  144. data/spec/public/css/blackberry.css +99 -0
  145. data/spec/public/css/iphone.css +392 -0
  146. data/spec/public/css/rho.css +3 -0
  147. data/spec/public/css/xhtml.css +114 -0
  148. data/spec/public/images/IUI_LICENSE.txt +21 -0
  149. data/spec/public/images/backButton.png +0 -0
  150. data/spec/public/images/blueButton.png +0 -0
  151. data/spec/public/images/cancel.png +0 -0
  152. data/spec/public/images/grayButton.png +0 -0
  153. data/spec/public/images/iui-logo-touch-icon.png +0 -0
  154. data/spec/public/images/listArrow.png +0 -0
  155. data/spec/public/images/listArrowSel.png +0 -0
  156. data/spec/public/images/listGroup.png +0 -0
  157. data/spec/public/images/loading.gif +0 -0
  158. data/spec/public/images/pinstripes.png +0 -0
  159. data/spec/public/images/right_button.png +0 -0
  160. data/spec/public/images/selection.png +0 -0
  161. data/spec/public/images/thumb.png +0 -0
  162. data/spec/public/images/toggle.png +0 -0
  163. data/spec/public/images/toggleOn.png +0 -0
  164. data/spec/public/images/toolButton.png +0 -0
  165. data/spec/public/images/toolButton_new.png +0 -0
  166. data/spec/public/images/toolbar.png +0 -0
  167. data/spec/public/images/whiteButton.png +0 -0
  168. data/spec/public/js/application.js +1 -0
  169. data/spec/public/js/jquery-1.2.6.min.js +32 -0
  170. data/spec/public/js/rho.js +4 -0
  171. data/spec/public/js/rhogeolocation-wm.js +59 -0
  172. data/spec/public/js/rhogeolocation.js +11 -0
  173. data/spec/rhoconfig.txt +19 -0
  174. metadata +169 -39
  175. data/History.txt +0 -37
  176. data/README.rdoc +0 -2
  177. data/lib/TestServe.rb +0 -9
  178. data/res/sqlite3/constants.rb +0 -49
  179. data/res/sqlite3/database.rb +0 -715
  180. data/res/sqlite3/driver/dl/api.rb +0 -154
  181. data/res/sqlite3/driver/dl/driver.rb +0 -307
  182. data/res/sqlite3/driver/native/driver.rb +0 -257
  183. data/res/sqlite3/errors.rb +0 -68
  184. data/res/sqlite3/pragmas.rb +0 -271
  185. data/res/sqlite3/resultset.rb +0 -176
  186. data/res/sqlite3/sqlite3_api.rb +0 -0
  187. data/res/sqlite3/statement.rb +0 -230
  188. data/res/sqlite3/translator.rb +0 -109
  189. data/res/sqlite3/value.rb +0 -57
  190. data/res/sqlite3/version.rb +0 -14
  191. data/rhodes.gemspec +0 -18
  192. data/spec/app_manifest.txt +0 -4
  193. data/spec/configs/contact.rb +0 -3
  194. data/spec/configs/employee.rb +0 -3
  195. data/spec/spec.opts +0 -1
  196. data/spec/spec_helper.rb +0 -49
  197. data/spec/stubs.rb +0 -39
  198. 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,5 @@
1
+ class Object
2
+ def bignum_value(plus=0)
3
+ 0x8000_0000_0000_0000 + plus
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module Kernel
2
+ def const_lookup(c)
3
+ names = c.split '::'
4
+ names.shift if names.first.empty?
5
+ names.inject(Object) do |m, n|
6
+ m.const_defined?(n) ? m.const_get(n) : m.const_missing(n)
7
+ end
8
+ end
9
+ 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,5 @@
1
+ class Object
2
+ def flunk(msg="This example is a failure")
3
+ Expectation.fail_with "Failed:", msg
4
+ end
5
+ 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,17 @@
1
+ module ScratchPad
2
+ def self.clear
3
+ @record = nil
4
+ end
5
+
6
+ def self.record(arg)
7
+ @record = arg
8
+ end
9
+
10
+ def self.<<(arg)
11
+ @record << arg
12
+ end
13
+
14
+ def self.recorded
15
+ @record
16
+ end
17
+ 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