hosts_file 0.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module HostsFile
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -8,19 +8,33 @@ describe HostsFile::Parser do
8
8
  host.aliases.should eql(alias_name)
9
9
  end
10
10
 
11
- it "should parse multiline" do
12
- @parser = HostsFile::Parser.new("1.1.1.1 hostname\n2.2.2.2 hostname2")
13
- @parser.collect {|h| h}.length.should eql(2)
11
+ def test_case(string, size)
12
+ hp = HostsFile::Parser.new(string)
13
+ hp.collect {|v|v}.length.should eql(size)
14
14
  end
15
15
 
16
- it "should not parse comments" do
17
- @parser = HostsFile::Parser.new("#1.1.1.1 hostname")
18
- @parser.collect {|h| h}.length.should eql(0)
16
+ it "should handle a file with only comments" do
17
+ test_case("# TEST", 0)
18
+ end
19
+
20
+ it "should handle a file with one host" do
21
+ test_case("1.1.1.1 HOSTNAME", 1)
22
+ end
23
+
24
+ it "should handle a basic file" do
25
+ test_case("# TEST\n1.1.1.1 HOSTNAME", 1)
26
+ end
27
+
28
+ it "should handle empty lines" do
29
+ test_case("\n\n# TEST\n1.1.1.1 HOSTNAME\n\n", 1)
30
+ end
31
+
32
+ it "should handle multiple lines" do
33
+ test_case("1.1.1.1 HOSTNAME\n1.1.1.1 HOSTNAME\n1.1.1.1 HOSTNAME", 3)
19
34
  end
20
35
 
21
36
  it "should not parse invalid lines" do
22
- @parser = HostsFile::Parser.new("1.1.1.1")
23
- @parser.collect {|h| h}.length.should eql(0)
37
+ test_case("1.1.1.1\n", 0)
24
38
  end
25
39
 
26
40
  it "should handle basic syntax" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hosts_file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-07-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &13603580 !ruby/object:Gem::Requirement
16
+ requirement: &19173460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *13603580
24
+ version_requirements: *19173460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &13601400 !ruby/object:Gem::Requirement
27
+ requirement: &19172800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *13601400
35
+ version_requirements: *19172800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &13600040 !ruby/object:Gem::Requirement
38
+ requirement: &19171900 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *13600040
46
+ version_requirements: *19171900
47
47
  description:
48
48
  email:
49
49
  - jbussdieker@gmail.com