dmarcator 0.1.0

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/spec/uri_spec.rb ADDED
@@ -0,0 +1,141 @@
1
+ require 'spec_helper'
2
+ require 'dmarcator/uri'
3
+
4
+ describe DMARCator::Uri do
5
+ let(:uri) { URI("mailto:d@ruf.agari.com") }
6
+ let(:size) { 10 }
7
+ let(:unit) { :m }
8
+
9
+ subject { described_class.new(uri,size,unit) }
10
+
11
+ describe "#initialize" do
12
+ it "should set the uri" do
13
+ expect(subject.uri).to be uri
14
+ end
15
+
16
+ it "should set the size" do
17
+ expect(subject.size).to be size
18
+ end
19
+
20
+ it "should set the unit" do
21
+ expect(subject.unit).to be unit
22
+ end
23
+
24
+ context "when size is omitted" do
25
+ subject { described_class.new(uri) }
26
+
27
+ it "should set size to nil" do
28
+ expect(subject.size).to be(nil)
29
+ end
30
+
31
+ it "should set unit to nil" do
32
+ expect(subject.unit).to be(nil)
33
+ end
34
+ end
35
+
36
+ context "when unit is omitted" do
37
+ subject { described_class.new(uri,size) }
38
+
39
+ it "should set size" do
40
+ expect(subject.size).to be(size)
41
+ end
42
+
43
+ it "should set unit to nil" do
44
+ expect(subject.unit).to be(nil)
45
+ end
46
+ end
47
+ end
48
+
49
+ describe "#size?" do
50
+ context "when size is nil" do
51
+ subject { described_class.new(uri) }
52
+
53
+ it { expect(subject.size?).to be(false) }
54
+ end
55
+
56
+ context "when size is set" do
57
+ subject { described_class.new(uri,size) }
58
+
59
+ it { expect(subject.size?).to be(true) }
60
+ end
61
+ end
62
+
63
+ describe "#unit?" do
64
+ context "when unit is nil" do
65
+ subject { described_class.new(uri,size) }
66
+
67
+ it { expect(subject.unit?).to be(false) }
68
+ end
69
+
70
+ context "when unit is set" do
71
+ subject { described_class.new(uri,size,unit) }
72
+
73
+ it { expect(subject.unit?).to be(true) }
74
+ end
75
+ end
76
+
77
+ describe "#==" do
78
+ context "when other is a #{described_class}" do
79
+ context "and all fields match" do
80
+ let(:other) { described_class.new(uri.dup,size,unit) }
81
+
82
+ it { expect(subject == other).to be(true) }
83
+ end
84
+
85
+ context "but the uri is different" do
86
+ let(:other_uri) { URI("mailto:foo@example.com") }
87
+ let(:other) { described_class.new(other_uri,size,unit) }
88
+
89
+ it { expect(subject == other).to be(false) }
90
+ end
91
+
92
+ context "but the size is different" do
93
+ let(:other) { described_class.new(uri,42,unit) }
94
+
95
+ it { expect(subject == other).to be(false) }
96
+ end
97
+
98
+ context "but the unit is different" do
99
+ let(:other) { described_class.new(uri,size,:t) }
100
+
101
+ it { expect(subject == other).to be(false) }
102
+ end
103
+ end
104
+
105
+ context "when other is a different class" do
106
+ let(:other) { Object.new }
107
+
108
+ it { expect(subject == other).to be(false) }
109
+ end
110
+ end
111
+
112
+ describe "#to_s" do
113
+ context "when only the uri is set" do
114
+ subject { described_class.new(uri) }
115
+
116
+ it "should return the uri" do
117
+ expect(subject.to_s).to be == uri.to_s
118
+ end
119
+ end
120
+
121
+ context "when uri and size are set" do
122
+ subject { described_class.new(uri,size) }
123
+
124
+ it "should return the uri!size" do
125
+ expect(subject.to_s).to be == "#{uri}!#{size}"
126
+ end
127
+ end
128
+
129
+ context "when uri, size and unit are set" do
130
+ it "should return the uri!size" do
131
+ expect(subject.to_s).to be == "#{uri}!#{size}#{unit}"
132
+ end
133
+ end
134
+ end
135
+
136
+ describe "#method_missing" do
137
+ it "should pass through methods to uri" do
138
+ expect(subject.host).to be(uri.host)
139
+ end
140
+ end
141
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dmarcator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Noah Berman
8
+ - Davis Gallinghouse
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: parslet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ description: A hardened DMARC record parser and query client, forked from the Trail
34
+ of Bits 'dmarc' gem.
35
+ email:
36
+ - noah@noahberman.org
37
+ - davis@trailofbits.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - ChangeLog.md
43
+ - LICENSE.txt
44
+ - README.md
45
+ - lib/dmarcator.rb
46
+ - lib/dmarcator/exceptions.rb
47
+ - lib/dmarcator/parser.rb
48
+ - lib/dmarcator/query.rb
49
+ - lib/dmarcator/record.rb
50
+ - lib/dmarcator/uri.rb
51
+ - lib/dmarcator/version.rb
52
+ - spec/data/alexa.csv
53
+ - spec/dmarcator_spec.rb
54
+ - spec/parser_spec.rb
55
+ - spec/record_spec.rb
56
+ - spec/spec_helper.rb
57
+ - spec/uri_spec.rb
58
+ homepage: https://github.com/bermannoah/dmarc
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ source_code_uri: https://github.com/bermannoah/dmarc
63
+ bug_tracker_uri: https://github.com/bermannoah/dmarc/issues
64
+ rubygems_mfa_required: 'true'
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 3.0.0
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 4.0.10
80
+ specification_version: 4
81
+ summary: DMARC record parser and query client
82
+ test_files:
83
+ - spec/data/alexa.csv
84
+ - spec/dmarcator_spec.rb
85
+ - spec/parser_spec.rb
86
+ - spec/record_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/uri_spec.rb