Simplify spec structure without defining modules

Specs should test classes and modules independently and they should not
be in the same module. It also avoids indentation and accidental
namespace polution.
This commit is contained in:
Maikel Linke
2023-01-24 11:41:06 +11:00
parent 7b14afbabe
commit d37fa9fc5f

View File

@@ -2,31 +2,27 @@
require "spec_helper"
module Api
module Admin
describe OrderCycleSerializer do
let(:order_cycle) { create(:order_cycle) }
let(:serializer) {
Api::Admin::OrderCycleSerializer.new order_cycle,
current_user: order_cycle.coordinator.owner
}
describe Api::Admin::OrderCycleSerializer do
let(:order_cycle) { create(:order_cycle) }
let(:serializer) {
Api::Admin::OrderCycleSerializer.new order_cycle,
current_user: order_cycle.coordinator.owner
}
it "serializes an order cycle" do
expect(serializer.to_json).to include order_cycle.name
end
it "serializes an order cycle" do
expect(serializer.to_json).to include order_cycle.name
end
it "serializes the order cycle with exchanges" do
expect(serializer.exchanges.to_json).to include "\"#{order_cycle.variants.first.id}\":true"
end
it "serializes the order cycle with exchanges" do
expect(serializer.exchanges.to_json).to include "\"#{order_cycle.variants.first.id}\":true"
end
it "serializes the order cycle with editable_variants_for_incoming_exchanges" do
expect(serializer.editable_variants_for_incoming_exchanges.to_json).to include order_cycle.variants.first.id.to_s
expect(serializer.editable_variants_for_incoming_exchanges.to_json).to_not include order_cycle.distributors.first.id.to_s
end
it "serializes the order cycle with editable_variants_for_incoming_exchanges" do
expect(serializer.editable_variants_for_incoming_exchanges.to_json).to include order_cycle.variants.first.id.to_s
expect(serializer.editable_variants_for_incoming_exchanges.to_json).to_not include order_cycle.distributors.first.id.to_s
end
it "serializes the order cycle with editable_variants_for_outgoing_exchanges" do
expect(serializer.editable_variants_for_outgoing_exchanges.to_json).to include order_cycle.variants.first.id.to_s
end
end
it "serializes the order cycle with editable_variants_for_outgoing_exchanges" do
expect(serializer.editable_variants_for_outgoing_exchanges.to_json).to include order_cycle.variants.first.id.to_s
end
end