memcache_mock 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d5a06c40518052a8c93e09fed496baae5cf0c1e
4
+ data.tar.gz: abbc0a1a65001bc248f7b474e108a0d160e6744c
5
+ SHA512:
6
+ metadata.gz: 5158bd5f6107aeb7eddbbad07d247f723e3cb10c60ca1bc1d6956fd08f7460028989b04e75af1ef7e1011df912ab0a3df0d9943f4f1d8fb735cdb0131a568223
7
+ data.tar.gz: bfb568ef3e052c5d01b2eee7e963d66b56b4394d831cc41f13f968ad8cfa61f6139b1c34cfa3223c59bab48e697e68fe20f32d70e20cfb916c26333d2dd90565
@@ -13,6 +13,14 @@ class MemcacheMock
13
13
  end
14
14
  end
15
15
 
16
+ def decr( key, value, ttl, default_value)
17
+ if @values[key]
18
+ substract( key, value )
19
+ else
20
+ @values[key] = default_value
21
+ end
22
+ end
23
+
16
24
  def get( key )
17
25
  @values.fetch(key, nil)
18
26
  end
@@ -36,6 +44,12 @@ class MemcacheMock
36
44
  end
37
45
  end
38
46
 
47
+ def substract( key, value )
48
+ if @values[key]
49
+ @values[key] -= value
50
+ end
51
+ end
52
+
39
53
  def delete(key)
40
54
  @values.delete(key)
41
55
  end
@@ -1,3 +1,3 @@
1
1
  class MemcacheMock
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -22,6 +22,18 @@ class MemcacheMockTest < Test::Unit::TestCase
22
22
  @cache.incr( "key", "value", nil, nil )
23
23
  end
24
24
 
25
+ def test_decr_when_key_not_exists
26
+ @cache.decr( "key", "value", nil, "default_value" )
27
+ assert_equal( "default_value", @cache.get( "key" ))
28
+ end
29
+
30
+ def test_decr
31
+ @cache.set( "key", "original_value" )
32
+ @cache.expects( :substract ).with( "key", "value" )
33
+
34
+ @cache.decr( "key", "value", nil, nil )
35
+ end
36
+
25
37
  def test_get_when_key_not_exists
26
38
  assert_equal( nil, @cache.get( "key" ) )
27
39
  end
@@ -65,6 +77,13 @@ class MemcacheMockTest < Test::Unit::TestCase
65
77
  assert_equal( "value1|value2", @cache.get( "key" ) )
66
78
  end
67
79
 
80
+ def test_substract
81
+ @cache.set( "key", 7 )
82
+ @cache.substract( "key", 5 )
83
+
84
+ assert_equal( 2, @cache.get( "key" ) )
85
+ end
86
+
68
87
  def test_fetch
69
88
  assert_equal( nil, @cache.fetch( "key0" ) )
70
89
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memcache_mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
5
- prerelease:
4
+ version: 0.0.14
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fernando Guillen
@@ -10,41 +9,50 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-11-26 00:00:00.000000000Z
12
+ date: 2013-12-17 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bundler
17
- requirement: &70178050682660 !ruby/object:Gem::Requirement
18
- none: false
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: 1.0.21
23
21
  type: :development
24
22
  prerelease: false
25
- version_requirements: *70178050682660
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.0.21
26
28
  - !ruby/object:Gem::Dependency
27
29
  name: rake
28
- requirement: &70178050682160 !ruby/object:Gem::Requirement
29
- none: false
30
+ requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - =
32
+ - - '='
32
33
  - !ruby/object:Gem::Version
33
34
  version: 0.9.2.2
34
35
  type: :development
35
36
  prerelease: false
36
- version_requirements: *70178050682160
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 0.9.2.2
37
42
  - !ruby/object:Gem::Dependency
38
43
  name: mocha
39
- requirement: &70178050681700 !ruby/object:Gem::Requirement
40
- none: false
44
+ requirement: !ruby/object:Gem::Requirement
41
45
  requirements:
42
- - - =
46
+ - - '='
43
47
  - !ruby/object:Gem::Version
44
48
  version: 0.10.0
45
49
  type: :development
46
50
  prerelease: false
47
- version_requirements: *70178050681700
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 0.10.0
48
56
  description: Simple key/value mocked storage system
49
57
  email:
50
58
  - fguillen.mail@gmail.com
@@ -66,27 +74,26 @@ files:
66
74
  - test/test_helper.rb
67
75
  homepage: https://github.com/fguillen/MemcacheMock
68
76
  licenses: []
77
+ metadata: {}
69
78
  post_install_message:
70
79
  rdoc_options: []
71
80
  require_paths:
72
81
  - lib
73
82
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
83
  requirements:
76
- - - ! '>='
84
+ - - '>='
77
85
  - !ruby/object:Gem::Version
78
86
  version: '0'
79
87
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
88
  requirements:
82
- - - ! '>='
89
+ - - '>='
83
90
  - !ruby/object:Gem::Version
84
91
  version: '0'
85
92
  requirements: []
86
93
  rubyforge_project: memcache_mock
87
- rubygems_version: 1.8.15
94
+ rubygems_version: 2.0.3
88
95
  signing_key:
89
- specification_version: 3
96
+ specification_version: 4
90
97
  summary: Simple key/value mocked storage system
91
98
  test_files:
92
99
  - test/memcache_mock_test.rb