lucky
lucky copied to clipboard
using visit with class name reports "Error: undefined constant User"
OS: Ubuntu 20.04 LTS (Running in VMware Workstation), 2 processors, 4gb RAM
Setup:
-
lucky init
- Full support
- No authentication
Created spec/flows/visit_home_spec.cr
with following contents:
require "../spec_helper"
describe "home" do
it "should visit index" do
HomePageFlow.new.visit_index
end
end
class HomePageFlow < BaseFlow
def visit_index
visit Home::Index
el("h1.headline", text: "Not sure where to start? Here are some ideas:").should be_on_page
end
end
Expected: Success Result:
crystal spec
Showing last frame. Use --error-trace for full trace.
In lib/lucky_flow/src/lucky_flow.cr:26:53
26 | def visit(action : Lucky::Action.class, as user : User? = nil)
^---
Error: undefined constant User
Replacing visit Home::Index
with visit "/"
results in the following successful result:
crystal spec
[1588919861.480][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919861.581][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919861.683][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919861.785][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919861.887][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919861.992][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.093][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.194][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.296][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.398][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.499][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.601][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.702][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.804][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919862.906][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919863.008][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919863.109][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919863.211][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919863.312][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919863.413][SEVERE]: Timed out receiving message from renderer: 0.100
[1588919863.514][SEVERE]: Timed out receiving message from renderer: 0.100
.
Finished in 2.65 seconds
1 examples, 0 failures, 0 errors, 0 pending
Related: https://github.com/luckyframework/lucky_flow/issues/65
Ah, I should have checked the lucky_flow repo. That workaround looks good for now.
Glad you have a workaround. We'll definitely fix this though so won't be necessary in the future :D
Does it make sense that since Authentic is built on top of lucky that it could also include some test helpers for LuckyFlow? That way the helper can take in an Authentic::PasswordAuthenticatable
instead of a User
I haven't looked in to it much, but that sounds good.
@matthewmcgarvey Oh I love that idea!
I think we'll still want to extract the visit
method that accepts an as
to a module that is not included by default. We would include it only when generating Lucky with auth enabled.
Does that make sense?
My thoughts were that there would be an Authentic::Spec
module and generated apps would have a require "authentic/spec"
put in the spec_helper
file which would include anything that would help with tests, and specifically these visit methods.
@paulcsmith Is that what you're getting at?
Yes I think that or something similar would be awesome 👍
Finally getting around to fixing this :joy:
Ref: https://github.com/luckyframework/lucky_flow/pull/152