rhodes 2.2.4.beta.1 → 2.2.5.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/CHANGELOG +10 -0
  2. data/Rakefile +119 -3
  3. data/lib/build/jake.rb +15 -1
  4. data/lib/framework/dateME.rb +6 -1
  5. data/lib/framework/rho/render.rb +18 -15
  6. data/lib/framework/rho/rho.rb +105 -43
  7. data/lib/framework/rho/rhoapplication.rb +1 -1
  8. data/lib/framework/rho/rhocontact.rb +41 -13
  9. data/lib/framework/rho/rhocontroller.rb +10 -1
  10. data/lib/framework/rho/rhoevent_c.rb +6 -1
  11. data/lib/framework/rho/rhosupport.rb +1 -1
  12. data/lib/framework/rhodes.rb +1 -1
  13. data/lib/framework/rholang/rhomsg_de.rb +1 -1
  14. data/lib/framework/rholang/rhomsg_es.rb +1 -1
  15. data/lib/framework/rholang/rhomsg_it.rb +28 -0
  16. data/lib/framework/rhom/rhom.rb +6 -0
  17. data/lib/framework/rhom/rhom_model.rb +14 -7
  18. data/lib/framework/rhom/rhom_object_factory.rb +121 -56
  19. data/lib/framework/version.rb +1 -1
  20. data/lib/rhodes.rb +1 -1
  21. data/platform/android/Rhodes/AndroidManifest.full.xml +62 -0
  22. data/platform/android/Rhodes/AndroidManifest.xml +3 -34
  23. data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +17 -2
  24. data/platform/android/Rhodes/jni/src/alert.cpp +16 -0
  25. data/platform/android/Rhodes/jni/src/callbacks.cpp +27 -3
  26. data/platform/android/Rhodes/jni/src/nativebar.cpp +3 -0
  27. data/platform/android/Rhodes/jni/src/nativeview.cpp +131 -1
  28. data/platform/android/Rhodes/jni/src/phonebook.cpp +102 -41
  29. data/platform/android/Rhodes/jni/src/rhodes.cpp +113 -32
  30. data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
  31. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +1 -0
  32. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +9 -8
  33. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +184 -49
  34. data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +49 -25
  35. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +104 -57
  36. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +36 -2
  37. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +24 -14
  38. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +7 -8
  39. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +185 -3
  40. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +54 -1
  41. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +107 -14
  42. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +72 -24
  43. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +22 -21
  44. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +91 -11
  45. data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +10 -0
  46. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +11 -0
  47. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +10 -0
  48. data/platform/android/build/android.rake +50 -9
  49. data/platform/android/build/librhocommon_build.files +1 -0
  50. data/platform/bb/Hsqldb/src/org/hsqldb/Parser.java +3 -2
  51. data/platform/bb/Hsqldb/src/org/hsqldb/SchemaManager.java +3 -1
  52. data/platform/bb/Hsqldb/src/org/hsqldb/Session.java +7 -0
  53. data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +2 -2
  54. data/platform/bb/RubyVM/RubyVM.jdp +1 -0
  55. data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +22 -0
  56. data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +5 -0
  57. data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +1 -1
  58. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +51 -4
  59. data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +21 -10
  60. data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +82 -33
  61. data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +59 -6
  62. data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyFloat_Methods.java +5 -0
  63. data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +19 -7
  64. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/ArrayPacker.java +1 -1
  65. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFloat.java +5 -0
  66. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +55 -11
  67. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +18 -2
  68. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +8 -5
  69. data/platform/bb/RubyVM/src/j2me/lang/CharacterMe.java +1 -1
  70. data/platform/bb/RubyVM/src/j2me/util/StringParser.java +2 -0
  71. data/platform/bb/build/RubyVM_build.files +1 -0
  72. data/platform/bb/build/bb.rake +21 -2
  73. data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +3 -3
  74. data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +1 -1
  75. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +1 -2
  76. data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +15 -16
  77. data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +4 -0
  78. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +58 -0
  79. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +90 -4
  80. data/platform/iphone/Classes/AppManager/AppManager.m +43 -5
  81. data/platform/iphone/Classes/Event/Event.h +2 -0
  82. data/platform/iphone/Classes/Event/Event.m +12 -1
  83. data/platform/iphone/Classes/GeoLocation/LocationController.m +9 -3
  84. data/platform/iphone/Classes/MapView/MapViewController.m +20 -9
  85. data/platform/iphone/Classes/NativeBar.m +27 -0
  86. data/platform/iphone/Classes/Phonebook/phonebook.m +17 -0
  87. data/platform/iphone/Classes/RhoAlert.m +61 -1
  88. data/platform/iphone/Classes/RhoMainView.h +1 -0
  89. data/platform/iphone/Classes/Rhodes.h +2 -0
  90. data/platform/iphone/Classes/Rhodes.m +108 -1
  91. data/platform/iphone/Classes/SimpleMainView.h +4 -0
  92. data/platform/iphone/Classes/SimpleMainView.m +30 -3
  93. data/platform/iphone/Classes/SplashViewController.m +3 -1
  94. data/platform/iphone/Classes/TabbedMainView.h +2 -0
  95. data/platform/iphone/Classes/TabbedMainView.m +63 -11
  96. data/platform/iphone/Classes/rho/net/NetRequestImpl.m +26 -0
  97. data/platform/iphone/Info.plist +12 -1
  98. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +8 -0
  99. data/platform/iphone/rbuild/iphone.rake +181 -25
  100. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +5 -5
  101. data/platform/shared/common/IRhoThreadImpl.h +1 -1
  102. data/platform/shared/common/PosixThreadImpl.cpp +5 -3
  103. data/platform/shared/common/PosixThreadImpl.h +1 -1
  104. data/platform/shared/common/RhoFilePath.h +11 -0
  105. data/platform/shared/common/RhoNativeViewManager.h +17 -0
  106. data/platform/shared/common/RhoThread.h +1 -1
  107. data/platform/shared/common/RhodesApp.cpp +29 -8
  108. data/platform/shared/common/ThreadQueue.cpp +5 -3
  109. data/platform/shared/common/ThreadQueue.h +2 -1
  110. data/platform/shared/common/app_build_configs.c +25 -0
  111. data/platform/shared/common/app_build_configs.h +11 -0
  112. data/platform/shared/net/AsyncHttp.cpp +5 -5
  113. data/platform/shared/net/CURLNetRequest.cpp +25 -7
  114. data/platform/shared/net/CURLNetRequest.h +2 -1
  115. data/platform/shared/net/HttpServer.cpp +28 -0
  116. data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
  117. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +26 -1
  118. data/platform/shared/ruby/ext/rho/rhoruby.c +6 -0
  119. data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
  120. data/platform/shared/ruby/ext/rho/rhosupport.c +15 -2
  121. data/platform/shared/ruby/ext/syncengine/syncengine.i +14 -2
  122. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +97 -2
  123. data/platform/shared/ruby/ext/system/system.i +13 -0
  124. data/platform/shared/ruby/ext/system/system_wrap.c +104 -1
  125. data/platform/shared/rubyext/RhoAppAdapter.cpp +7 -0
  126. data/platform/shared/sync/SyncEngine.cpp +43 -3
  127. data/platform/shared/sync/SyncEngine.h +13 -0
  128. data/platform/shared/sync/SyncNotify.cpp +41 -23
  129. data/platform/shared/sync/SyncNotify.h +18 -4
  130. data/platform/shared/sync/SyncSource.cpp +52 -14
  131. data/platform/shared/sync/SyncSource.h +1 -0
  132. data/platform/shared/sync/SyncThread.cpp +29 -9
  133. data/platform/shared/sync/SyncThread.h +4 -2
  134. data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
  135. data/platform/wm/build/build_inf.js +15 -9
  136. data/platform/wm/build/wm.rake +10 -5
  137. data/platform/wm/rhodes/Alert.cpp +10 -0
  138. data/platform/wm/rhodes/Alert.h +3 -3
  139. data/platform/wm/rhodes/MainWindow.cpp +171 -26
  140. data/platform/wm/rhodes/MainWindow.h +23 -1
  141. data/platform/wm/rhodes/MetaHandler.cpp +192 -0
  142. data/platform/wm/rhodes/MetaHandler.h +31 -0
  143. data/platform/wm/rhodes/RhoNativeViewManager.cpp +126 -0
  144. data/platform/wm/rhodes/RhoNativeViewManagerWM.h +20 -0
  145. data/platform/wm/rhodes/Rhodes.cpp +91 -2
  146. data/platform/wm/rhodes/Rhodes.rc +15 -6
  147. data/platform/wm/rhodes/SyncStatusDlg.cpp +32 -0
  148. data/platform/wm/rhodes/SyncStatusDlg.h +29 -0
  149. data/platform/wm/rhodes/resource.h +5 -2
  150. data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +3 -1
  151. data/platform/wm/rhodes/rho/common/RhoThreadImpl.h +1 -1
  152. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +146 -14
  153. data/platform/wm/rhodes/rhodes.vcproj +28 -0
  154. data/rakefile.rb +119 -3
  155. data/res/build-tools/iphonesim/README +58 -0
  156. data/res/build-tools/iphonesim/Source/iPhoneSimulator.h +43 -0
  157. data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +224 -0
  158. data/res/build-tools/iphonesim/Source/main.m +52 -0
  159. data/res/build-tools/iphonesim/Source/nsprintf.h +3 -0
  160. data/res/build-tools/iphonesim/Source/nsprintf.m +42 -0
  161. data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
  162. data/res/build-tools/iphonesim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +124 -0
  163. data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +261 -0
  164. data/res/build-tools/iphonesim/iphonesim_Prefix.pch +7 -0
  165. data/res/generators/rhogen.rb +5 -0
  166. data/res/generators/templates/application/app/layout.erb +7 -13
  167. data/res/generators/templates/application/app/loading.png +0 -0
  168. data/res/generators/templates/application/build.yml +3 -0
  169. data/res/generators/templates/application/icon/icon114.png +0 -0
  170. data/res/generators/templates/application/icon/icon57.png +0 -0
  171. data/res/generators/templates/application/icon/icon72.png +0 -0
  172. data/res/generators/templates/application/public/css/iphone.css +96 -0
  173. data/res/generators/templates/application/public/images/backButton.png +0 -0
  174. data/res/generators/templates/application/public/jqtouch/jqtouch.js +2 -1
  175. data/res/generators/templates/application/rhoconfig.txt +2 -0
  176. data/rhodes.gemspec +1 -1
  177. data/spec/phone_spec/app/spec/array_pack_spec.rb +108 -0
  178. data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
  179. data/spec/phone_spec/app/spec/date_spec.rb +27 -0
  180. data/spec/phone_spec/app/spec/fixtures/classes.rb +91 -0
  181. data/spec/phone_spec/app/spec/lstrip_spec.rb +57 -0
  182. data/spec/phone_spec/app/spec/rho_spec.rb +50 -19
  183. data/spec/phone_spec/app/spec/rhom_object_spec.rb +78 -0
  184. data/spec/phone_spec/app/spec/rstrip_spec.rb +51 -0
  185. data/spec/phone_spec/app/spec/strip_spec.rb +50 -0
  186. data/spec/phone_spec/app/spec/syncengine_spec.rb +46 -3
  187. data/spec/phone_spec/app/spec_runner.rb +6 -0
  188. metadata +34 -4
@@ -0,0 +1,108 @@
1
+ # ~~~~~~~~~~
2
+ # Script encoding of this file should be neither ASCII-8BIT, US-ASCII nor UTF-8.
3
+ # This makes it easier to verify that Strings are converted into correct encodings.
4
+
5
+ require 'spec/fixtures/classes'
6
+
7
+ def binary(str) str.force_encoding(Encoding::ASCII_8BIT) end
8
+ def utf8(str) str.force_encoding(Encoding::UTF_8) end
9
+
10
+ describe "Array#pack with format 'm'" do
11
+ it "encodes string with Base64 encoding" do
12
+ ["ABCDEF"].pack('m').should == "QUJDREVG\n"
13
+ end
14
+
15
+ it "converts series of 3-char sequences into four 4-char sequences" do
16
+ ["ABCDEFGHI"].pack('m').size.should == 4+4+4+1
17
+ end
18
+
19
+ it "fills chars with non-significant bits with '=' sign" do
20
+ ["A"].pack('m').should == "QQ==\n"
21
+ end
22
+
23
+ #it "appends newline at the end of result string" do
24
+ # ["A"].pack('m')[-1].should == ?\n
25
+ #end
26
+
27
+ it "appends newline whenever after consumes 45 bytes by default" do
28
+ ["ABC"*31].pack('m').should ==
29
+ "QUJD"*15 + "\n" +
30
+ "QUJD"*15 + "\n" +
31
+ "QUJD\n"
32
+ end
33
+
34
+ =begin
35
+ it "appends newline whenever after consumes [number/3]*3 of bytes for the specified number > 2, where [x] is the floor function" do
36
+ s = ["ABC"*3].pack('m3').should == "QUJD\n"*3
37
+ s = ["ABC"*3+"\x01"].pack('m3').should == "QUJD\n"*3 + "AQ==\n"
38
+
39
+ s = ["ABC"*3].pack('m4').should == "QUJD\n"*3
40
+ s = ["ABC"*3+"\x01"].pack('m4').should == "QUJD\n"*3 + "AQ==\n"
41
+ s = ["ABC"*3+"\x01"].pack('m5').should == "QUJD\n"*3 + "AQ==\n"
42
+ s = ["ABC"*3+"\x01"].pack('m6').should == "QUJDQUJD\nQUJDAQ==\n"
43
+ end
44
+ =end
45
+
46
+ it "ignores line length parameter if it is 1 or 2" do
47
+ wrapped_at_45 =
48
+ "QUJD"*15 + "\n" +
49
+ "QUJD"*15 + "\n" +
50
+ "QUJD\n"
51
+ ["ABC"*31].pack('m1').should == wrapped_at_45
52
+ ["ABC"*31].pack('m2').should == wrapped_at_45
53
+ end
54
+
55
+ =begin
56
+ # feature changed in 1.9 - [ruby-dev:35904].
57
+ it "does not append newline if line length parameter is 0" do
58
+ ["ABC"*31].pack('m0').should == "QUJD"*31
59
+ ["ABC"*31 + "\x01"].pack('m0').should == "QUJD"*31 + "AQ=="
60
+ end
61
+ =end
62
+
63
+ it "comsumres only one array item per a format" do
64
+ ["ABC", "DEF"].pack('m').should == "QUJD\n"
65
+ ["ABC", "DEF"].pack('m3').should == "QUJD\n"
66
+ ["ABC", "DEF"].pack('m3m3').should == "QUJD\nREVG\n"
67
+ end
68
+
69
+ it "encodes 6-bit char less than 26 with capital letters" do
70
+ [( 0*4).chr].pack('m').should == "AA==\n"
71
+ [( 1*4).chr].pack('m').should == "BA==\n"
72
+
73
+ [(25*4).chr].pack('m').should == "ZA==\n"
74
+ end
75
+
76
+ it "encodes 6-bit char from 26 to 51 with lowercase letters" do
77
+ [(26*4).chr].pack('m').should == "aA==\n"
78
+ [(27*4).chr].pack('m').should == "bA==\n"
79
+
80
+ [(51*4).chr].pack('m').should == "zA==\n"
81
+ end
82
+
83
+ it "encodes 6-bit char 62 with '+'" do
84
+ [(62*4).chr].pack('m').should == "+A==\n"
85
+ end
86
+
87
+ it "encodes 6-bit char 63 with '/'" do
88
+ [(63*4).chr].pack('m').should == "/A==\n"
89
+ end
90
+
91
+ it "returns empty string if source string is empty" do
92
+ [""].pack('m').should == ""
93
+ end
94
+
95
+ =begin
96
+ it "tries to convert the pack argument to a String using #to_str" do
97
+ obj = mock('to_str')
98
+ obj.should_receive(:to_str).and_return("ABC")
99
+ [obj].pack('m').should == "QUJD\n"
100
+ end
101
+ =end
102
+
103
+ =begin
104
+ it "returns an US-ASCII string" do
105
+ ["abcd"].pack('m').encoding.should == Encoding::US_ASCII
106
+ end
107
+ =end
108
+ end
@@ -28,6 +28,7 @@ describe "BulkSync_test" do
28
28
  ::Rhom::Rhom.database_full_reset_and_logout
29
29
 
30
30
  SyncEngine.set_syncserver('http://store-bulk.rhohub.com/application')
31
+ #SyncEngine.set_syncserver('http://localhost:9292/application')
31
32
  Rho::RhoConfig.bulksync_state='0'
32
33
 
33
34
  @save_sync_types = ::Rho::RHO.get_user_db().select_from_table('sources','name, sync_type')
@@ -14,4 +14,31 @@ describe "DateTime" do
14
14
  str2 = date.strftime("%m/%d/%Y")
15
15
  str2.should == "07/08/2010"
16
16
  end
17
+
18
+ it "should format GMT datetime" do
19
+ str = "11/22/2010 04:13 PM"
20
+
21
+ time = Time.strptime(str, "%m/%d/%Y %I:%M %p")
22
+ #time.utc?.should == false
23
+
24
+ dbTime = time.utc
25
+ dbTime.utc?.should == true
26
+
27
+ res = dbTime.strftime("%Y%m%dT%H%M%S.000 GMT")
28
+
29
+ puts "res: #{res}"
30
+ #res.should == "20101122T131300.000 GMT"
31
+ end
32
+
33
+ if !defined? RHO_ME
34
+ it "should commercial date" do
35
+ Date.today.cweek
36
+ res = Date.commercial(2010, 33, 1)
37
+ puts "Date.commercial(2010, 33, 1) : #{res}"
38
+ res.year.should == 2010
39
+
40
+ res.to_s.should == "2010-08-16"
41
+ end
42
+ end
43
+
17
44
  end
@@ -0,0 +1,91 @@
1
+ module ArraySpecs
2
+ def self.max_32bit_size
3
+ 2**32/4
4
+ end
5
+
6
+ def self.max_64bit_size
7
+ 2**64/8
8
+ end
9
+
10
+ def self.frozen_array
11
+ frozen_array = [1,2,3]
12
+ frozen_array.freeze
13
+ frozen_array
14
+ end
15
+
16
+ def self.recursive_array
17
+ a = [1, 'two', 3.0]
18
+ 5.times { a << a }
19
+ a
20
+ end
21
+
22
+ def self.head_recursive_array
23
+ a = []
24
+ 5.times { a << a }
25
+ a << 1 << 'two' << 3.0
26
+ a
27
+ end
28
+
29
+ def self.empty_recursive_array
30
+ a = []
31
+ a << a
32
+ a
33
+ end
34
+
35
+ class MyArray < Array; end
36
+
37
+ class Sexp < Array
38
+ def initialize(*args)
39
+ super(args)
40
+ end
41
+ end
42
+
43
+ # TODO: replace specs that use this with #should_not_receive(:to_ary)
44
+ # expectations on regular objects (e.g. Array instances).
45
+ class ToAryArray < Array
46
+ def to_ary() ["to_ary", "was", "called!"] end
47
+ end
48
+
49
+ class MyRange < Range; end
50
+
51
+ class AssocKey
52
+ def ==(other); other == 'it'; end
53
+ end
54
+
55
+ class D
56
+ def <=>(obj)
57
+ return 4 <=> obj unless obj.class == D
58
+ 0
59
+ end
60
+ end
61
+
62
+ class SubArray < Array
63
+ def initialize(*args)
64
+ ScratchPad.record args
65
+ end
66
+ end
67
+
68
+ class ArrayConvertable
69
+ attr_accessor :called
70
+ def initialize(*values, &block)
71
+ @values = values;
72
+ end
73
+
74
+ def to_a
75
+ self.called = :to_a
76
+ @values
77
+ end
78
+
79
+ def to_ary
80
+ self.called = :to_ary
81
+ @values
82
+ end
83
+ end
84
+
85
+ class ArrayNotReallyConvertable
86
+ def to_ary
87
+ raise "Oups"
88
+ end
89
+ end
90
+
91
+ end
@@ -0,0 +1,57 @@
1
+ #require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
2
+ #require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'
3
+
4
+ describe "String#lstrip" do
5
+ it "returns a copy of self with leading whitespace removed" do
6
+ " hello ".lstrip.should == "hello "
7
+ " hello world ".lstrip.should == "hello world "
8
+ "\n\r\t\n\r hello world ".lstrip.should == "hello world "
9
+ "hello".lstrip.should == "hello"
10
+ end
11
+
12
+ # spec/core/string/lstrip_spec.rb
13
+ #not_compliant_on :rubinius do
14
+ #it "does not strip leading \0" do
15
+ # "\x00hello".lstrip.should == "\x00hello"
16
+ #end
17
+ #end
18
+
19
+ it "taints the result when self is tainted" do
20
+ #"".taint.lstrip.tainted?.should == true
21
+ #"ok".taint.lstrip.tainted?.should == true
22
+ #" ok".taint.lstrip.tainted?.should == true
23
+ end
24
+ end
25
+
26
+ describe "String#lstrip!" do
27
+ it "modifies self in place and returns self" do
28
+ a = " hello "
29
+ a.lstrip!.should == a
30
+ a.should == "hello "
31
+ end
32
+
33
+ it "returns nil if no modifications were made" do
34
+ a = "hello"
35
+ a.lstrip!.should == nil
36
+ a.should == "hello"
37
+ end
38
+
39
+ #ruby_version_is ""..."1.9" do
40
+ #it "raises a TypeError if self is frozen" do
41
+ # "hello".freeze.lstrip! # ok, nothing changed
42
+ # "".freeze.lstrip! # ok, nothing changed
43
+
44
+ # lambda { " hello ".freeze.lstrip! }.should raise_error(TypeError)
45
+ #end
46
+ #end
47
+
48
+ #ruby_version_is "1.9" do
49
+ # ruby_bug "#1550", "1.9.2" do
50
+ # it "raises a RuntimeError if self is frozen" do
51
+ # lambda { "hello".freeze.lstrip! }.should raise_error(RuntimeError)
52
+ # lambda { "".freeze.lstrip! }.should raise_error(RuntimeError)
53
+ # lambda { " hello ".freeze.lstrip! }.should raise_error(RuntimeError)
54
+ # end
55
+ # end
56
+ #end
57
+ end
@@ -150,10 +150,15 @@ describe "RhoRuby" do
150
150
  it "split should have nil" do
151
151
  line = "Account|parent_name|44e804f2-4933-4e20-271c-48fcecd9450d||\n"
152
152
  parts = line.chomp.split('|')
153
-
153
+
154
+ parts.should == ['Account','parent_name','44e804f2-4933-4e20-271c-48fcecd9450d']
154
155
  parts[3].should be_nil
155
156
  parts[4].should be_nil
156
157
  end
158
+
159
+ it "should empty fields when limit isn't given" do
160
+ "1,2,,3,4,,".split(',').should == ["1", "2", "", "3", "4"]
161
+ end
157
162
 
158
163
  it "should call to_a on string" do
159
164
  s = "abcdef"
@@ -289,26 +294,54 @@ end
289
294
  a[5..10].should == []
290
295
  end
291
296
 
292
- if !defined? RHO_ME
293
- it "should commercial date" do
294
- Date.today.cweek
295
- res = Date.commercial(2010, 33, 1)
296
- puts "Date.commercial(2010, 33, 1) : #{res}"
297
- res.year.should == 2010
297
+ it "should call Float.to_f" do
298
+ ftest = 0.34
299
+ ftest.is_a?(Float).should == true
300
+
301
+ fres = ftest.to_f
302
+ fres.is_a?(Float).should == true
303
+
304
+ fres.should == ftest
298
305
 
299
- res.to_s.should == "2010-08-16"
300
306
  end
301
- end
307
+
308
+ it "splits between characters when its argument is an empty string" do
309
+ "hi!".split("").should == ["h", "i", "!"]
310
+ #"hi!".split("", -1).should == ["h", "i", "!", ""]
311
+ "hi!".split("", 2).should == ["h", "i!"]
312
+ end
313
+
314
+ it "should split empty string" do
315
+ block = nil
316
+ if block.nil?
317
+ buffer = []
318
+ else
319
+ buffer = block.split('')
320
+ end
321
+
322
+ buffer.should_not be_nil
323
+ buffer.should == []
324
+ buffer.length.should == 0
325
+ end
326
+
327
+ it "should split empty string1" do
328
+
329
+ block = '' if block.nil?
330
+ buffer = block.split('')
331
+
332
+ buffer.should_not be_nil
333
+ buffer.should == []
334
+ buffer.length.should == 0
335
+ end
302
336
 
303
- end
304
- =begin
305
- describe "String#split with String" do
306
337
  it "returns an array of substrings based on splitting on the given string" do
307
338
  "mellow yellow".split("ello").should == ["m", "w y", "w"]
308
339
  end
309
-
340
+
310
341
  it "suppresses trailing empty fields when limit isn't given or 0" do
311
342
  "1,2,,3,4,,".split(',').should == ["1", "2", "", "3", "4"]
343
+ "1,2,,3,4".split(',').should == ["1", "2", "", "3", "4"]
344
+
312
345
  "1,2,,3,4,,".split(',', 0).should == ["1", "2", "", "3", "4"]
313
346
  " a b c\nd ".split(" ").should == ["", "a", "b", "c\nd"]
314
347
  "hai".split("hai").should == []
@@ -346,6 +379,10 @@ describe "String#split with String" do
346
379
  " a b c\nd ".split(" ", -1).should == ["", "a", "b", "c\nd", ""]
347
380
  ",".split(",", -1).should == ["", ""]
348
381
  end
382
+ end
383
+
384
+ =begin
385
+ describe "String#split with String" do
349
386
 
350
387
  it "defaults to $; when string isn't given or nil" do
351
388
  begin
@@ -378,12 +415,6 @@ describe "String#split with String" do
378
415
  "a\x00a b".split(' ').should == ["a\x00a", "b"]
379
416
  end
380
417
 
381
- it "splits between characters when its argument is an empty string" do
382
- "hi!".split("").should == ["h", "i", "!"]
383
- "hi!".split("", -1).should == ["h", "i", "!", ""]
384
- "hi!".split("", 2).should == ["h", "i!"]
385
- end
386
-
387
418
  it "doesn't set $~" do
388
419
  $~ = nil
389
420
  "x.y.z".split(".")
@@ -823,6 +823,67 @@ describe "Rhom::RhomObject" do
823
823
  @accts[1].name.should == "Aeroprise"
824
824
  @accts[1].industry.should == "Technology"
825
825
  end
826
+
827
+ it "should order by block" do
828
+ @accts = getAccount.find(:all, :order => 'name') do |x,y|
829
+ y <=> x
830
+ end
831
+
832
+ @accts[0].name.should == "Mobio India"
833
+ @accts[0].industry.should == "Technology"
834
+ @accts[1].name.should == "Aeroprise"
835
+ @accts[1].industry.should == "Technology"
836
+
837
+ @accts = getAccount.find(:all, :order => 'name', :orderdir => 'DESC') do |x,y|
838
+ y <=> x
839
+ end
840
+
841
+ @accts[0].name.should == "Aeroprise"
842
+ @accts[0].industry.should == "Technology"
843
+ @accts[1].name.should == "Mobio India"
844
+ @accts[1].industry.should == "Technology"
845
+
846
+ puts "block without order parameter"
847
+ @accts = getAccount.find(:all) do |item1,item2|
848
+ item2.name <=> item1.name
849
+ end
850
+
851
+ @accts[0].name.should == "Mobio India"
852
+ @accts[0].industry.should == "Technology"
853
+ @accts[1].name.should == "Aeroprise"
854
+ @accts[1].industry.should == "Technology"
855
+
856
+ end
857
+
858
+ it "should order by multiple columns" do
859
+ getAccount.create(:name=>'ZMobile', :industry => 'IT', :modified_by_name => 'user')
860
+ getAccount.create(:name=>'Aeroprise', :industry => 'Accounting', :modified_by_name => 'admin')
861
+
862
+ @accts = getAccount.find(:all, :order => ['name', 'industry'], :orderdir => ['ASC', 'DESC'])
863
+
864
+ @accts.length().should == 4
865
+ @accts[0].name.should == "Aeroprise"
866
+ @accts[0].industry.should == "Technology"
867
+ @accts[1].name.should == "Aeroprise"
868
+ @accts[1].industry.should == "Accounting"
869
+ @accts[2].name.should == "Mobio India"
870
+ @accts[2].industry.should == "Technology"
871
+ @accts[3].name.should == "ZMobile"
872
+ @accts[3].industry.should == "IT"
873
+
874
+ puts "multiple order with condition"
875
+ @accts = getAccount.find(:all, :conditions => {:modified_by_name => 'admin'},
876
+ :order => ['name', 'industry'], :orderdir => ['ASC', 'DESC'])
877
+
878
+ @accts.length().should == 3
879
+ @accts[0].name.should == "Aeroprise"
880
+ @accts[0].industry.should == "Technology"
881
+ @accts[1].name.should == "Aeroprise"
882
+ @accts[1].industry.should == "Accounting"
883
+ @accts[2].name.should == "Mobio India"
884
+ @accts[2].industry.should == "Technology"
885
+
886
+ end
826
887
 
827
888
  it "should return records when order by is nil for some records" do
828
889
  @accts = getAccount.find(:all, :order => 'shipping_address_country', :dont_ignore_missed_attribs => true)
@@ -836,16 +897,33 @@ describe "Rhom::RhomObject" do
836
897
  end
837
898
 
838
899
  it "should delete_all" do
900
+ vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
901
+ account = getAccount.create(vars)
902
+
839
903
  getAccount.delete_all
840
904
 
841
905
  getAccount.find(:all).length.should == 0
906
+
907
+ if $spec_settings[:sync_model]
908
+ records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*', 'source_id' => getAccount().get_source_id() )
909
+ records.length.should == 0
910
+ end
842
911
  end
843
912
 
844
913
  it "should delete_all with conditions" do
914
+ vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
915
+ account = getAccount.create(vars)
916
+
845
917
  getAccount.delete_all(:conditions => {'name' => 'Mobio India'})
846
918
 
847
919
  @accts = getAccount.find(:all, :conditions => {'name' => 'Mobio India'})
848
920
  @accts.length.should == 0
921
+
922
+ if $spec_settings[:sync_model]
923
+ records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*', 'source_id' => getAccount().get_source_id() )
924
+ records.length.should > 0
925
+ end
926
+
849
927
  end
850
928
 
851
929
  it "should delete_all with conditions across objects" do
@@ -0,0 +1,51 @@
1
+ #require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
2
+ #require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'
3
+
4
+ describe "String#rstrip" do
5
+ it "returns a copy of self with trailing whitespace removed" do
6
+ " hello ".rstrip.should == " hello"
7
+ " hello world ".rstrip.should == " hello world"
8
+ " hello world \n\r\t\n\r".rstrip.should == " hello world"
9
+ "hello".rstrip.should == "hello"
10
+ "hello".rstrip.should == "hello"
11
+ end
12
+
13
+ #it "taints the result when self is tainted" do
14
+ # "".taint.rstrip.tainted?.should == true
15
+ # "ok".taint.rstrip.tainted?.should == true
16
+ # "ok ".taint.rstrip.tainted?.should == true
17
+ #end
18
+ end
19
+
20
+ describe "String#rstrip!" do
21
+ it "modifies self in place and returns self" do
22
+ a = " hello "
23
+ a.rstrip!.should == a
24
+ a.should == " hello"
25
+ end
26
+
27
+ it "returns nil if no modifications were made" do
28
+ a = "hello"
29
+ a.rstrip!.should == nil
30
+ a.should == "hello"
31
+ end
32
+
33
+ #ruby_version_is ""..."1.9" do
34
+ #it "raises a TypeError if self is frozen" do
35
+ # "hello".freeze.rstrip! # ok, nothing changed
36
+ # "".freeze.rstrip! # ok, nothing changed
37
+
38
+ # lambda { " hello ".freeze.rstrip! }.should raise_error(TypeError)
39
+ #end
40
+ #end
41
+
42
+ #ruby_version_is "1.9" do
43
+ # ruby_bug "[ruby-core:23666]", "1.9.2" do
44
+ # it "raises a RuntimeError if self is frozen" do
45
+ # lambda { "hello".freeze.rstrip! }.should raise_error(RuntimeError)
46
+ # lambda { "".freeze.rstrip! }.should raise_error(RuntimeError)
47
+ # lambda { " hello ".freeze.rstrip! }.should raise_error(RuntimeError)
48
+ # end
49
+ #end
50
+ #end
51
+ end
@@ -0,0 +1,50 @@
1
+ #require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
2
+ #require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'
3
+
4
+ describe "String#strip" do
5
+ it "returns a new string with leading and trailing whitespace removed" do
6
+ " hello ".strip.should == "hello"
7
+ " hello world ".strip.should == "hello world"
8
+ "\tgoodbye\r\n".strip.should == "goodbye"
9
+ " goodbye \000".strip.should == "goodbye"
10
+ end
11
+
12
+ #it "taints the result when self is tainted" do
13
+ # "".taint.strip.tainted?.should == true
14
+ # "ok".taint.strip.tainted?.should == true
15
+ # " ok ".taint.strip.tainted?.should == true
16
+ #end
17
+ end
18
+
19
+ describe "String#strip!" do
20
+ it "modifies self in place and returns self" do
21
+ a = " hello "
22
+ a.strip!.should == a
23
+ a.should == "hello"
24
+ end
25
+
26
+ it "returns nil if no modifications where made" do
27
+ a = "hello"
28
+ a.strip!.should == nil
29
+ a.should == "hello"
30
+ end
31
+
32
+ #ruby_version_is ""..."1.9" do
33
+ # it "raises a TypeError if self is frozen" do
34
+ # "hello".freeze.strip! # ok, nothing changed
35
+ # "".freeze.strip! # ok, nothing changed
36
+
37
+ # lambda { " hello ".freeze.strip! }.should raise_error(TypeError)
38
+ # end
39
+ #end
40
+
41
+ #ruby_version_is "1.9" do
42
+ # ruby_bug "#1552", "1.9.2" do
43
+ # it "raises a RuntimeError if self is frozen" do
44
+ # lambda {"hello".freeze.strip! }.should raise_error(RuntimeError)
45
+ # lambda {"".freeze.strip! }.should raise_error(RuntimeError)
46
+ # lambda { " hello ".freeze.strip! }.should raise_error(RuntimeError)
47
+ # end
48
+ #end
49
+ #end
50
+ end
@@ -44,6 +44,9 @@ def getCustomer_str
44
44
  'Customer'
45
45
  end
46
46
 
47
+ SYNC_SERVER_URL = 'http://rhodes-store-server.heroku.com/application'
48
+ #SYNC_SERVER_URL = 'http://localhost:9292/application'
49
+
47
50
  describe "SyncEngine_test" do
48
51
 
49
52
  before(:all) do
@@ -51,8 +54,7 @@ describe "SyncEngine_test" do
51
54
 
52
55
  ::Rhom::Rhom.database_fullclient_reset_and_logout
53
56
 
54
- SyncEngine.set_syncserver('http://rhodes-store-server.heroku.com/application')
55
- #SyncEngine.set_syncserver('http://localhost:9292/application')
57
+ SyncEngine.set_syncserver(SYNC_SERVER_URL)
56
58
 
57
59
  @save_sync_types = ::Rho::RHO.get_user_db().select_from_table('sources','name, sync_type')
58
60
  ::Rho::RHO.get_user_db().update_into_table('sources',{'sync_type'=>'none'})
@@ -66,6 +68,10 @@ describe "SyncEngine_test" do
66
68
  end
67
69
 
68
70
  end
71
+
72
+ after (:each) do
73
+ Rho::RhoConfig.syncserver = SYNC_SERVER_URL
74
+ end
69
75
 
70
76
  it "should update syncserver at runtime" do
71
77
 
@@ -91,7 +97,16 @@ describe "SyncEngine_test" do
91
97
  res['error_code'].to_i.should == ::Rho::RhoError::ERR_CLIENTISNOTLOGGEDIN
92
98
 
93
99
  end
94
-
100
+ =begin
101
+ it "should update sources from database" do
102
+ uniq_sources = Rho::RhoConfig::sources.values
103
+
104
+ ::Rho::RHO.get_instance().load_server_sources("{\"partition\":\"user\"}")
105
+ ::Rhom::Rhom.database_fullclient_reset_and_logout
106
+
107
+ #uniq_sources.should == Rho::RhoConfig::sources.values
108
+ end
109
+ =end
95
110
  it "should login" do
96
111
 
97
112
  res = ::Rho::RhoSupport::parse_query_parameters SyncEngine.login('lars', 'larspass', "/app/Settings/login_callback")
@@ -199,6 +214,34 @@ describe "SyncEngine_test" do
199
214
  cust22.first.should == cust2.first
200
215
 
201
216
  end
217
+
218
+ it "should process error sync" do
219
+
220
+ records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
221
+ records.length.should == 0
222
+
223
+ cust1 = getCustomer.create( {:first => "CustTest1"})
224
+
225
+ records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
226
+ records.length.should_not == 0
227
+
228
+ Rho::RhoConfig.syncserver = 'http://rhodes-store-server.heroku2.com/application'
229
+ res = ::Rho::RhoSupport::parse_query_parameters getCustomer.sync
230
+ res['status'].should == 'error'
231
+ res['error_code'].to_i.should == ::Rho::RhoError::ERR_NETWORK
232
+
233
+ records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
234
+ records.length.should_not == 0
235
+
236
+ Rho::RhoConfig.syncserver = SYNC_SERVER_URL
237
+ res = ::Rho::RhoSupport::parse_query_parameters getCustomer.sync
238
+ res['status'].should == 'ok'
239
+ res['error_code'].to_i.should == ::Rho::RhoError::ERR_NONE
240
+
241
+ records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
242
+ records.length.should == 0
243
+
244
+ end
202
245
 
203
246
  it "should modify Product" do
204
247
  SyncEngine.logged_in.should == 1