hit_counter 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hit_counter"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roderick Monje"]
12
- s.date = "2011-09-25"
12
+ s.date = "2011-09-30"
13
13
  s.email = "rod@seologic.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -61,6 +61,16 @@ class HitCounter
61
61
 
62
62
  # Instance methods: Overrides ====================================================================
63
63
 
64
+ # Sets the number of hits.
65
+ #
66
+ # * *Args*
67
+ # - +value+ -> the number of hits
68
+ # * *Returns*
69
+ # - the value
70
+ def hits= value
71
+ self[:hits] = value.to_i
72
+ end
73
+
64
74
  # Sets the URL to be tracked. The http prefix is optional.
65
75
  #
66
76
  # * *Args*
@@ -8,13 +8,15 @@ describe HitCounter do
8
8
 
9
9
  describe '#get' do
10
10
  context 'when existing URL' do
11
+ before { @hit_counter2 = HitCounter.get @hit_counter.url, 10 }
12
+
11
13
  describe 'document count' do
12
14
  specify { HitCounter.count.should == 1 }
13
15
  end
14
16
 
15
17
  context 'with starting count 10' do
16
18
  describe 'hits' do
17
- specify { HitCounter.get(@hit_counter.url, 10).hits.should == 0 }
19
+ specify { @hit_counter2.hits.should == 0 }
18
20
  end
19
21
  end
20
22
  end
@@ -26,9 +28,15 @@ describe HitCounter do
26
28
  specify { HitCounter.count.should == 2 }
27
29
  end
28
30
 
31
+ context 'with blank starting count' do
32
+ describe '#hits' do
33
+ specify { HitCounter.get('www.nytimes.com', nil).hits.should == 0 }
34
+ end
35
+ end
36
+
29
37
  context 'with starting count 10' do
30
- describe 'hits' do
31
- specify { HitCounter.get('www.nytimes.com', 10).hits.should == 10 }
38
+ describe '#hits' do
39
+ specify { HitCounter.get('online.wsj.com', 10).hits.should == 10 }
32
40
  end
33
41
  end
34
42
  end
@@ -54,10 +62,12 @@ describe HitCounter do
54
62
  end
55
63
 
56
64
  describe '#normalize_style_number' do
57
- context 'when undefined' do
58
- it 'should return 0' do
59
- HitCounter.normalize_style_number(nil).should == 0
60
- end
65
+ context 'when nil' do
66
+ it { HitCounter.normalize_style_number(nil).should be_zero }
67
+ end
68
+
69
+ context 'when empty string' do
70
+ it { HitCounter.normalize_style_number('').should be_zero }
61
71
  end
62
72
 
63
73
  context 'when within range' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hit_counter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roderick Monje
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-25 00:00:00 Z
18
+ date: 2011-09-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: addressable