Wondering to make inherited fabricators I get error because of Fabricator looks for an class.
I found in docs, that key :from is used both to point to an class name and to an fabricator. Is that correct?
ruby 2.6.1, rspec 3.8.0
The code:
require_relative '../../app/amqp_response'
Fabricator :amqp_rq, class: "AMQPResponse" do
on_init { init_with( meta, props, body ) }
meta {{}}
body { body }
end
Fabricator :amqp_anon, :from => :amqp_rq do
props do |routing_key|
{ correlation_id: (Time.now.to_f*10000).to_i.to_s.freeze,
app_id: 'proxy',
content_type: 'application/json',
type: 'POST',
routing_key: routing_key,
headers: {
'client_id' => nil,
'accept_language' => 'ru' } }
end
end
Fabricator :amqp_client, :from => :amqp_rq do
props do |routing_key|
{ correlation_id: (Time.now.to_f*10000).to_i.to_s.freeze,
app_id: 'proxy',
content_type: 'application/json',
type: 'POST',
routing_key: routing_key,
headers: {
'client_id' => client_id,
'accept_language' => 'ru' } }
end
end
When I'm want to inherit the fabricator :amqp_rq that error shows, that Fabricator is looking for class named "AmqpRq". Isn't it?
Fabrication::UnfabricatableError:
No class found for 'amqp_rq' (original exception: uninitialized constant AmqpRq)
--
You received this message because you are subscribed to the Google Groups "fabrication" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabricationge...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
require 'bunny'
require_relative '../../app/amqp_response'
Fabricator :amqp_rq, from: "AMQPResponse" do
meta {|ba, consumer, ch| Bunny::DeliveryInfo.new(basic_deliver, consumer, channel) }
body { '{}' }
on_init { new( meta, props, body ) }
end
Fabricator :amqp_anon, from: :amqp_rq do
props do |routing_key|
Bunny::MessageProperties.new(
correlation_id: (Time.now.to_f*10000).to_i.to_s.freeze,
app_id: 'proxy',
content_type: 'application/json',
type: 'POST',
routing_key: routing_key,
headers: {
'client_id' => nil,
'accept_language' => 'ru' } )
end
end
Fabricator :amqp_client, from: :amqp_rq do
props do |routing_key|
Bunny::MessageProperties.new(
correlation_id: (Time.now.to_f*10000).to_i.to_s.freeze,
app_id: 'proxy',
content_type: 'application/json',
type: 'POST',
routing_key: routing_key,
headers: {
'client_id' => client_id,
'accept_language' => 'ru' } )
end
end