rdice 0.0.2 → 0.0.3
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/README.md +1 -1
- data/lib/dice/version.rb +1 -1
- data/spec/config_spec.rb +15 -0
- data/spec/dice_spec.rb +112 -15
- metadata +9 -7
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@ This gem was created with studies purpose. It simple create a dice and let you r
|
|
|
7
7
|
Add to your Gemfile and run the `bundle` command to install it.
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
gem "
|
|
10
|
+
gem "rdice"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
**Requires Ruby 1.9.3 or later.**
|
data/lib/dice/version.rb
CHANGED
data/spec/config_spec.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Dice::Config do
|
|
4
|
+
it "have dices as 1 and faces as 6 as default" do
|
|
5
|
+
dice = Dice.new
|
|
6
|
+
Dice::Config.faces.should == 6
|
|
7
|
+
Dice::Config.dices.should == 1
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "set dices and faces as requested" do
|
|
11
|
+
dice = Dice.new(12,3)
|
|
12
|
+
Dice::Config.faces.should == 12
|
|
13
|
+
Dice::Config.dices.should == 3
|
|
14
|
+
end
|
|
15
|
+
end
|
data/spec/dice_spec.rb
CHANGED
|
@@ -1,30 +1,127 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
describe Dice do
|
|
4
|
-
|
|
5
|
+
NTIMES = 300
|
|
5
6
|
|
|
6
|
-
describe "new" do
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
describe "new with default values" do
|
|
8
|
+
|
|
9
|
+
describe ".roll" do
|
|
10
|
+
let(:dice) { Dice.new }
|
|
11
|
+
|
|
12
|
+
it "return value between 1 to 6" do
|
|
13
|
+
NTIMES.times { 1.upto(6).include?(dice.roll).should be_true }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe ".roll_two" do
|
|
18
|
+
let(:dice) { Dice.new }
|
|
19
|
+
|
|
20
|
+
it "return value between 2 to 12" do
|
|
21
|
+
NTIMES.times { 2.upto(12).include?(dice.roll_two).should be_true }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "cant return 1" do
|
|
25
|
+
NTIMES.times { 2.upto(12).include?(dice.roll_two).should_not == 1 }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "cant be lesser then 2" do
|
|
29
|
+
NTIMES.times { dice.roll_two.should_not < 2 }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "cant return 13" do
|
|
33
|
+
NTIMES.times { dice.roll_two.should_not > 13 }
|
|
34
|
+
end
|
|
9
35
|
end
|
|
36
|
+
|
|
37
|
+
describe ".roll_d20" do
|
|
38
|
+
let(:dice) { Dice.new }
|
|
39
|
+
|
|
40
|
+
it "return value between 1 to 20" do
|
|
41
|
+
NTIMES.times { 1.upto(20).include?(dice.roll_d20).should be_true }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "cant return 21" do
|
|
45
|
+
NTIMES.times { dice.roll_two.should_not > 20 }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe ".roll_two_d10" do
|
|
50
|
+
let(:dice) { Dice.new }
|
|
51
|
+
|
|
52
|
+
it "return value between 1 to 10" do
|
|
53
|
+
NTIMES.times { 2.upto(20).include?(dice.roll_two_d10).should be_true }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "can be less than 2" do
|
|
57
|
+
NTIMES.times { dice.roll_two_d10.should_not < 2 }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "cant return 21" do
|
|
61
|
+
NTIMES.times { dice.roll_two_d10.should_not > 20 }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
10
65
|
end
|
|
11
|
-
|
|
12
|
-
describe "new with
|
|
13
|
-
|
|
14
|
-
|
|
66
|
+
|
|
67
|
+
describe "new with 12 faces and 3 dices" do
|
|
68
|
+
|
|
69
|
+
describe ".roll" do
|
|
70
|
+
let(:dice) { Dice.new(12,3) }
|
|
71
|
+
|
|
72
|
+
it "return value between 3 to 36" do
|
|
73
|
+
3.upto(36).include?(dice.roll).should be_true
|
|
74
|
+
end
|
|
15
75
|
end
|
|
16
76
|
|
|
17
|
-
|
|
18
|
-
|
|
77
|
+
describe ".roll_two" do
|
|
78
|
+
let(:dice) { Dice.new(12,3) }
|
|
79
|
+
|
|
80
|
+
it "return value between 2 to 24" do
|
|
81
|
+
NTIMES.times { 2.upto(24).include?(dice.roll_two).should be_true }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "cant return 1" do
|
|
85
|
+
NTIMES.times { 2.upto(24).include?(dice.roll_two).should_not == 1 }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "cant be lesser then 2" do
|
|
89
|
+
NTIMES.times { dice.roll_two.should_not < 2 }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "cant return 25" do
|
|
93
|
+
NTIMES.times { dice.roll_two.should_not > 25 }
|
|
94
|
+
end
|
|
19
95
|
end
|
|
20
96
|
|
|
21
|
-
|
|
22
|
-
|
|
97
|
+
describe ".roll_d20" do
|
|
98
|
+
let(:dice) { Dice.new(12,3) }
|
|
99
|
+
|
|
100
|
+
it "return value between 1 to 60" do
|
|
101
|
+
NTIMES.times { 3.upto(60).include?(dice.roll_d20).should be_true }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "cant return 61" do
|
|
105
|
+
NTIMES.times { dice.roll_two.should_not > 61 }
|
|
106
|
+
end
|
|
23
107
|
end
|
|
24
108
|
|
|
25
|
-
|
|
26
|
-
|
|
109
|
+
describe ".roll_two_d10" do
|
|
110
|
+
let(:dice) { Dice.new(12,3) }
|
|
111
|
+
|
|
112
|
+
it "return value between 1 to 10" do
|
|
113
|
+
NTIMES.times { 2.upto(20).include?(dice.roll_two_d10).should be_true }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "can be less than 2" do
|
|
117
|
+
NTIMES.times { dice.roll_two_d10.should_not < 2 }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "cant return 21" do
|
|
121
|
+
NTIMES.times { dice.roll_two_d10.should_not > 20 }
|
|
122
|
+
end
|
|
27
123
|
end
|
|
124
|
+
|
|
28
125
|
end
|
|
29
|
-
|
|
126
|
+
|
|
30
127
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rdice
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -13,7 +13,7 @@ date: 2012-03-02 00:00:00.000000000 Z
|
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70293146228280 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70293146228280
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: rake
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &70293146227360 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,7 +32,7 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *70293146227360
|
|
36
36
|
description: This gem allow you to set dices and roll it lots of times
|
|
37
37
|
email:
|
|
38
38
|
- de.tierno@gmail.com
|
|
@@ -49,6 +49,7 @@ files:
|
|
|
49
49
|
- lib/dice/config.rb
|
|
50
50
|
- lib/dice/dice.rb
|
|
51
51
|
- lib/dice/version.rb
|
|
52
|
+
- spec/config_spec.rb
|
|
52
53
|
- spec/dice_spec.rb
|
|
53
54
|
- spec/spec_helper.rb
|
|
54
55
|
homepage: ''
|
|
@@ -65,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
65
66
|
version: '0'
|
|
66
67
|
segments:
|
|
67
68
|
- 0
|
|
68
|
-
hash: -
|
|
69
|
+
hash: -645987200912169816
|
|
69
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
none: false
|
|
71
72
|
requirements:
|
|
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
74
75
|
version: '0'
|
|
75
76
|
segments:
|
|
76
77
|
- 0
|
|
77
|
-
hash: -
|
|
78
|
+
hash: -645987200912169816
|
|
78
79
|
requirements: []
|
|
79
80
|
rubyforge_project: rdice
|
|
80
81
|
rubygems_version: 1.8.10
|
|
@@ -82,5 +83,6 @@ signing_key:
|
|
|
82
83
|
specification_version: 3
|
|
83
84
|
summary: Roll dices with different faces
|
|
84
85
|
test_files:
|
|
86
|
+
- spec/config_spec.rb
|
|
85
87
|
- spec/dice_spec.rb
|
|
86
88
|
- spec/spec_helper.rb
|