punching_bag 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/punch.rb +1 -1
- data/lib/punching_bag/version.rb +1 -1
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/log/test.log +4255 -0
- data/spec/lib/punching_bag_spec.rb +2 -2
- data/spec/models/punch_spec.rb +26 -17
- data/spec/spec_helper.rb +2 -2
- metadata +60 -39
@@ -9,7 +9,7 @@ describe PunchingBag do
|
|
9
9
|
|
10
10
|
describe '.punch' do
|
11
11
|
it 'does nothing when the request is from a bot' do
|
12
|
-
expect(PunchingBag.punch(article, bot_request)).to
|
12
|
+
expect(PunchingBag.punch(article, bot_request)).to be false
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'creates a new punch when the request is valid' do
|
@@ -30,4 +30,4 @@ describe PunchingBag do
|
|
30
30
|
expect(PunchingBag.average_time(punch_1, punch_2)).to eql (time + 25.seconds)
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end
|
data/spec/models/punch_spec.rb
CHANGED
@@ -14,50 +14,59 @@ describe Punch do
|
|
14
14
|
|
15
15
|
context 'with one hit' do
|
16
16
|
its(:hits) { should eql 1 }
|
17
|
-
its(:jab?) { should
|
18
|
-
its(:combo?) { should
|
17
|
+
its(:jab?) { should be true }
|
18
|
+
its(:combo?) { should be false }
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'with two hits' do
|
22
22
|
let(:attrs) { {hits: 2} }
|
23
23
|
|
24
24
|
its(:hits) { should eql 2 }
|
25
|
-
its(:jab?) { should
|
26
|
-
its(:combo?) { should
|
25
|
+
its(:jab?) { should be false }
|
26
|
+
its(:combo?) { should be true }
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'with start time same as end time' do
|
30
30
|
its(:timeframe) { should eql :second }
|
31
|
-
its(:day_combo?) { should
|
32
|
-
its(:month_combo?) { should
|
33
|
-
its(:year_combo?) { should
|
31
|
+
its(:day_combo?) { should be false }
|
32
|
+
its(:month_combo?) { should be false }
|
33
|
+
its(:year_combo?) { should be false }
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'with start time in the same day as end time' do
|
37
37
|
let(:attrs) { {starts_at: day + 1.hour, ends_at: day + 2.hours } }
|
38
38
|
|
39
39
|
its(:timeframe) { should eql :day }
|
40
|
-
its(:day_combo?) { should
|
41
|
-
its(:month_combo?) { should
|
42
|
-
its(:year_combo?) { should
|
40
|
+
its(:day_combo?) { should be true }
|
41
|
+
its(:month_combo?) { should be false }
|
42
|
+
its(:year_combo?) { should be false }
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'with start time in the same month as end time' do
|
46
46
|
let(:attrs) { {starts_at: month + 1.day, ends_at: month + 2.days } }
|
47
47
|
|
48
48
|
its(:timeframe) { should eql :month }
|
49
|
-
its(:day_combo?) { should
|
50
|
-
its(:month_combo?) { should
|
51
|
-
its(:year_combo?) { should
|
49
|
+
its(:day_combo?) { should be false }
|
50
|
+
its(:month_combo?) { should be true }
|
51
|
+
its(:year_combo?) { should be false }
|
52
52
|
end
|
53
53
|
|
54
54
|
context 'with start time in the same year as end time' do
|
55
55
|
let(:attrs) { {starts_at: year + 1.month, ends_at: year + 2.months } }
|
56
56
|
|
57
57
|
its(:timeframe) { should eql :year }
|
58
|
-
its(:day_combo?) { should
|
59
|
-
its(:month_combo?) { should
|
60
|
-
its(:year_combo?) { should
|
58
|
+
its(:day_combo?) { should be false }
|
59
|
+
its(:month_combo?) { should be false }
|
60
|
+
its(:year_combo?) { should be true }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with only one punch on a day' do
|
64
|
+
let(:other_punch) { nil }
|
65
|
+
before { punch.save! }
|
66
|
+
|
67
|
+
describe '#combine_with' do
|
68
|
+
it { expect { punch.combine_with other_punch }.to_not change { Punch.count } }
|
69
|
+
end
|
61
70
|
end
|
62
71
|
|
63
72
|
context 'with another punch on the same day' do
|
@@ -95,4 +104,4 @@ describe Punch do
|
|
95
104
|
end
|
96
105
|
end
|
97
106
|
end
|
98
|
-
end
|
107
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,11 +8,11 @@ Bundler.require :default
|
|
8
8
|
Combustion.initialize! :active_record
|
9
9
|
|
10
10
|
require 'rspec/rails'
|
11
|
-
require 'rspec/
|
11
|
+
require 'rspec/its'
|
12
12
|
|
13
13
|
require 'active_support/time'
|
14
14
|
require 'ostruct'
|
15
15
|
|
16
16
|
RSpec.configure do |config|
|
17
17
|
config.use_transactional_fixtures = true
|
18
|
-
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,99 +1,119 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: punching_bag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Crownoble
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.2'
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- - "~>"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
32
|
+
version: '4.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: voight_kampff
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- -
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2
|
39
|
+
version: '0.2'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- -
|
44
|
+
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2
|
46
|
+
version: '0.2'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: activerecord
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - ~>
|
51
|
+
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: 4.0
|
53
|
+
version: '4.0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - ~>
|
58
|
+
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.0
|
60
|
+
version: '4.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: combustion
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- -
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.5'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.5'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec-its
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
60
80
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
81
|
+
version: '1.0'
|
62
82
|
type: :development
|
63
83
|
prerelease: false
|
64
84
|
version_requirements: !ruby/object:Gem::Requirement
|
65
85
|
requirements:
|
66
|
-
- -
|
86
|
+
- - "~>"
|
67
87
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
88
|
+
version: '1.0'
|
69
89
|
- !ruby/object:Gem::Dependency
|
70
90
|
name: rspec-rails
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
72
92
|
requirements:
|
73
|
-
- -
|
93
|
+
- - "~>"
|
74
94
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
95
|
+
version: '3.0'
|
76
96
|
type: :development
|
77
97
|
prerelease: false
|
78
98
|
version_requirements: !ruby/object:Gem::Requirement
|
79
99
|
requirements:
|
80
|
-
- -
|
100
|
+
- - "~>"
|
81
101
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
102
|
+
version: '3.0'
|
83
103
|
- !ruby/object:Gem::Dependency
|
84
104
|
name: sqlite3
|
85
105
|
requirement: !ruby/object:Gem::Requirement
|
86
106
|
requirements:
|
87
|
-
- -
|
107
|
+
- - "~>"
|
88
108
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
109
|
+
version: '1.3'
|
90
110
|
type: :development
|
91
111
|
prerelease: false
|
92
112
|
version_requirements: !ruby/object:Gem::Requirement
|
93
113
|
requirements:
|
94
|
-
- -
|
114
|
+
- - "~>"
|
95
115
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
116
|
+
version: '1.3'
|
97
117
|
description: PunchingBag is a hit counting and simple trending engine for Ruby on
|
98
118
|
Rails
|
99
119
|
email: adam@obledesign.com
|
@@ -103,23 +123,23 @@ extra_rdoc_files: []
|
|
103
123
|
files:
|
104
124
|
- MIT-LICENSE
|
105
125
|
- app/models/punch.rb
|
106
|
-
- lib/punching_bag/version.rb
|
107
|
-
- lib/punching_bag/engine.rb
|
108
|
-
- lib/punching_bag/acts_as_taggable_on.rb
|
109
|
-
- lib/punching_bag/acts_as_punchable.rb
|
110
126
|
- lib/generators/punching_bag/punching_bag_generator.rb
|
111
127
|
- lib/generators/punching_bag/templates/create_punches_table.rb
|
112
128
|
- lib/punching_bag.rb
|
129
|
+
- lib/punching_bag/acts_as_punchable.rb
|
130
|
+
- lib/punching_bag/acts_as_taggable_on.rb
|
131
|
+
- lib/punching_bag/engine.rb
|
132
|
+
- lib/punching_bag/version.rb
|
113
133
|
- lib/tasks/punching_bag.rake
|
114
|
-
- spec/
|
134
|
+
- spec/internal/app/models/article.rb
|
135
|
+
- spec/internal/config/database.yml
|
136
|
+
- spec/internal/db/combustion_test.sqlite
|
137
|
+
- spec/internal/db/schema.rb
|
138
|
+
- spec/internal/log/test.log
|
115
139
|
- spec/lib/punching_bag_spec.rb
|
116
140
|
- spec/models/punch_spec.rb
|
117
141
|
- spec/models/punchable_spec.rb
|
118
|
-
- spec/
|
119
|
-
- spec/internal/db/combustion_test.sqlite
|
120
|
-
- spec/internal/config/database.yml
|
121
|
-
- spec/internal/app/models/article.rb
|
122
|
-
- spec/internal/log/test.log
|
142
|
+
- spec/spec_helper.rb
|
123
143
|
homepage: https://github.com/biola/punching_bag
|
124
144
|
licenses:
|
125
145
|
- MIT
|
@@ -130,17 +150,17 @@ require_paths:
|
|
130
150
|
- lib
|
131
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
152
|
requirements:
|
133
|
-
- -
|
153
|
+
- - ">="
|
134
154
|
- !ruby/object:Gem::Version
|
135
155
|
version: '0'
|
136
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
157
|
requirements:
|
138
|
-
- -
|
158
|
+
- - ">="
|
139
159
|
- !ruby/object:Gem::Version
|
140
160
|
version: '0'
|
141
161
|
requirements: []
|
142
162
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.2.2
|
144
164
|
signing_key:
|
145
165
|
specification_version: 4
|
146
166
|
summary: PunchingBag hit conter and trending plugin
|
@@ -154,3 +174,4 @@ test_files:
|
|
154
174
|
- spec/internal/config/database.yml
|
155
175
|
- spec/internal/app/models/article.rb
|
156
176
|
- spec/internal/log/test.log
|
177
|
+
has_rdoc:
|