ki 0.4.11 → 0.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +9 -0
  4. data/.ruby-gemset +1 -1
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +10 -2
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +95 -85
  9. data/Guardfile +20 -14
  10. data/MIDDLEWARE.md +2 -2
  11. data/README.md +29 -1
  12. data/Rakefile +3 -1
  13. data/bin/ki +1 -0
  14. data/ki.gemspec +15 -14
  15. data/lib/ki.rb +8 -1
  16. data/lib/ki/base_request.rb +7 -5
  17. data/lib/ki/channel_manager.rb +2 -0
  18. data/lib/ki/helpers.rb +4 -5
  19. data/lib/ki/ki.rb +11 -2
  20. data/lib/ki/ki_app.rb +2 -0
  21. data/lib/ki/ki_cli.rb +9 -2
  22. data/lib/ki/ki_config.rb +5 -2
  23. data/lib/ki/ki_logger.rb +15 -0
  24. data/lib/ki/middleware/admin_interface_generator.rb +3 -1
  25. data/lib/ki/middleware/api_handler.rb +3 -1
  26. data/lib/ki/middleware/base_middleware.rb +2 -0
  27. data/lib/ki/middleware/coffee_compiler.rb +2 -0
  28. data/lib/ki/middleware/haml_compiler.rb +2 -0
  29. data/lib/ki/middleware/helpers/format_of_helper.rb +3 -1
  30. data/lib/ki/middleware/helpers/haml_compiler_helper.rb +7 -5
  31. data/lib/ki/middleware/helpers/public_file_helper.rb +2 -0
  32. data/lib/ki/middleware/helpers/redirect_to_helper.rb +2 -0
  33. data/lib/ki/middleware/helpers/view_helper.rb +2 -0
  34. data/lib/ki/middleware/init_middleware.rb +2 -0
  35. data/lib/ki/middleware/{doc_generator.rb → insta_doc.rb} +8 -6
  36. data/lib/ki/middleware/public_file_server.rb +2 -0
  37. data/lib/ki/middleware/realtime.rb +3 -1
  38. data/lib/ki/middleware/sass_compiler.rb +2 -0
  39. data/lib/ki/model.rb +8 -7
  40. data/lib/ki/modules/callbacks.rb +12 -20
  41. data/lib/ki/modules/model_helper.rb +2 -0
  42. data/lib/ki/modules/query_interface.rb +2 -0
  43. data/lib/ki/modules/restrictions.rb +5 -2
  44. data/lib/ki/orm.rb +20 -13
  45. data/lib/ki/utils/annotations.rb +33 -0
  46. data/lib/ki/utils/api_error.rb +14 -4
  47. data/lib/ki/utils/descendants.rb +9 -0
  48. data/lib/ki/utils/extra_irb.rb +3 -1
  49. data/lib/ki/utils/extra_ruby.rb +12 -0
  50. data/lib/ki/utils/indifferent_hash.rb +2 -0
  51. data/lib/ki/utils/logger.rb +5 -0
  52. data/lib/ki/version.rb +3 -1
  53. data/lib/ki/views/instadoc.haml +49 -9
  54. data/spec/config.yml.example +1 -1
  55. data/spec/examples/base/client.rb +20 -0
  56. data/spec/examples/base/logs/.keep +0 -0
  57. data/spec/examples/base/public/javascripts/app.js +12 -0
  58. data/spec/examples/json.northpole.ro/.ruby-version +1 -1
  59. data/spec/examples/json.northpole.ro/public/javascripts/app.coffee +1 -0
  60. data/spec/functional_spec.rb +2 -0
  61. data/spec/lib/ki/base_request_spec.rb +25 -23
  62. data/spec/lib/ki/channel_manager_spec.rb +2 -0
  63. data/spec/lib/ki/helpers_spec.rb +4 -2
  64. data/spec/lib/ki/indifferent_hash_spec.rb +2 -0
  65. data/spec/lib/ki/ki_app_spec.rb +2 -0
  66. data/spec/lib/ki/ki_config_spec.rb +5 -3
  67. data/spec/lib/ki/ki_spec.rb +2 -0
  68. data/spec/lib/ki/middleware/admin_generator_spec.rb +2 -0
  69. data/spec/lib/ki/middleware/haml_compiler_spec.rb +6 -3
  70. data/spec/lib/ki/middleware/helpers/format_of_helper_spec.rb +4 -2
  71. data/spec/lib/ki/middleware/init_middleware_spec.rb +3 -1
  72. data/spec/lib/ki/middleware/{doc_generator_spec.rb → insta_doc_spec.rb} +3 -1
  73. data/spec/lib/ki/middleware/realtime_spec.rb +12 -6
  74. data/spec/lib/ki/middleware_spec.rb +3 -1
  75. data/spec/lib/ki/model_spec.rb +26 -22
  76. data/spec/lib/ki/modules/model_helper_spec.rb +5 -3
  77. data/spec/lib/ki/modules/restrictions_spec.rb +16 -0
  78. data/spec/lib/ki/orm_spec.rb +18 -15
  79. data/spec/lib/ki/utils/api_error_spec.rb +9 -0
  80. data/spec/spec_helper.rb +13 -7
  81. data/spec/util_spec.rb +3 -1
  82. metadata +44 -30
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::ChannelManager do
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Helpers do
4
6
  include Ki::Helpers
5
7
 
6
8
  it 'should render_haml' do
7
- haml('%div.foo').should == "<div class='foo'></div>\n"
9
+ expect(haml('%div.foo')).to eq "<div class='foo'></div>\n"
8
10
  end
9
11
 
10
12
  it 'renders css tag' do
@@ -22,7 +24,7 @@ describe Ki::Helpers do
22
24
  end
23
25
 
24
26
  it 'renders haml' do
25
- File.stub(:join).and_return('lib/ki/views/404.haml')
27
+ expect(File).to receive(:join).and_return('lib/ki/views/404.haml')
26
28
  expect(partial('404')).to include('h1')
27
29
  end
28
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe IndifferentHash do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::KiApp do
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::KiConfig do
4
6
  let(:config) { Ki::KiConfig.instance }
5
7
 
6
8
  it 'should know db name in test env' do
7
- config.environment.should == 'test'
9
+ expect(config.environment).to eq 'test'
8
10
  end
9
11
 
10
12
  it 'is overwritten for testing. see spec_helper' do
11
13
  path = config.config_file_path
12
- path.start_with?('spec/config.yml').should be true
14
+ expect(path).to be_start_with('spec/config.yml')
13
15
  end
14
16
 
15
17
  it 'defaults cors to true' do
@@ -48,7 +50,7 @@ describe Ki::KiConfig do
48
50
  end
49
51
 
50
52
  it 'does not add duplicate middleware' do
51
- config.config['add_middleware'] = %w(Realtime Realtime)
53
+ config.config['add_middleware'] = %w[Realtime Realtime]
52
54
  expect(config.middleware.to_s.scan(/Realtime/).count).to eq 1
53
55
  end
54
56
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Ki do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Middleware::AdminInterfaceGenerator do
@@ -1,17 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Middleware::HamlCompiler do
4
6
  let(:compiler) { Ki::Middleware::HamlCompiler }
5
7
 
6
8
  it 'works' do
7
- compiler.any_instance.stub(:view_exists?).and_return(true)
8
- File.stub(:read).and_return('%p hello')
9
+ # TODO: find out why twice
10
+ expect_any_instance_of(compiler).to receive(:view_exists?).twice.and_return(true)
11
+ expect(File).to receive(:read).twice.and_return('%p hello')
9
12
  get '/existing_haml'
10
13
  expect(last_response.body).to eq "<p>hello</p>\n"
11
14
  end
12
15
 
13
16
  it 'passes to next middleware' do
14
- compiler.any_instance.stub(:view_exists?).and_return(false)
17
+ expect_any_instance_of(compiler).to receive(:view_exists?).and_return(false)
15
18
  get '/inexisting_haml'
16
19
  expect(last_response.body).to eq '<h1>404</h1>'
17
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Middleware::Helpers::FormatOf do
@@ -8,11 +10,11 @@ describe Ki::Middleware::Helpers::FormatOf do
8
10
 
9
11
  it 'should parse url format' do
10
12
  [nil, {}, '', '.json'].each do |s|
11
- obj.format_of(s).should == ''
13
+ expect(obj.format_of(s)).to eq ''
12
14
  end
13
15
 
14
16
  ['asd.json', 'asd.json?asd=1'].each do |s|
15
- obj.format_of(s).should == 'json'
17
+ expect(obj.format_of(s)).to eq 'json'
16
18
  end
17
19
  end
18
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Middleware::InitMiddleware do
@@ -14,7 +16,7 @@ describe Ki::Middleware::InitMiddleware do
14
16
  it 'renders index.html if it exists' do
15
17
  env = Rack::MockRequest.env_for('/', { 'REQUEST_METHOD' => 'GET' })
16
18
 
17
- Ki::Middleware::InitMiddleware.any_instance.stub(:public_file_exists?).and_return(true)
19
+ expect_any_instance_of(Ki::Middleware::InitMiddleware).to receive(:public_file_exists?).and_return(true)
18
20
  resp = init.call env
19
21
  expect(resp[0]).to eq 404 # not found because index.html doesn't exist
20
22
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe Ki::Middleware::DocGenerator do
5
+ describe Ki::Middleware::InstaDoc do
4
6
  it 'works' do
5
7
  get '/instadoc'
6
8
  expect(last_response.body).to include('Ki InstaDoc')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  # TODO: find a way to test
@@ -18,8 +20,10 @@ describe Ki::Middleware::Realtime do
18
20
  it 'handle_websocket' do
19
21
  env = Rack::MockRequest.env_for('/realtime', { 'REQUEST_METHOD' => 'GET' })
20
22
 
21
- Ki::Middleware::Realtime.any_instance.stub(:handle_websocket).and_return('handle_websocket')
22
- Faye::WebSocket.stub(:websocket?).and_return(true)
23
+ # Ki::Middleware::Realtime.any_instance.stub(:handle_websocket).and_return('handle_websocket')
24
+ # Faye::WebSocket.stub(:websocket?).and_return(true)
25
+ expect_any_instance_of(Ki::Middleware::Realtime).to receive(:handle_websocket).and_return('handle_websocket')
26
+ expect(Faye::WebSocket).to receive(:websocket?).and_return(true)
23
27
 
24
28
  resp = realtime.call env
25
29
  expect(resp).to eq 'handle_websocket'
@@ -27,15 +31,17 @@ describe Ki::Middleware::Realtime do
27
31
 
28
32
  it 'continues call' do
29
33
  env = Rack::MockRequest.env_for('/bazinga', { 'REQUEST_METHOD' => 'GET' })
30
- Hash.any_instance.stub(:call).and_return('continue')
34
+ expect_any_instance_of(Hash).to receive(:call).and_return('continue')
35
+ # Hash.any_instance.stub(:call).and_return('continue')
31
36
  resp = realtime.call env
32
37
  expect(resp).to eq 'continue'
33
38
  end
34
39
 
35
40
  it 'has ws_send' do
36
41
  ws = {}
37
- ws.stub(:send).and_return true
38
- expect(realtime.ws_send(ws, {})).to be_true
42
+ expect(ws).to receive(:send).and_return(true)
43
+ # ws.stub(:send).and_return true
44
+ expect(realtime.ws_send(ws, {})).to be true
39
45
  end
40
46
 
41
47
  describe 'on_message' do
@@ -43,7 +49,7 @@ describe Ki::Middleware::Realtime do
43
49
  let(:db) { Ki::Orm::Db.instance }
44
50
 
45
51
  before :each do
46
- realtime.stub(:ws_send) do |_arg1, arg2|
52
+ allow(realtime).to receive(:ws_send) do |_arg1, arg2|
47
53
  arg2
48
54
  end
49
55
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Middleware do
@@ -5,7 +7,7 @@ describe Ki::Middleware do
5
7
  it 'should only handle urls maped from objects that extend Ki::Model' do
6
8
  get '/asd.json'
7
9
  json
8
- last_response.status.should == 404
10
+ expect(last_response.status).to eq 404
9
11
  end
10
12
  end
11
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Model do
@@ -6,20 +8,20 @@ describe Ki::Model do
6
8
  class Bar < Ki::Model; end
7
9
  end
8
10
 
9
- it 'should know about all descendants' do
11
+ it 'knows about descendants' do
10
12
  desc = Ki::Model.descendants
11
- desc.include?(Foo).should be_true
12
- desc.include?(Bar).should be_true
13
+ expect(desc).to include(Foo)
14
+ expect(desc).to include(Bar)
13
15
  end
14
16
 
15
17
  context Ki::Model::QueryInterface do
16
18
  it 'should have the query interface' do
17
- Foo.class_name.should eq 'Foo'
19
+ expect(Foo.class_name).to eq 'Foo'
18
20
  expect do
19
21
  id = Foo.create({ hello: 'world' })['id']
20
- Foo.find(id).first['hello'].should eq 'world'
22
+ expect(Foo.find(id).first['hello']).to eq 'world'
21
23
  Foo.update('id' => id, 'hello' => 'universe')
22
- Foo.find(id).first['hello'].should eq 'universe'
24
+ expect(Foo.find(id).first['hello']).to eq 'universe'
23
25
  Foo.delete(id)
24
26
  end.to change { Foo.count }.by 0
25
27
  end
@@ -34,9 +36,9 @@ describe Ki::Model do
34
36
  end
35
37
 
36
38
  it 'should have restrictions configured' do
37
- Bar.unique_attributes.should eq []
38
- Bar.required_attributes.should eq []
39
- Bar.forbidden_actions.should eq []
39
+ expect(Bar.unique_attributes).to eq []
40
+ expect(Bar.required_attributes).to eq []
41
+ expect(Bar.forbidden_actions).to eq []
40
42
 
41
43
  class Bar < Ki::Model
42
44
  unique :foo
@@ -44,9 +46,9 @@ describe Ki::Model do
44
46
  forbid :delete
45
47
  end
46
48
 
47
- Bar.unique_attributes.should eq [:foo]
48
- Bar.required_attributes.should eq [:foo]
49
- Bar.forbidden_actions.should eq [:delete]
49
+ expect(Bar.unique_attributes).to eq [:foo]
50
+ expect(Bar.required_attributes).to eq [:foo]
51
+ expect(Bar.forbidden_actions).to eq [:delete]
50
52
  end
51
53
 
52
54
  context 'default properties' do
@@ -55,8 +57,10 @@ describe Ki::Model do
55
57
 
56
58
  it 'should create object' do
57
59
  mock_req = {}
58
- mock_req.stub(:to_action).and_return(:create)
59
- mock_req.stub(:params).and_return({})
60
+ expect(mock_req).to receive(:to_action).and_return(:create)
61
+ # mock_req.stub(:to_action).and_return(:create)
62
+ # mock_req.stub(:params).and_return({})
63
+ expect(mock_req).to receive(:params).and_return({})
60
64
 
61
65
  expect {
62
66
  DefaultProperties.new(mock_req)
@@ -78,8 +82,8 @@ describe Ki::Model do
78
82
  SpecialProperties.delete({ 'foo' => t })
79
83
 
80
84
  mock_req = {}
81
- mock_req.stub(:to_action).and_return(:create)
82
- mock_req.stub(:params).and_return('name' => 'zim', 'foo' => t)
85
+ expect(mock_req).to receive(:to_action).and_return(:create)
86
+ expect(mock_req).to receive(:params).and_return('name' => 'zim', 'foo' => t)
83
87
 
84
88
  expect {
85
89
  SpecialProperties.new(mock_req)
@@ -88,8 +92,8 @@ describe Ki::Model do
88
92
 
89
93
  it 'should check for required attributes' do
90
94
  mock_req = {}
91
- mock_req.stub(:to_action).and_return(:create)
92
- mock_req.stub(:params).and_return({})
95
+ expect(mock_req).to receive(:to_action).and_return(:create)
96
+ expect(mock_req).to receive(:params).and_return({})
93
97
 
94
98
  expect {
95
99
  SpecialProperties.new(mock_req)
@@ -99,8 +103,8 @@ describe Ki::Model do
99
103
  it 'should check for unique attributes' do
100
104
  t = Time.now.to_i
101
105
  mock_req = {}
102
- mock_req.stub(:to_action).and_return(:create)
103
- mock_req.stub(:params).and_return({ 'name' => 'zim', 'foo' => t })
106
+ expect(mock_req).to receive(:to_action).and_return(:create)
107
+ expect(mock_req).to receive(:params).and_return({ 'name' => 'zim', 'foo' => t })
104
108
 
105
109
  expect {
106
110
  SpecialProperties.new(mock_req)
@@ -110,8 +114,8 @@ describe Ki::Model do
110
114
 
111
115
  it 'should not allow forbidden actions' do
112
116
  mock_req = {}
113
- mock_req.stub(:to_action).and_return(:delete)
114
- mock_req.stub(:params).and_return({})
117
+ expect(mock_req).to receive(:to_action).and_return(:delete)
118
+ expect(mock_req).to receive(:params).and_return({})
115
119
 
116
120
  expect {
117
121
  SpecialProperties.new(mock_req)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Model::ModelHelper do
@@ -28,8 +30,8 @@ describe Ki::Model::ModelHelper do
28
30
  end
29
31
 
30
32
  @req = TmpClassModelHelper.new
31
- expect(post?).to be_true
32
- expect(put?).to be_true
33
- expect(delete?).to be_true
33
+ expect(post?).to be true
34
+ expect(put?).to be true
35
+ expect(delete?).to be true
34
36
  end
35
37
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Ki::Model::Restrictions do
6
+ before :all do
7
+ class DoubleRestricted < Ki::Model
8
+ requires :foo, :cez
9
+ requires :bar
10
+ end
11
+ end
12
+
13
+ it 'merges multiple generic_restrictions' do
14
+ expect(DoubleRestricted.required_attributes).to eq %i[foo bar cez].sort
15
+ end
16
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Ki::Orm do
@@ -6,7 +8,7 @@ describe Ki::Orm do
6
8
  end
7
9
 
8
10
  it 'should know db name in test env' do
9
- @db.config['name'].should == 'np_test'
11
+ expect(@db.config['name']).to eq 'np_test'
10
12
  end
11
13
 
12
14
  it 'has a connection string' do
@@ -16,7 +18,7 @@ describe Ki::Orm do
16
18
  it 'should create a db object' do
17
19
  expect {
18
20
  oid = @db.insert 'foo', { hello: 'world' }
19
- oid.class.should == Hash
21
+ expect(oid).to be_a(Hash)
20
22
  }.to change { @db.count('foo') }.by(1)
21
23
  end
22
24
 
@@ -39,28 +41,29 @@ describe Ki::Orm do
39
41
  it 'should find all' do
40
42
  @db.insert 'foo', { hello: 'world' }
41
43
  @db.insert 'foo', { hello: 'world' }
42
- @db.find('foo').to_a.size.should >= 2
44
+ expect(@db.find('foo').to_a.size).to be >= 2
43
45
  end
44
46
 
45
47
  it 'should find by string id' do
46
48
  obj_id = @db.insert('foo', { hello: 'world' })['id']
47
- @db.find('foo', obj_id).first['id'].should eq obj_id
49
+ expect(@db.find('foo', obj_id).first['id']).to eq obj_id
48
50
  end
49
51
 
50
52
  it 'should find by hash["id"]' do
51
- obj_id = @db.insert 'foo', { 'hello' => 'world' }
52
- @db.find('foo', { 'id' => obj_id['id'] }).first.should eq obj_id
53
+ obj_id = @db.insert('foo', { 'hello' => 'world' })['id']
54
+ find_query = @db.find('foo', { 'id' => obj_id })
55
+ expect(find_query.first['id']).to eq obj_id
53
56
  end
54
57
 
55
58
  it 'should find by hash["_id"]' do
56
59
  obj_id = @db.insert('foo', { hello: 'world' })['id']
57
- @db.find('foo', { '_id' => obj_id }).first['id'].should eq obj_id
60
+ expect(@db.find('foo', { '_id' => obj_id }).first['id']).to eq obj_id
58
61
  end
59
62
 
60
63
  it 'should find by BSON::ObjectId(id)' do
61
64
  obj_id = @db.insert('foo', { 'hello' => 'world' })['id']
62
- @db.find('foo', { 'id' => BSON::ObjectId(obj_id) }).first['id'].should eq obj_id
63
- @db.find('foo', { '_id' => BSON::ObjectId(obj_id) }).first['id'].should eq obj_id
65
+ expect(@db.find('foo', { 'id' => BSON::ObjectId(obj_id) }).first['id']).to eq obj_id
66
+ expect(@db.find('foo', { '_id' => BSON::ObjectId(obj_id) }).first['id']).to eq obj_id
64
67
  end
65
68
 
66
69
  it 'should return empty array when nothing found' do
@@ -75,12 +78,12 @@ describe Ki::Orm do
75
78
  @db.insert('sort_tests', { 'value' => 1 })
76
79
  @db.insert('sort_tests', { 'value' => 2 })
77
80
 
78
- r = @db.find('sort_tests', { '__sort' => { 'value' => 'desc' } })
81
+ r = @db.find('sort_tests', { '__sort' => { 'value' => -1 } })
79
82
  expect(r.size).to eq 2
80
83
  expect(r[0]['value']).to eq 2
81
84
  expect(r[1]['value']).to eq 1
82
85
 
83
- r = @db.find('sort_tests', { '__sort' => { 'value' => 'asc' } })
86
+ r = @db.find('sort_tests', { '__sort' => { 'value' => 1 } })
84
87
  expect(r.size).to eq 2
85
88
  expect(r[0]['value']).to eq 1
86
89
  expect(r[1]['value']).to eq 2
@@ -98,16 +101,16 @@ describe Ki::Orm do
98
101
 
99
102
  it 'should update' do
100
103
  obj_id = @db.insert('foo', { 'hello' => 'world' })['id']
101
- @db.find('foo', obj_id).first['hello'].should eq 'world'
104
+ expect(@db.find('foo', obj_id).first['hello']).to eq 'world'
102
105
  up = @db.update('foo', { 'id' => obj_id, 'hello' => 'universe' })['id']
103
- up.should eq obj_id
104
- @db.find('foo', obj_id).first['hello'].should eq 'universe'
106
+ expect(up).to eq obj_id
107
+ expect(@db.find('foo', obj_id).first['hello']).to eq 'universe'
105
108
  end
106
109
 
107
110
  it 'should delete by id' do
108
111
  obj_id = @db.insert 'foo', { 'hello' => 'world' }
109
112
  expect {
110
- @db.delete('foo', obj_id).should == { deleted_item_count: 1 }
113
+ expect(@db.delete('foo', obj_id)).to eq({ deleted_item_count: 1 })
111
114
  }.to change { @db.count 'foo' }.by(-1)
112
115
  end
113
116
  end