Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using visit with class name reports "Error: undefined constant User" #1137

Open
jeremyjung opened this issue May 8, 2020 · 9 comments
Open
Labels

Comments

@jeremyjung
Copy link

OS: Ubuntu 20.04 LTS (Running in VMware Workstation), 2 processors, 4gb RAM

Setup:

  1. lucky init
  2. Full support
  3. 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
@jwoertink jwoertink added the bug label May 8, 2020
@jwoertink
Copy link
Member

Related: luckyframework/lucky_flow#65

@jeremyjung
Copy link
Author

Ah, I should have checked the lucky_flow repo. That workaround looks good for now.

@paulcsmith
Copy link
Member

Glad you have a workaround. We'll definitely fix this though so won't be necessary in the future :D

@matthewmcgarvey
Copy link
Member

matthewmcgarvey commented May 15, 2020

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

@jwoertink
Copy link
Member

I haven't looked in to it much, but that sounds good.

@paulcsmith
Copy link
Member

@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?

@matthewmcgarvey
Copy link
Member

matthewmcgarvey commented May 15, 2020

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?

@paulcsmith
Copy link
Member

Yes I think that or something similar would be awesome 👍

@jwoertink
Copy link
Member

Finally getting around to fixing this 😂

Ref: luckyframework/lucky_flow#152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants