means 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.4
1
+ 1.2.5
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "means"
8
- s.version = "1.2.4"
8
+ s.version = "1.2.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nigel Lowry"]
12
- s.date = "2013-08-15"
12
+ s.date = "2013-08-16"
13
13
  s.description = "Calculates the different means for a data set (arithmetic, geometric and harmonic)."
14
14
  s.email = "nigel-lowry@ultra.eclipse.co.uk"
15
15
  s.extra_rdoc_files = [
@@ -29,7 +29,9 @@ Gem::Specification.new do |s|
29
29
  "lib/means.rb",
30
30
  "means.gemspec",
31
31
  "spec/means_spec.rb",
32
- "spec/spec_helper.rb"
32
+ "spec/spec_helper.rb",
33
+ "spec/support/shared_examples_for_all_means.rb",
34
+ "spec/support/shared_examples_for_non_arithmetic_means.rb"
33
35
  ]
34
36
  s.homepage = "http://github.com/nigel-lowry/means"
35
37
  s.licenses = ["MIT"]
@@ -1,41 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- shared_examples_for "all means" do
4
- [:arithmetic, :geometric, :harmonic].each do |mean|
5
- it "is nil for an empty array" do
6
- Mean.send(mean, []).should be_nil
7
- end
8
-
9
- it "is the singleton element of a singleton array" do
10
- element = 5.5
11
- Mean.send(mean, [element]).should == element
12
- end
13
-
14
- it "is the common value in an array when all values are equal" do
15
- element = 5.5
16
- Mean.send(mean, [element, element]).should == element
17
- end
18
- end
19
- end
20
-
21
- shared_examples_for "non-arithmetic means" do
22
- [:geometric, :harmonic].each do |mean|
23
- it "is nil when there are any zeroes" do
24
- data = [1.1, 0.0]
25
- Mean.send(mean, data).should be_nil
26
- end
27
-
28
- it "is nil when there are any negative numbers" do
29
- data = [1, -1]
30
- Mean.send(mean, data).should be_nil
31
- end
32
- end
33
- end
34
-
35
3
  describe "Mean" do
36
-
37
4
  describe ".arithmetic" do
38
- it_behaves_like "all means"
5
+ it_behaves_like "all means", :arithmetic
39
6
 
40
7
  specify { Mean.arithmetic([1.0, 2.0]).should be_within(0.01).of(1.5) }
41
8
  specify { Mean.arithmetic([1, 2]).should be_within(0.01).of(1.5) }
@@ -49,8 +16,8 @@ describe "Mean" do
49
16
  end
50
17
 
51
18
  describe ".geometric" do
52
- it_behaves_like "all means"
53
- it_behaves_like "non-arithmetic means"
19
+ it_behaves_like "all means", :geometric
20
+ it_behaves_like "non-arithmetic means", :geometric
54
21
 
55
22
  it "is the square root of the product of two numbers" do
56
23
  d1, d2 = 2, 8
@@ -66,8 +33,8 @@ describe "Mean" do
66
33
  end
67
34
 
68
35
  describe ".harmonic" do
69
- it_behaves_like "all means"
70
- it_behaves_like "non-arithmetic means"
36
+ it_behaves_like "all means", :harmonic
37
+ it_behaves_like "non-arithmetic means", :harmonic
71
38
 
72
39
  it "is according to the formula with two elements" do
73
40
  d1, d2 = 1.0, 2.0
@@ -0,0 +1,15 @@
1
+ shared_examples_for "all means" do |mean_method|
2
+ it "is nil for an empty array" do
3
+ Mean.send(mean_method, []).should be_nil
4
+ end
5
+
6
+ it "is the singleton element of a singleton array" do
7
+ element = 5.5
8
+ Mean.send(mean_method, [element]).should == element
9
+ end
10
+
11
+ it "is the common value in an array when all values are equal" do
12
+ element = 5.5
13
+ Mean.send(mean_method, [element, element]).should == element
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ shared_examples_for "non-arithmetic means" do |mean_method|
2
+ it "is nil when there are any zeroes" do
3
+ data = [1.1, 0.0]
4
+ Mean.send(mean_method, data).should be_nil
5
+ end
6
+
7
+ it "is nil when there are any negative numbers" do
8
+ data = [1, -1]
9
+ Mean.send(mean_method, data).should be_nil
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: means
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-15 00:00:00.000000000 Z
12
+ date: 2013-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -145,6 +145,8 @@ files:
145
145
  - means.gemspec
146
146
  - spec/means_spec.rb
147
147
  - spec/spec_helper.rb
148
+ - spec/support/shared_examples_for_all_means.rb
149
+ - spec/support/shared_examples_for_non_arithmetic_means.rb
148
150
  homepage: http://github.com/nigel-lowry/means
149
151
  licenses:
150
152
  - MIT
@@ -160,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
162
  version: '0'
161
163
  segments:
162
164
  - 0
163
- hash: 846031021487915499
165
+ hash: 1493769061049119642
164
166
  required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  none: false
166
168
  requirements: