rspec tests were added for the process banner
This commit is contained in:
31
spec/helpers/legislation_helper_spec.rb
Normal file
31
spec/helpers/legislation_helper_spec.rb
Normal 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
|
||||||
@@ -177,4 +177,24 @@ describe Legislation::Process do
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user