polygonize 0.0.3 → 0.0.4

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/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
@@ -1,3 +1,3 @@
1
1
  module Polygonize
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -4,43 +4,65 @@ require 'spec_helper'
4
4
 
5
5
  include Polygonize
6
6
 
7
- describe "Polygonize" do
8
- context "空テキスト" do
9
- it "空テキストは何も返さない" do
10
- "".coordinates.should eql ""
7
+ describe "Polygonizeモジュールをインクルードする" do
8
+ describe ":coordinates メソッド" do
9
+ context "空テキスト" do
10
+ it "は何も返さない" do
11
+ "".coordinates.should eql ""
12
+ end
11
13
  end
12
- end
13
14
 
14
- context "テキスト" do
15
- txt = "こんにちは"
16
- it "はxy座標の文字列を返す" do
17
- txt.coordinates.should eql "48,83 48,147 48,107 48,97 48,111"
15
+ context "Stringのメソッドである" do
16
+ it "Fixnumはエラーになる" do
17
+ proc {
18
+ 123.coordinates
19
+ }.should raise_error
20
+ end
21
+
22
+ it "Arrayはエラーになる" do
23
+ proc {
24
+ ["foo","bar"].coordinates
25
+ }.should raise_error
26
+ end
18
27
  end
19
28
 
20
- it "要素は偶数個である" do
21
- ar = txt.coordinates.split(" ").inject([]) { |mem, x| mem << x.split(",") }
22
- (ar.flatten.size%2).should eql 0
23
- end
29
+ context "テキスト" do
30
+ txt = "こんにちは"
31
+ it "はxy座標の文字列を返す" do
32
+ txt.coordinates.should eql "48,83 48,147 48,107 48,97 48,111"
33
+ end
34
+
35
+ it "要素は偶数個である" do
36
+ ar = txt.coordinates.split(" ").inject([]) { |mem, x| mem << x.split(",") }
37
+ (ar.flatten.size%2).should eql 0
38
+ end
24
39
 
25
- it "各要素は255(FF)以下である" do
26
- txt.coordinates.split(" ").flatten.reject! { |x| x.to_i < 255}
40
+ it "各要素は255(FF)以下である" do
41
+ ret = txt.coordinates.split(" ").flatten.reject! { |x| x.to_i < 255}
42
+ ret.should eql []
43
+ end
27
44
  end
28
- end
29
45
 
30
- context "1バイトテキスト" do
31
- txt_e = "x"
32
- it "ゼロで補完する" do
33
- txt_e.coordinates.split(",")[1].should eql "0"
34
- end
46
+ context "1バイトテキスト" do
47
+ txt_e = "x"
48
+ it "は奇数要素、ゼロで補完する" do
49
+ txt_e.coordinates.split(",")[1].should eql "0"
50
+ end
35
51
 
36
- it "x = 0x78" do
37
- txt_e.coordinates.split(",")[0].should eql "78".hex.to_s
52
+ it "#{txt_e}の文字コードは0x78である" do
53
+ txt_e.coordinates.split(",")[0].should eql "78".hex.to_s
54
+
55
+ end
56
+ it "0x78 = 120である" do
57
+ txt_e.coordinates.split(",")[0].should eql "120"
58
+ end
38
59
  end
39
- end
40
60
 
41
- context "メソッド" do
42
- it "coordinatesは Stringのインスタンスメソッドがある" do
43
- String.instance_methods.grep(/^coordinates/).should eql [:coordinates]
44
- end
61
+ context "メソッド" do
62
+ it ":coordinatesは Stringのインスタンスメソッドがある" do
63
+ String.instance_methods.grep(/^coordinates/).should eql [:coordinates]
64
+ end
65
+ end
45
66
  end
67
+
46
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polygonize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2012-09-05 00:00:00.000000000 Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -83,6 +83,7 @@ extensions: []
83
83
  extra_rdoc_files: []
84
84
  files:
85
85
  - .gitignore
86
+ - .travis.yml
86
87
  - Gemfile
87
88
  - Guardfile
88
89
  - LICENSE