rhoconnect 4.0.4 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +54 -5
  3. data/CREDITS +219 -219
  4. data/Gemfile +2 -2
  5. data/Gemfile.lock +68 -79
  6. data/Rakefile +1 -2
  7. data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
  8. data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
  9. data/bench/benchapp/spec/spec_helper.rb +3 -3
  10. data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
  11. data/bench/blobapp/spec/spec_helper.rb +3 -3
  12. data/bench/lib/bench/runner.rb +1 -69
  13. data/bench/lib/bench.rb +18 -18
  14. data/bench/spec/mock_adapter_spec.rb +54 -55
  15. data/bench/spec/mock_client_spec.rb +47 -48
  16. data/bench/spec/result_spec.rb +41 -44
  17. data/bench/spec/utils_spec.rb +24 -25
  18. data/commands/generators/app.rb +7 -5
  19. data/commands/generators/controller.rb +7 -5
  20. data/commands/generators/model.rb +7 -5
  21. data/commands/generators/source.rb +7 -5
  22. data/commands/parser.rb +1 -1
  23. data/commands/redis/redis_download.rb +1 -1
  24. data/doc/async-jobs.txt +9 -9
  25. data/doc/supported-platforms.txt +0 -2
  26. data/generators/rhoconnect.rb +92 -212
  27. data/generators/templates/application/rcgemfile +3 -3
  28. data/generators/templates/application/spec/application_controller_spec.rb +14 -16
  29. data/generators/templates/application/spec/js_spec.rb +20 -20
  30. data/generators/templates/application/spec/spec_helper.rb +1 -1
  31. data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
  32. data/generators/templates/source/models/ruby/model_spec.rb +17 -17
  33. data/install.sh +10 -21
  34. data/installer/unix-like/rho_connect_install_constants.rb +5 -5
  35. data/installer/unix-like/rho_connect_install_installers.rb +4 -4
  36. data/installer/utils/constants.rb +6 -6
  37. data/installer/utils/nix_install_test.rb +29 -29
  38. data/installer/utils/package_upload/repos.rake +16 -26
  39. data/js-adapters/node.rb +4 -4
  40. data/js-adapters/node_channel.rb +4 -8
  41. data/lib/rhoconnect/db_adapter.rb +13 -13
  42. data/lib/rhoconnect/handler/changes/engine.rb +1 -1
  43. data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
  44. data/lib/rhoconnect/license.rb +7 -7
  45. data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
  46. data/lib/rhoconnect/ping/apple.rb +4 -4
  47. data/lib/rhoconnect/server.rb +2 -2
  48. data/lib/rhoconnect/source.rb +2 -2
  49. data/lib/rhoconnect/store.rb +12 -6
  50. data/lib/rhoconnect/utilities.rb +2 -2
  51. data/lib/rhoconnect/version.rb +1 -1
  52. data/lib/rhoconnect.rb +6 -4
  53. data/rhoconnect.gemspec +5 -6
  54. data/spec/api/api_helper.rb +1 -1
  55. data/spec/api/app/fast_delete_spec.rb +22 -22
  56. data/spec/api/app/fast_insert_spec.rb +23 -23
  57. data/spec/api/app/fast_update_spec.rb +63 -63
  58. data/spec/api/app/push_deletes_spec.rb +11 -13
  59. data/spec/api/app/push_objects_spec.rb +39 -39
  60. data/spec/api/client/client_get_db_doc_spec.rb +29 -29
  61. data/spec/api/client/client_set_db_doc_spec.rb +11 -11
  62. data/spec/api/client/get_client_params_spec.rb +29 -29
  63. data/spec/api/client/list_client_docs_spec.rb +32 -34
  64. data/spec/api/client/reset_spec.rb +30 -30
  65. data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
  66. data/spec/api/source/get_source_params_spec.rb +32 -34
  67. data/spec/api/source/list_sources_spec.rb +13 -13
  68. data/spec/api/source/update_source_params_spec.rb +19 -19
  69. data/spec/api/store/get_db_doc_spec.rb +27 -27
  70. data/spec/api/store/set_db_doc_spec.rb +38 -38
  71. data/spec/api/system/adapter_spec.rb +27 -29
  72. data/spec/api/system/get_license_info_spec.rb +11 -11
  73. data/spec/api/system/login_spec.rb +37 -37
  74. data/spec/api/system/reset_spec.rb +15 -15
  75. data/spec/api/system/stats_spec.rb +70 -71
  76. data/spec/api/user/create_user_spec.rb +37 -37
  77. data/spec/api/user/delete_client_spec.rb +7 -7
  78. data/spec/api/user/delete_user_spec.rb +62 -62
  79. data/spec/api/user/list_clients_spec.rb +24 -24
  80. data/spec/api/user/list_source_docs_spec.rb +29 -29
  81. data/spec/api/user/list_users_spec.rb +22 -22
  82. data/spec/api/user/ping_spec.rb +18 -18
  83. data/spec/api/user/show_user_spec.rb +10 -10
  84. data/spec/api/user/update_user_spec.rb +43 -43
  85. data/spec/api/user/user_get_db_doc_spec.rb +12 -12
  86. data/spec/api/user/user_set_db_doc_spec.rb +37 -37
  87. data/spec/api_token_spec.rb +8 -8
  88. data/spec/app_spec.rb +18 -17
  89. data/spec/apps/jstestapp/settings/settings.yml +2 -0
  90. data/spec/async_spec.rb +9 -11
  91. data/spec/bulk_data/bulk_data_spec.rb +120 -120
  92. data/spec/cli/cli_spec.rb +50 -53
  93. data/spec/client_spec.rb +105 -105
  94. data/spec/client_sync_spec.rb +529 -528
  95. data/spec/controllers/js_base_spec.rb +147 -141
  96. data/spec/doc/doc_spec.rb +51 -52
  97. data/spec/document_spec.rb +58 -58
  98. data/spec/dynamic_adapter_spec.rb +33 -36
  99. data/spec/generator/generator_spec.rb +76 -42
  100. data/spec/jobs/bulk_data_job_spec.rb +101 -102
  101. data/spec/jobs/ping_job_spec.rb +176 -177
  102. data/spec/jobs/source_job_spec.rb +24 -25
  103. data/spec/license_spec.rb +54 -55
  104. data/spec/models/js_base_spec.rb +121 -120
  105. data/spec/perf/bulk_data_perf_spec.rb +23 -24
  106. data/spec/perf/perf_spec_helper.rb +7 -7
  107. data/spec/perf/store_perf_spec.rb +139 -140
  108. data/spec/ping/apple_spec.rb +65 -65
  109. data/spec/ping/gcm_spec.rb +83 -84
  110. data/spec/ping/rhoconnect_push_spec.rb +52 -53
  111. data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
  112. data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
  113. data/spec/read_state_spec.rb +24 -25
  114. data/spec/rhoconnect_spec.rb +7 -7
  115. data/spec/server/server_spec.rb +664 -662
  116. data/spec/server/stats_spec.rb +12 -12
  117. data/spec/source_adapter_spec.rb +124 -125
  118. data/spec/source_spec.rb +148 -149
  119. data/spec/source_sync_spec.rb +736 -736
  120. data/spec/spec_helper.rb +4 -5
  121. data/spec/stats/record_spec.rb +22 -21
  122. data/spec/store_orm_spec.rb +48 -48
  123. data/spec/store_spec.rb +428 -426
  124. data/spec/support/shared_examples.rb +5 -7
  125. data/spec/sync_states_spec.rb +67 -67
  126. data/spec/test_methods_spec.rb +121 -123
  127. data/spec/testdata/10000-data.txt +0 -0
  128. data/spec/testdata/5000-data.txt +0 -0
  129. data/spec/user_spec.rb +102 -102
  130. data/tasks/redis.rake +3 -3
  131. metadata +154 -195
  132. data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
  133. data/bench/benchapp/tmp/restart.txt +0 -0
  134. data/bench/blobapp/settings/license.key.bak +0 -2
  135. data/bench/blobapp/tmp/restart.txt +0 -0
  136. data/bench/lib/testdata/1-data.txt +0 -0
  137. data/bench/lib/testdata/10-data.txt +0 -0
  138. data/bench/lib/testdata/2-data.txt +0 -0
  139. data/bench/lib/testdata/250-data.txt +0 -0
  140. data/bench/lib/testdata/5-blob_data.txt +0 -0
  141. data/bench/lib/testdata/5-data.txt +0 -0
  142. data/bench/lib/testdata/50-data.txt +0 -0
  143. data/bench/lib/testdata/500-data.txt +0 -0
  144. data/doc/protocol.html +0 -1993
  145. data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
  146. data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
  147. data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
  148. data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
  149. data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
  150. data/spec/coverage/rcov/index.html +0 -88
  151. data/spec/generator/generator_spec_helper.rb +0 -9
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rspec'
3
3
  require 'webmock/rspec'
4
- require 'rspec/autorun' # Required for Rcov to run with rspec '~> 2.8.0'
5
4
 
6
5
  require 'simplecov'
7
6
  require 'simplecov-rcov'
@@ -56,10 +55,10 @@ ENV['RACK_ENV'] = 'test'
56
55
  ERROR = '0_broken_object_id' unless defined? ERROR
57
56
 
58
57
  class Rhoconnect::Model::Base
59
- def inject_result(result)
58
+ def inject_result(result)
60
59
  @result = result
61
60
  end
62
-
61
+
63
62
  def inject_tmpdoc(doctype)
64
63
  @tmp_docname = doctype
65
64
  @stash_size = 0
@@ -144,7 +143,7 @@ module TestHelpers
144
143
  end
145
144
 
146
145
  def setup_post_yield(response)
147
- RestClient.stub!(:post).and_yield(response, nil, nil)
146
+ RestClient.stub(:post).and_yield(response, nil, nil)
148
147
  end
149
148
 
150
149
  def set_state(state,append=false)
@@ -345,7 +344,7 @@ module TestHelpers
345
344
  end
346
345
 
347
346
  def unzip_file(file,file_dir)
348
- Zip::ZipFile.open(file) do |zip_file|
347
+ Zip::File.open(file) do |zip_file|
349
348
  zip_file.each do |f|
350
349
  f_path = File.join(file_dir,f.name)
351
350
  FileUtils.mkdir_p(File.dirname(f_path))
@@ -7,67 +7,68 @@ STATS_RECORD_SIZE = 8 unless defined? STATS_RECORD_SIZE
7
7
  include Rhoconnect
8
8
 
9
9
  describe "Record" do
10
-
10
+
11
11
  before(:each) do
12
12
  @now = 9
13
+ Store.create
13
14
  Store.flush_all
14
- Store.stub!(:lock).and_yield
15
+ Store.stub(:lock).and_yield
15
16
  end
16
-
17
+
17
18
  it "should add metric to the record and trim record size" do
18
- Time.stub!(:now).and_return { @now }
19
+ Time.stub(:now).and_return { @now }
19
20
  10.times { @now += 1; Rhoconnect::Stats::Record.add('foo') }
20
21
  Store.zrange('stat:foo', 0, -1).should == ["2:12", "2:14", "2:16", "2:18"]
21
22
  end
22
-
23
+
23
24
  it "should add single record" do
24
- Time.stub!(:now).and_return { @now += 1; @now }
25
+ Time.stub(:now).and_return { @now += 1; @now }
25
26
  Rhoconnect::Stats::Record.add('foo')
26
27
  Store.zrange('stat:foo', 0, -1).should == ["1:10"]
27
28
  end
28
-
29
+
29
30
  it "should return type of metric" do
30
31
  Rhoconnect::Stats::Record.add('foo')
31
32
  Rhoconnect::Stats::Record.rtype('foo').should == 'zset'
32
33
  end
33
-
34
+
34
35
  it "should set string metric" do
35
36
  Rhoconnect::Stats::Record.set_value('foo', 'bar')
36
37
  Store.get_value('stat:foo').should == 'bar'
37
38
  end
38
-
39
+
39
40
  it "should get string metric" do
40
41
  Store.put_value('stat:foo', 'bar')
41
42
  Rhoconnect::Stats::Record.get_value('foo').should == 'bar'
42
43
  end
43
-
44
+
44
45
  it "should get keys" do
45
46
  Rhoconnect::Stats::Record.add('foo')
46
47
  Rhoconnect::Stats::Record.add('bar')
47
48
  Rhoconnect::Stats::Record.keys.sort.should == ['bar','foo']
48
49
  end
49
-
50
+
50
51
  it "should add absolute metric value" do
51
- Time.stub!(:now).and_return { @now }
52
+ Time.stub(:now).and_return { @now }
52
53
  time = 0
53
- 4.times do
54
+ 4.times do
54
55
  @now += 1
55
56
  Rhoconnect::Stats::Record.save_average('foo',time)
56
57
  time += 1
57
58
  end
58
59
  Store.zrange('stat:foo', 0, -1).should == ["2.0,1.0:10", "2.0,5.0:12"]
59
60
  end
60
-
61
+
61
62
  it "should update metric" do
62
63
  Rhoconnect.stats = true
63
64
  @incr = 0
64
- Time.stub!(:now).and_return do
65
+ Time.stub(:now).and_return do
65
66
  if @incr > 0
66
67
  @now += 1
67
68
  @incr -= 1
68
69
  end
69
70
  @now
70
- end
71
+ end
71
72
  4.times do
72
73
  @now += 1
73
74
  Rhoconnect::Stats::Record.update('foo') do
@@ -77,21 +78,21 @@ describe "Record" do
77
78
  Store.zrange('stat:foo', 0, -1).should == ["1,1.0:14", "1,1.0:18", "1,1.0:20"]
78
79
  Rhoconnect.stats = false
79
80
  end
80
-
81
+
81
82
  it "should get range of metric values" do
82
- Time.stub!(:now).and_return { @now }
83
+ Time.stub(:now).and_return { @now }
83
84
  10.times { @now += 1; Rhoconnect::Stats::Record.add('foo') }
84
85
  Rhoconnect::Stats::Record.range('foo', 0, 1).should == ["2:12", "2:14"]
85
86
  end
86
-
87
+
87
88
  it "should reset metric" do
88
- Time.stub!(:now).and_return { @now }
89
+ Time.stub(:now).and_return { @now }
89
90
  10.times { @now += 1; Rhoconnect::Stats::Record.add('foo') }
90
91
  Store.zrange('stat:foo', 0, -1).should == ["2:12", "2:14", "2:16", "2:18"]
91
92
  Rhoconnect::Stats::Record.reset('foo')
92
93
  Store.zrange('stat:foo', 0, -1).should == []
93
94
  end
94
-
95
+
95
96
  it "should reset all metrics" do
96
97
  Rhoconnect::Stats::Record.add('foo')
97
98
  Rhoconnect::Stats::Record.add('bar')
@@ -2,31 +2,31 @@
2
2
  require File.join(File.dirname(__FILE__),'spec_helper')
3
3
 
4
4
  describe Rhoconnect::StoreOrm do
5
-
5
+
6
6
  context "DSL" do
7
7
  class TestDSL < Rhoconnect::StoreOrm
8
8
  field :foo
9
9
  list :bar
10
10
  set :sloppy
11
11
  end
12
-
12
+
13
13
  before(:each) do
14
14
  @x = TestDSL.with_key(1)
15
15
  end
16
-
16
+
17
17
  it "should define rw accessors for field" do
18
18
  @x.should respond_to(:foo)
19
19
  @x.should respond_to(:foo=)
20
20
  end
21
-
21
+
22
22
  it "should define r accessor for list" do
23
23
  @x.should respond_to(:bar)
24
24
  end
25
-
25
+
26
26
  it "should define r accessor for set" do
27
27
  @x.should respond_to(:sloppy)
28
28
  end
29
-
29
+
30
30
  it "should raise error on invalid type" do
31
31
  lambda do
32
32
  class TestInvalidType < Rhoconnect::StoreOrm
@@ -35,7 +35,7 @@ describe Rhoconnect::StoreOrm do
35
35
  end.should raise_error(ArgumentError, 'Unknown type invalid_type for field invalid')
36
36
  end
37
37
  end
38
-
38
+
39
39
  context "field type cast" do
40
40
  class TestType < Rhoconnect::StoreOrm
41
41
  field :foo_string, :string
@@ -43,21 +43,21 @@ describe Rhoconnect::StoreOrm do
43
43
  field :foo_date, :datetime
44
44
  field :foo_int, :int
45
45
  field :foo_float, :float
46
-
46
+
47
47
  list :list_date, :datetime
48
- set :set_date, :datetime
48
+ set :set_date, :datetime
49
49
  end
50
-
50
+
51
51
  class TestValidateType < Rhoconnect::StoreOrm
52
52
  field :v_field, :string
53
53
  validates_presence_of :v_field
54
54
  end
55
-
55
+
56
56
  class TestLoadType < Rhoconnect::StoreOrm
57
57
  field :something, :string
58
58
  attr_accessor :foo
59
59
  end
60
-
60
+
61
61
  before(:each) do
62
62
  Store.create
63
63
  Store.flush_all
@@ -67,47 +67,47 @@ describe Rhoconnect::StoreOrm do
67
67
  @yRedisDbMock = RSpec::Mocks::Mock.new
68
68
  @x = TestType.with_key(1)
69
69
  @y = TestType.with_key(1)
70
- @x.stub!(:store).and_return(@xRedisMock)
71
- @y.stub!(:store).and_return(@yRedisMock)
72
- @xRedisMock.stub!(:db).and_return(@xRedisDbMock)
73
- @yRedisMock.stub!(:db).and_return(@yRedisDbMock)
70
+ @x.stub(:store).and_return(@xRedisMock)
71
+ @y.stub(:store).and_return(@yRedisMock)
72
+ @xRedisMock.stub(:db).and_return(@xRedisDbMock)
73
+ @yRedisMock.stub(:db).and_return(@yRedisDbMock)
74
74
  end
75
-
75
+
76
76
  it "should create with string id" do
77
77
  @x = TestType.create(:id => 'test')
78
78
  @x.id.should == 'test'
79
79
  end
80
-
80
+
81
81
  it "should create with auto-increment id" do
82
82
  @x = TestType.create
83
83
  @x1 = TestType.create
84
84
  @x1.id.should == @x.id + 1
85
85
  end
86
-
86
+
87
87
  it "should raise ArgumentError on create with duplicate id" do
88
88
  @x = TestType.create(:id => 'test1')
89
- lambda { TestType.create(:id => 'test1') }.should
89
+ lambda { TestType.create(:id => 'test1') }.should
90
90
  raise_error(ArgumentError, "Record already exists for 'test1'")
91
91
  end
92
-
92
+
93
93
  it "should validate_presence_of v_field" do
94
94
  lambda { TestValidateType.create(:id => 'test2') }.should
95
95
  raise_error(ArgumentError, "Missing required field 'v_field'")
96
96
  end
97
-
97
+
98
98
  it "should load with attributes set" do
99
99
  TestLoadType.create(:id => 'test2')
100
100
  @x = TestLoadType.load('test2',{:foo => 'bar'})
101
101
  @x.foo.should == 'bar'
102
102
  end
103
-
103
+
104
104
  it "should save string as is" do
105
105
  @xRedisMock.should_receive(:put_value).with('test_type:1:foo_string', 'xxx')
106
106
  @yRedisMock.should_receive(:get_value).with('test_type:1:foo_string').and_return('xxx')
107
107
  @x.foo_string = 'xxx'
108
108
  @y.foo_string.should be_instance_of(String)
109
109
  end
110
-
110
+
111
111
  it "should marshal integer fields" do
112
112
  @xRedisMock.should_receive(:put_value).with('test_type:1:foo_int', '12')
113
113
  @yRedisMock.should_receive(:get_value).with('test_type:1:foo_int').and_return('12')
@@ -115,7 +115,7 @@ describe Rhoconnect::StoreOrm do
115
115
  @y.foo_int.should be_kind_of(Integer)
116
116
  @y.foo_int.should == 12
117
117
  end
118
-
118
+
119
119
  it "should marshal float fields" do
120
120
  @xRedisMock.should_receive(:put_value).with('test_type:1:foo_float', '12.1')
121
121
  @yRedisMock.should_receive(:get_value).with('test_type:1:foo_float').and_return('12.1')
@@ -123,7 +123,7 @@ describe Rhoconnect::StoreOrm do
123
123
  @y.foo_float.should be_kind_of(Float)
124
124
  @y.foo_float.should == 12.1
125
125
  end
126
-
126
+
127
127
  it "should marshal datetime fields" do
128
128
  time = DateTime.now
129
129
  str = time.strftime('%FT%T%z')
@@ -133,7 +133,7 @@ describe Rhoconnect::StoreOrm do
133
133
  @y.foo_date.should be_kind_of(DateTime)
134
134
  @y.foo_date.should.to_s == time.to_s
135
135
  end
136
-
136
+
137
137
  it "should marshal json structs" do
138
138
  data = {'foo' => 'bar', 'x' => 2}
139
139
  str = JSON.dump(data)
@@ -143,16 +143,16 @@ describe Rhoconnect::StoreOrm do
143
143
  @y.foo_json.should be_kind_of(Hash)
144
144
  @y.foo_json.should.inspect == data.inspect
145
145
  end
146
-
146
+
147
147
  it "should return nil for empty fields" do
148
148
  @xRedisMock.should_receive(:get_value).with('test_type:1:foo_date').and_return(nil)
149
149
  @x.foo_date.should be_nil
150
150
  end
151
-
151
+
152
152
  it "should marshal list values" do
153
153
  data = DateTime.now
154
154
  str = data.strftime('%FT%T%z')
155
-
155
+
156
156
  @xRedisDbMock.should_receive('rpush').with('test_type:1:list_date', str)
157
157
  @xRedisDbMock.should_receive('lset').with('test_type:1:list_date', 1, str)
158
158
  @xRedisDbMock.should_receive('exists').with('test_type:1:list_date', str)
@@ -172,7 +172,7 @@ describe Rhoconnect::StoreOrm do
172
172
  @x.list_date.pop_tail.should be_kind_of(DateTime)
173
173
  @x.list_date.pop_head.should be_kind_of(DateTime)
174
174
  end
175
-
175
+
176
176
  it "should marshal set values" do
177
177
  data = DateTime.now
178
178
  str = data.strftime('%FT%T%z')
@@ -188,34 +188,34 @@ describe Rhoconnect::StoreOrm do
188
188
  end
189
189
 
190
190
  it "should handle empty members" do
191
- @xRedisDbMock.stub!(:smembers).and_return(nil)
191
+ @xRedisDbMock.stub(:smembers).and_return(nil)
192
192
  @x.set_date.members.should == []
193
193
  end
194
194
  end
195
-
195
+
196
196
  context "increment/decrement" do
197
197
  class TestIncrements < Rhoconnect::StoreOrm
198
198
  field :foo, :integer
199
199
  field :bar, :string
200
200
  field :baz, :float
201
201
  end
202
-
202
+
203
203
  before do
204
204
  @redisMock = RSpec::Mocks::Mock.new
205
205
  @x = TestIncrements.with_key(1)
206
- @x.stub!(:store).and_return(@redisMock)
206
+ @x.stub(:store).and_return(@redisMock)
207
207
  end
208
-
208
+
209
209
  it "should send INCR when #increment! is called on an integer" do
210
210
  @redisMock.should_receive(:update_count).with("test_increments:1:foo", 1)
211
211
  @x.increment!(:foo)
212
212
  end
213
-
213
+
214
214
  it "should send DECR when #decrement! is called on an integer" do
215
215
  @redisMock.should_receive(:update_count).with("test_increments:1:foo", -1)
216
216
  @x.decrement!(:foo)
217
217
  end
218
-
218
+
219
219
  it "should raise an ArgumentError when called on non-integers" do
220
220
  [:bar, :baz].each do |f|
221
221
  lambda{@x.increment!(f)}.should raise_error(ArgumentError)
@@ -223,47 +223,47 @@ describe Rhoconnect::StoreOrm do
223
223
  end
224
224
  end
225
225
  end
226
-
226
+
227
227
  context "redis commands" do
228
228
  class TestCommands < Rhoconnect::StoreOrm
229
229
  field :foo
230
230
  list :bar
231
231
  set :sloppy
232
232
  end
233
-
233
+
234
234
  before(:each) do
235
235
  @redisMock = RSpec::Mocks::Mock.new
236
236
  @redisDbMock = RSpec::Mocks::Mock.new
237
237
  @x = TestCommands.with_key(1)
238
- @x.stub!(:store).and_return(@redisMock)
239
- @redisMock.stub!(:db).and_return(@redisDbMock)
238
+ @x.stub(:store).and_return(@redisMock)
239
+ @redisMock.stub(:db).and_return(@redisDbMock)
240
240
  end
241
-
241
+
242
242
  it "should send GET on field read" do
243
243
  @redisMock.should_receive(:get_value).with('test_commands:1:foo')
244
244
  @x.foo
245
245
  end
246
-
246
+
247
247
  it "should send SET on field write" do
248
248
  @redisMock.should_receive(:put_value).with('test_commands:1:foo', 'bar')
249
249
  @x.foo = 'bar'
250
250
  end
251
-
251
+
252
252
  it "should send RPUSH on list <<" do
253
253
  @redisDbMock.should_receive(:rpush).with('test_commands:1:bar', 'bar')
254
254
  @x.bar << 'bar'
255
255
  end
256
-
256
+
257
257
  it "should send SADD on set <<" do
258
258
  @redisDbMock.should_receive(:sadd).with('test_commands:1:sloppy', 'bar')
259
259
  @x.sloppy << 'bar'
260
260
  end
261
-
261
+
262
262
  it "should delete separate fields" do
263
263
  @redisMock.should_receive(:delete_value).with('test_commands:1:foo')
264
264
  @x.delete :foo
265
265
  end
266
-
266
+
267
267
  it "should delete all field" do
268
268
  @redisMock.should_receive(:delete_value).with('test_commands:1:foo')
269
269
  @redisMock.should_receive(:delete_value).with('test_commands:1:rho__id')