jp_prefecture 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.1 (June 11, 2013) ##
2
+
3
+ * name で渡した文字列が変更されるバグを修正
4
+
1
5
  ## 0.3.0 (June 11, 2013) ##
2
6
 
3
7
  * 都道府県名(英語表記含む)から都道府県を検索できるようにした
@@ -94,9 +94,10 @@ module JpPrefecture
94
94
 
95
95
  # 名前から都道府県コードを検索
96
96
  def self.find_code_by_name(name)
97
- name.capitalize!
97
+ result = PREFECTURE_CODE_NAME.select { |_, v|
98
+ v.has_value?(name.capitalize)
99
+ }.first
98
100
 
99
- result = PREFECTURE_CODE_NAME.select { |_, v| v.has_value?(name) }.first
100
101
  return if result.nil?
101
102
 
102
103
  result[0]
@@ -1,3 +1,3 @@
1
1
  module JpPrefecture
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -10,47 +10,75 @@ describe JpPrefecture::Prefecture do
10
10
  end
11
11
 
12
12
  describe '.find' do
13
- shared_examples "都道府県が見つかる" do |arg|
14
- let(:pref) { JpPrefecture::Prefecture.find(arg) }
15
- it { pref.code.should eq 1 }
16
- it { pref.name.should eq '北海道' }
17
- it { pref.name_e.should eq 'Hokkaido' }
18
- end
13
+ describe '検索結果について' do
14
+ shared_examples "都道府県が見つかる" do |arg|
15
+ let(:pref) { JpPrefecture::Prefecture.find(arg) }
16
+ it { pref.code.should eq 1 }
17
+ it { pref.name.should eq '北海道' }
18
+ it { pref.name_e.should eq 'Hokkaido' }
19
+ end
19
20
 
20
- shared_examples '都道府県が見つからない' do |arg|
21
- let(:pref) { JpPrefecture::Prefecture.find(arg) }
22
- it { pref.should be_nil }
23
- end
21
+ shared_examples '都道府県が見つからない' do |arg|
22
+ let(:pref) { JpPrefecture::Prefecture.find(arg) }
23
+ it { pref.should be_nil }
24
+ end
24
25
 
25
- describe '都道府県コード' do
26
- it_behaves_like "都道府県が見つかる", 1
27
- it_behaves_like "都道府県が見つからない", 99
28
- it_behaves_like "都道府県が見つかる", "1"
29
- it_behaves_like "都道府県が見つかる", "01"
30
- it_behaves_like "都道府県が見つからない", "99"
31
- end
26
+ describe '都道府県コード' do
27
+ it_behaves_like "都道府県が見つかる", 1
28
+ it_behaves_like "都道府県が見つからない", 99
29
+ it_behaves_like "都道府県が見つかる", "1"
30
+ it_behaves_like "都道府県が見つかる", "01"
31
+ it_behaves_like "都道府県が見つからない", "99"
32
+ end
32
33
 
33
- describe '都道府県コード(キーワード引数)' do
34
- it_behaves_like "都道府県が見つかる", code: 1
35
- it_behaves_like "都道府県が見つからない", code: 99
36
- it_behaves_like "都道府県が見つかる", code: "1"
37
- it_behaves_like "都道府県が見つかる", code: "01"
38
- it_behaves_like "都道府県が見つからない", code: "99"
39
- end
34
+ describe '都道府県コード(キーワード引数)' do
35
+ it_behaves_like "都道府県が見つかる", code: 1
36
+ it_behaves_like "都道府県が見つからない", code: 99
37
+ it_behaves_like "都道府県が見つかる", code: "1"
38
+ it_behaves_like "都道府県が見つかる", code: "01"
39
+ it_behaves_like "都道府県が見つからない", code: "99"
40
+ end
40
41
 
41
- describe '都道府県名' do
42
- it_behaves_like "都道府県が見つかる", name: "北海道"
43
- it_behaves_like "都道府県が見つからない", name: "うどん県"
44
- end
42
+ describe '都道府県名' do
43
+ it_behaves_like "都道府県が見つかる", name: "北海道"
44
+ it_behaves_like "都道府県が見つからない", name: "うどん県"
45
+ end
46
+
47
+ describe '都道府県名(英語表記)' do
48
+ it_behaves_like "都道府県が見つかる", name: "Hokkaido"
49
+ it_behaves_like "都道府県が見つからない", name: "Udon"
50
+ end
45
51
 
46
- describe '都道府県名(英語表記)' do
47
- it_behaves_like "都道府県が見つかる", name: "Hokkaido"
48
- it_behaves_like "都道府県が見つからない", name: "Udon"
52
+ describe '都道府県名(英語表記-小文字)' do
53
+ it_behaves_like "都道府県が見つかる", name: "hokkaido"
54
+ it_behaves_like "都道府県が見つからない", name: "udon"
55
+ end
49
56
  end
50
57
 
51
- describe '都道府県名(英語表記-小文字)' do
52
- it_behaves_like "都道府県が見つかる", name: "hokkaido"
53
- it_behaves_like "都道府県が見つからない", name: "udon"
58
+ describe '渡した変数について' do
59
+ context 'string の場合' do
60
+ it '値が変更されないこと' do
61
+ code = '1'
62
+ JpPrefecture::Prefecture.find(code)
63
+ code.should eq '1'
64
+ end
65
+ end
66
+
67
+ context 'code が string の場合' do
68
+ it '値が変更されないこと' do
69
+ code = '1'
70
+ JpPrefecture::Prefecture.find(code: code)
71
+ code.should eq '1'
72
+ end
73
+ end
74
+
75
+ context 'name の場合' do
76
+ it '値が変更されないこと' do
77
+ name = 'hokkaido'
78
+ JpPrefecture::Prefecture.find(name: name)
79
+ name.should eq 'hokkaido'
80
+ end
81
+ end
54
82
  end
55
83
  end
56
84
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jp_prefecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
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-06-10 00:00:00.000000000 Z
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake