Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
shared_examples_for "an exploitable" do
Exploitable::FIELDS.each do |field|
it { is_expected.to belong_to(field).optional }
it { is_expected.to respond_to("#{field}_text") }
describe "#{field}_value" do
context "when a pre-defined value is chosen" do
it "returns the label for that value" do
exploitable = build(described_class.model_name.singular,
field => build(field, label: "My Field"),
"#{field}_text" => "Test")
expect(exploitable.public_send("#{field}_value")).to eq "My Field"
end
end
context "when 'Other' is chosen" do
it "returns the #{field} text" do
exploitable = build(described_class.model_name.singular,
field => build(field, label: "Other"),
"#{field}_text" => "Test")
expect(exploitable.public_send("#{field}_value")).to eq "Test"
end
end
if described_class.respond_to?(:contract_template)
context "when a contract template is present" do
it "returns the #{field} value from the contract template" do
contract_template = build(:contract_template, field => build(field, label: "Contract Template Field"))
exploitable = build(described_class.model_name.singular, contract_template: contract_template)
expect(exploitable.public_send("#{field}_value")).to eq "Contract Template Field"
end
end
end
end
end
end