|
63 | 63 | end |
64 | 64 | end |
65 | 65 |
|
66 | | - describe "#at_least_55_no_diploma_not_working?" do |
67 | | - it "returns true when age >= 55, no diploma, and not worked in last 5 years" do |
68 | | - nc_screener = build(:nc_screener, |
69 | | - screener: build(:screener, birth_date: 56.years.ago.to_date), |
70 | | - has_hs_diploma: "no", |
71 | | - worked_last_five_years: "no") |
| 66 | + describe "#operating_homeschool_30_or_more_hours?" do |
| 67 | + it "returns true when homeschool_hours >= 30" do |
| 68 | + nc_screener = build(:nc_screener, teaches_homeschool: "yes", homeschool_hours: 30) |
| 69 | + expect(nc_screener.operating_homeschool_30_or_more_hours?).to be true |
| 70 | + end |
72 | 71 |
|
73 | | - expect(nc_screener.at_least_55_no_diploma_not_working?).to be true |
| 72 | + it "returns false when homeschool_hours < 30" do |
| 73 | + nc_screener = build(:nc_screener, teaches_homeschool: "yes", homeschool_hours: 29) |
| 74 | + expect(nc_screener.operating_homeschool_30_or_more_hours?).to be false |
74 | 75 | end |
75 | 76 |
|
76 | | - it "returns false when age < 55" do |
77 | | - nc_screener = build(:nc_screener, |
78 | | - screener: build(:screener, birth_date: 54.years.ago.to_date), |
79 | | - has_hs_diploma: "no", |
80 | | - worked_last_five_years: "no") |
| 77 | + it "returns false when homeschool_hours is nil" do |
| 78 | + nc_screener = build(:nc_screener) |
| 79 | + expect(nc_screener.operating_homeschool_30_or_more_hours?).to be false |
| 80 | + end |
| 81 | + end |
81 | 82 |
|
82 | | - expect(nc_screener.at_least_55_no_diploma_not_working?).to be false |
| 83 | + describe "#age_work_education_health_exemption?" do |
| 84 | + it "returns true when age >= 55 && age <= 64 && worked_last_five_years_no? && has_hs_diploma_no? && preventing_work_medical_condition_yes?" do |
| 85 | + nc_screener = build(:nc_screener, worked_last_five_years: "no", has_hs_diploma: "no") |
| 86 | + create(:screener, state: "NC", birth_date: 56.years.ago.to_date, preventing_work_medical_condition: "yes", nc_screener: nc_screener) |
| 87 | + expect(nc_screener.exempt_from_work_rules?).to be true |
83 | 88 | end |
84 | 89 |
|
85 | | - it "returns false when has a diploma" do |
86 | | - nc_screener = build(:nc_screener, |
87 | | - screener: build(:screener, birth_date: 56.years.ago.to_date), |
88 | | - has_hs_diploma: "yes", |
89 | | - worked_last_five_years: "no") |
| 90 | + it "returns false when age is not set" do |
| 91 | + nc_screener = build(:nc_screener, worked_last_five_years: "no", has_hs_diploma: "no") |
| 92 | + create(:screener, state: "NC", preventing_work_medical_condition: "yes", nc_screener: nc_screener) |
| 93 | + expect(nc_screener.exempt_from_work_rules?).to be false |
| 94 | + end |
90 | 95 |
|
91 | | - expect(nc_screener.at_least_55_no_diploma_not_working?).to be false |
| 96 | + it "returns false when age is too young" do |
| 97 | + nc_screener = build(:nc_screener, worked_last_five_years: "no", has_hs_diploma: "no") |
| 98 | + create(:screener, state: "NC", birth_date: 20.years.ago.to_date, preventing_work_medical_condition: "yes", nc_screener: nc_screener) |
| 99 | + expect(nc_screener.exempt_from_work_rules?).to be false |
92 | 100 | end |
93 | 101 |
|
94 | | - it "returns false when worked in last 5 years" do |
95 | | - nc_screener = build(:nc_screener, |
96 | | - screener: build(:screener, birth_date: 56.years.ago.to_date), |
97 | | - has_hs_diploma: "no", |
98 | | - worked_last_five_years: "yes") |
| 102 | + it "returns false when age is too old" do |
| 103 | + nc_screener = build(:nc_screener, worked_last_five_years: "no", has_hs_diploma: "no") |
| 104 | + create(:screener, state: "NC", birth_date: 70.years.ago.to_date, preventing_work_medical_condition: "yes", nc_screener: nc_screener) |
| 105 | + expect(nc_screener.exempt_from_work_rules?).to be false |
| 106 | + end |
| 107 | + |
| 108 | + it "returns false worked_last_five_years is yes" do |
| 109 | + nc_screener = build(:nc_screener, worked_last_five_years: "yes", has_hs_diploma: "no") |
| 110 | + create(:screener, state: "NC", birth_date: 56.years.ago.to_date, preventing_work_medical_condition: "yes", nc_screener: nc_screener) |
| 111 | + expect(nc_screener.exempt_from_work_rules?).to be false |
| 112 | + end |
99 | 113 |
|
100 | | - expect(nc_screener.at_least_55_no_diploma_not_working?).to be false |
| 114 | + it "returns false when has_hs_diploma is yes" do |
| 115 | + nc_screener = build(:nc_screener, worked_last_five_years: "no", has_hs_diploma: "yes") |
| 116 | + create(:screener, state: "NC", birth_date: 56.years.ago.to_date, preventing_work_medical_condition: "yes", nc_screener: nc_screener) |
| 117 | + expect(nc_screener.exempt_from_work_rules?).to be false |
| 118 | + end |
| 119 | + |
| 120 | + it "returns false when preventing_work_medical_condition is no" do |
| 121 | + nc_screener = build(:nc_screener, worked_last_five_years: "no", has_hs_diploma: "no") |
| 122 | + create(:screener, state: "NC", birth_date: 56.years.ago.to_date, preventing_work_medical_condition: "no", nc_screener: nc_screener) |
| 123 | + expect(nc_screener.exempt_from_work_rules?).to be false |
101 | 124 | end |
102 | 125 | end |
103 | 126 |
|
104 | | - describe "#operating_homeschool_30_or_more_hours?" do |
105 | | - it "returns true when homeschool_hours >= 30" do |
106 | | - nc_screener = build(:nc_screener, homeschool_hours: 30) |
107 | | - expect(nc_screener.operating_homeschool_30_or_more_hours?).to be true |
| 127 | + describe "#exempt_from_work_rules?" do |
| 128 | + it "returns true when operating a homeschool for 30 or more hours and age/work/education/health exemption is true" do |
| 129 | + nc_screener = build(:nc_screener) |
| 130 | + allow(nc_screener).to receive(:operating_homeschool_30_or_more_hours?).and_return(true) |
| 131 | + allow(nc_screener).to receive(:age_work_education_health_exemption?).and_return(true) |
| 132 | + expect(nc_screener.exempt_from_work_rules?).to be true |
108 | 133 | end |
109 | 134 |
|
110 | | - it "returns false when homeschool_hours < 30" do |
111 | | - nc_screener = build(:nc_screener, homeschool_hours: 29) |
112 | | - expect(nc_screener.operating_homeschool_30_or_more_hours?).to be false |
| 135 | + it "returns true when not operating a homeschool for 30 or more hours and age/work/education/health exemption is true" do |
| 136 | + nc_screener = build(:nc_screener) |
| 137 | + allow(nc_screener).to receive(:operating_homeschool_30_or_more_hours?).and_return(false) |
| 138 | + allow(nc_screener).to receive(:age_work_education_health_exemption?).and_return(true) |
| 139 | + expect(nc_screener.exempt_from_work_rules?).to be true |
113 | 140 | end |
114 | 141 |
|
115 | | - it "returns false when homeschool_hours is nil" do |
| 142 | + it "returns true when operating a homeschool for 30 or more hours and age/work/education/health exemption is false" do |
116 | 143 | nc_screener = build(:nc_screener) |
117 | | - expect(nc_screener.operating_homeschool_30_or_more_hours?).to be false |
| 144 | + allow(nc_screener).to receive(:operating_homeschool_30_or_more_hours?).and_return(true) |
| 145 | + allow(nc_screener).to receive(:age_work_education_health_exemption?).and_return(false) |
| 146 | + expect(nc_screener.exempt_from_work_rules?).to be true |
| 147 | + end |
| 148 | + |
| 149 | + it "returns false when not operating a homeschool for 30 or more hours and age/work/education/health exemption is false" do |
| 150 | + nc_screener = build(:nc_screener) |
| 151 | + allow(nc_screener).to receive(:operating_homeschool_30_or_more_hours?).and_return(false) |
| 152 | + allow(nc_screener).to receive(:age_work_education_health_exemption?).and_return(false) |
| 153 | + expect(nc_screener.exempt_from_work_rules?).to be false |
118 | 154 | end |
119 | 155 | end |
120 | 156 | end |
0 commit comments