|
63 | 63 | end |
64 | 64 | end |
65 | 65 |
|
66 | | - describe ".get" do |
67 | | - it "returns the correct data for each county" do |
68 | | - all_counties.each do |state, counties| |
69 | | - counties.each do |county_name, data| |
70 | | - result = described_class.get(state, county_name) |
71 | | - expect(result).to eq(data) |
72 | | - end |
73 | | - end |
74 | | - end |
75 | | - |
76 | | - it "returns nil for unknown county or state" do |
77 | | - expect(described_class.get("NC", "Fake County")).to be_nil |
78 | | - expect(described_class.get("FAKE", "Some County")).to be_nil |
79 | | - end |
80 | | - end |
81 | | - |
82 | 66 | describe "county counts" do |
83 | 67 | it "reports correct number of counties per state" do |
84 | 68 | all_counties.each do |state, counties| |
|
89 | 73 | end |
90 | 74 | end |
91 | 75 |
|
92 | | - describe ".fetch_county!" do |
| 76 | + describe ".get" do |
93 | 77 | let(:state) { all_counties.keys.first } |
94 | 78 | let(:county) { all_counties[state].keys.first } |
95 | 79 |
|
96 | 80 | it "returns the county when valid inputs are provided" do |
97 | | - result = described_class.fetch_county!(state, county) |
| 81 | + result = described_class.get(state, county) |
98 | 82 | expect(result).to eq(all_counties[state][county]) |
99 | 83 | end |
100 | 84 |
|
101 | 85 | it "raises error when state_code is blank" do |
102 | 86 | expect { |
103 | | - described_class.fetch_county!(nil, county) |
| 87 | + described_class.get(nil, county) |
104 | 88 | }.to raise_error(ArgumentError, /state_code is required/) |
105 | 89 | end |
106 | 90 |
|
107 | 91 | it "raises error when county_key is blank" do |
108 | 92 | expect { |
109 | | - described_class.fetch_county!(state, nil) |
| 93 | + described_class.get(state, nil) |
110 | 94 | }.to raise_error(ArgumentError, /county_key is required/) |
111 | 95 | end |
112 | 96 |
|
113 | 97 | it "raises error when county does not exist" do |
114 | 98 | expect { |
115 | | - described_class.fetch_county!(state, "Fake County") |
| 99 | + described_class.get(state, "Fake County") |
116 | 100 | }.to raise_error(StandardError, /County not found/) |
117 | 101 | end |
118 | 102 | end |
|
133 | 117 | end |
134 | 118 | end |
135 | 119 |
|
| 120 | + describe ".email_for" do |
| 121 | + let(:state) { all_counties.keys.first } |
| 122 | + let(:county) { all_counties[state].keys.first } |
| 123 | + |
| 124 | + it "returns the email for a valid county" do |
| 125 | + expected = all_counties[state][county][:email] |
| 126 | + expect(described_class.email_for(state, county)).to eq(expected) |
| 127 | + end |
| 128 | + |
| 129 | + it "raises when county not found" do |
| 130 | + expect { |
| 131 | + described_class.email_for(state, "Fake County") |
| 132 | + }.to raise_error(StandardError) |
| 133 | + end |
| 134 | + end |
| 135 | + |
136 | 136 | describe ".upload_portal_or_email_for" do |
137 | 137 | let(:state) { all_counties.keys.first } |
138 | 138 |
|
|
0 commit comments