rspec tests were added for the process banner

This commit is contained in:
Manu
2019-01-16 12:48:12 -05:00
parent b462b7131e
commit 14d64e94d0
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
require 'rails_helper'
describe LegislationHelper do
let(:process) { build(:legislation_process) }
it "is valid" do
expect(process).to be_valid
end
describe "banner colors presence" do
it "background and font color exist" do
@process = build(:legislation_process, background_color: "#944949", font_color: "#ffffff")
expect(banner_color?).to eq(true)
end
it "background color exist and font color not exist" do
@process = build(:legislation_process, background_color: "#944949", font_color: "")
expect(banner_color?).to eq(false)
end
it "background color not exist and font color exist" do
@process = build(:legislation_process, background_color: "", font_color: "#944949")
expect(banner_color?).to eq(false)
end
it "background and font color not exist" do
@process = build(:legislation_process, background_color: "", font_color: "")
expect(banner_color?).to eq(false)
end
end
end

View File

@@ -177,4 +177,24 @@ describe Legislation::Process do
end
end
describe "banner colors" do
it "valid banner colors" do
process1 = create(:legislation_process, background_color: "123", font_color: "#fff")
process2 = create(:legislation_process, background_color: "#fff", font_color: "123")
process3 = create(:legislation_process, background_color: "", font_color: "")
process4 = create(:legislation_process, background_color: "#abf123", font_color: "fff123")
expect(process1).to be_valid
expect(process2).to be_valid
expect(process3).to be_valid
expect(process4).to be_valid
end
it "invalid banner colors" do
expect {
process1 = create(:legislation_process, background_color: "#123ghi", font_color: "#fff")
process2 = create(:legislation_process, background_color: "#ffffffff", font_color: "#123")
}.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Background color is invalid")
end
end
end