bikepoa-tools 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,64 +1,60 @@
1
+ require 'spec_helper'
1
2
 
2
3
  describe BikePOA::Helpers::ForceField do
3
- class DummySubject < Hashie::Dash
4
- include BikePOA::Helpers::ForceField
5
- property :normal
6
- property :number
7
- property :name
8
-
9
- force_integer :number
10
- force_utf8 :name
11
- end
12
-
13
- describe 'force utf8' do
14
- let(:dummy) { DummySubject.new }
15
-
16
- describe 'when setting property directly' do
17
- it 'encodes a iso-8859-1 value to utf-8' do
18
- dummy.name = "Jo\xE3o da Silva"
19
- dummy.name.should == "Jo\xC3\xA3o da Silva"
4
+ describe 'enforcer installation' do
5
+ before :each do
6
+ module BikePOA::Helpers::ForceField::Enforcers
7
+ def self.force_something(value)
8
+ "#{value}, forced"
9
+ end
10
+ end
11
+ class DummySubject < Hashie::Dash
12
+ include BikePOA::Helpers::ForceField
13
+ property :forced
14
+ force_something :forced
20
15
  end
16
+ end
21
17
 
22
- it 'does not try to over-convert an utf-8 value' do
23
- dummy.name = "Jo\xC3\xA3o da Silva"
24
- dummy.name.should == "Jo\xC3\xA3o da Silva"
18
+ context 'when setting property directly' do
19
+ let(:dummy) { DummySubject.new }
20
+
21
+ it 'applies the enforcer' do
22
+ dummy.forced = 'a value'
23
+ dummy.forced.should == 'a value, forced'
25
24
  end
26
25
  end
27
- describe "when loading the Dash from a hash" do
28
- it 'encodes an iso-8859-1 value to utf-8' do
29
- expect { DummySubject.new(number: '678') }.to_not raise_error(ArgumentError)
26
+ context 'when creating the object from a hash' do
27
+ let(:dummy) { DummySubject.new(forced: 'a value') }
28
+
29
+ it 'forces the value to become something else' do
30
+ dummy = DummySubject.new(forced: 'a value')
31
+ dummy.forced.should == 'a value, forced'
30
32
  end
31
33
  end
32
34
  end
33
35
 
34
- describe 'force integer' do
35
- let(:dummy) { DummySubject.new }
36
-
37
- describe "when setting property directly" do
36
+ describe :Enforcers do
37
+ let(:mod) { BikePOA::Helpers::ForceField::Enforcers }
38
38
 
39
- it "accepts any value that is castable to integer" do
40
- expect { dummy.number = '42' }.to_not raise_error(ArgumentError)
41
- expect { dummy.number = 42 }.to_not raise_error(ArgumentError)
42
- expect { dummy.number = 42.0 }.to_not raise_error(ArgumentError)
43
- end
44
- it "raises when the value is not castable to integer" do
45
- expect { dummy.number = "abc" }.to raise_error(ArgumentError)
46
- expect { dummy.number = "a12" }.to raise_error(ArgumentError)
39
+ describe :force_utf8 do
40
+ it 'encodes a iso-8859-1 value to utf-8' do
41
+ mod.force_utf8("Jo\xE3o da Silva").bytes.to_a.should == "Jo\xC3\xA3o da Silva".bytes.to_a
47
42
  end
48
- it 'lets you put anything into non-forced fields' do
49
- expect { DummySubject.new(normal: 'abc1123') }.to_not raise_error
43
+
44
+ it 'does not try to over-convert an utf-8 value' do
45
+ mod.force_utf8("Jo\xC3\xA3o da Silva").bytes.to_a.should == "Jo\xC3\xA3o da Silva".bytes.to_a
50
46
  end
51
47
  end
52
48
 
53
- describe "when loading the Dash from a hash" do
54
- it 'accepts values castable to integer' do
55
- expect { DummySubject.new(number: '678') }.to_not raise_error(ArgumentError)
56
- end
57
- it "raises when one of the forced-fields is invalid" do
58
- expect { DummySubject.new(number: "abc") }.to raise_error(ArgumentError)
49
+ describe 'force integer' do
50
+ it "accepts any value that is castable to integer" do
51
+ expect { mod.force_integer('42') }.to_not raise_error(ArgumentError)
52
+ expect { mod.force_integer(42) }.to_not raise_error(ArgumentError)
53
+ expect { mod.force_integer(42.0) }.to_not raise_error(ArgumentError)
59
54
  end
60
- it 'lets you put anything into non-forced fields' do
61
- expect { DummySubject.new(normal: 'abc1123') }.to_not raise_error
55
+ it "raises when the value is not castable to integer" do
56
+ expect { mod.force_integer("abc") }.to raise_error(ArgumentError)
57
+ expect { mod.force_integer("a12") }.to raise_error(ArgumentError)
62
58
  end
63
59
  end
64
60
  end
@@ -26,22 +26,23 @@ function criaPonto() {
26
26
  blabla
27
27
  }
28
28
  trash trash trash
29
- map.addOverlay( criaPonto(point,4,'Usina do Gasômetro','Avenida Presidente João Goulart, 551','','12x0',23,'A','EO',12,6,0,50) );
30
-
29
+ exibirEstacaMapa("-30.028658",
30
+ "-51.226791",
31
+ "img/icone-estacoes.gif",
32
+ "Mercado, em frente ao chalé",
33
+ "1",
34
+ "A",
35
+ "EO",
36
+ "4",
37
+ "12",
38
+ "Rua Marechal Floriano, 66, entre a Rua Voluntários da Pátria e a Avenida Otávio Rocha");
39
+ function exibirEstacaMapa(trash, trash, trash);
31
40
  EOF
32
41
  }
33
42
  it 'extracts one relevant line containing a station' do
34
43
  result = subject.parse(content)
35
44
  result.should have(1).station
36
- end
37
- end
38
-
39
- context 'given a line that has items with commas' do
40
- let(:content) { "map.addOverlay( criaPonto(point,4,'Usina, na frente do cachorro-quente','Rua, 551','','12x0',23,'A','EO',12,6,0,50) );" }
41
- it 'should not break those items into two items' do
42
- entry = subject.parse(content).first
43
- entry.should have(7).items
44
- entry.values.should include('Usina, na frente do cachorro-quente')
45
+ result.first['name'].should == 'Mercado, em frente ao chalé'
45
46
  end
46
47
  end
47
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bikepoa-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-18 00:00:00.000000000 Z
12
+ date: 2013-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: effin_utf8
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rake
16
32
  requirement: !ruby/object:Gem::Requirement