-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_item_spec.rb
46 lines (39 loc) · 1.43 KB
/
update_item_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'aws-sdk-dynamodb'
RSpec.describe 'update_item' do
it 'edits an item in-place' do
young_anand = {
'name': 'Vishy',
'speed': 'lightning fast'
}
recreate_table('chess_players', 'name', 'S')
client = Aws::DynamoDB::Client.new(connection_info)
client.put_item({
table_name: 'chess_players',
item: young_anand
})
response = client.get_item({
table_name: 'chess_players',
key: {
'name': 'Vishy'
}
})
expect(response.item['speed']).to eql('lightning fast')
client.update_item({
table_name: 'chess_players',
key: {
'name': 'Vishy'
},
update_expression: "SET speed = :v_speed",
expression_attribute_values: {
':v_speed': 'sedate'
}
})
new_response = client.get_item({
table_name: 'chess_players',
key: {
'name': 'Vishy'
}
})
expect(new_response.item['speed']).to eql('sedate')
end
end