答案 0 :(得分:0)
可以部分模拟水豚,也可以改变水豚常规的价值
另外,https://github.com/jnicklas/capybara/以防可能感兴趣
答案 1 :(得分:0)
我手动创建了Ahoy::Visits
和Ahoy::Events
。
# use the Faker gem for fake data
request = OpenStruct.new(
params: { },
referer: Faker::Internet.url,
remote_ip: Faker::Internet.public_ip_v4_address,
user_agent: Faker::Internet.user_agent,
original_url: Rails.application.routes.url_helpers.root_url,
)
visit_properties = Ahoy::VisitProperties.new(request, api: nil)
properties = visit_properties.generate.select { |_, v| v }
example_visit = Ahoy::Visit.create!(properties.merge(
visit_token: SecureRandom.uuid,
visitor_token: SecureRandom.uuid,
started_at: Time.current
))
example_event = Ahoy::Event.create!(
visit: example_visit,
name: 'example_event',
properties: 'example properties',
time: Time.current
)