Skip to content

Commit

Permalink
Add test for Plugins::DryValidation.inherited
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloh committed Aug 9, 2024
1 parent edcee9c commit aba1ca2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
10 changes: 10 additions & 0 deletions spec/plugins/dry_validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ class OperationWithAutoWire < Operation
.to include(:gender)
end
end

context 'when the operation is inherited' do
let(:opr_class) { OperationWithAutoWire }
subject(:opr_subclass) { Class.new(OperationWithAutoWire) }

it "sets 'contract_class' and 'auto_wire' from the superclass", :aggregate_failures do
expect(opr_subclass.auto_wire).to eq(opr_class.auto_wire)
expect(opr_subclass.contract_class).to eq(opr_class.contract_class)
end
end
end

describe "#call" do
Expand Down
17 changes: 8 additions & 9 deletions spec/plugins/sequel_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def chain_operation(state)
end
end

class SubOperation < MyOperation; end

describe 'DSL' do
let(:result) { operation.call(params) }
let(:params) { { email: '[email protected]' } }
Expand Down Expand Up @@ -274,13 +272,14 @@ class InvalidOperation < MyOperation
end

context 'when the operation is inherited' do
it "sets 'result_key', 'search_field', 'model_class' and 'model_not_found' from the superclass" do
aggregate_failures do
expect(SubOperation.result_key).to eq(MyOperation.result_key)
expect(SubOperation.search_field).to eq(MyOperation.search_field)
expect(SubOperation.model_class).to eq(MyOperation.model_class)
expect(SubOperation.model_not_found).to eq(MyOperation.model_not_found)
end
let(:opr_class) { MyOperation }
subject(:opr_subclass) { Class.new(opr_class) }

it "sets 'result_key', 'search_field', 'model_class' and 'model_not_found' from the superclass", :aggregate_failures do
expect(opr_subclass.result_key).to eq(opr_class.result_key)
expect(opr_subclass.search_field).to eq(opr_class.search_field)
expect(opr_subclass.model_class).to eq(opr_class.model_class)
expect(opr_subclass.model_not_found).to eq(opr_class.model_not_found)
end
end
end
Expand Down

0 comments on commit aba1ca2

Please sign in to comment.