amethyst-framework / amethyst

Amethyst is a Rails inspired web-framework for Crystal language
https://github.com/amethyst-framework
MIT License
648 stars 46 forks source link

Remove default an argumet from initialize method in App class #74

Closed tobyapi closed 7 years ago

tobyapi commented 7 years ago

The initialize method in Amethyst::Base::App receive two default arguments:

def initialize(app_path= __FILE__, app_type={{@type.name.stringify}})

Here, app_path initialize by "?" because FILE is "?" in default argument of initialize method. For Example:

class A
  def initialize(@file : String =__FILE__) 
    puts @file
  end

  def get(@file=__FILE__) 
    puts @file
  end
end

a = A.new  # => "?"
a.get      # => file_path

So, "initialize should set app name" in spec/base/application_spec.cr is failing.

spec/base/application_spec.cr:

app = Base::App.new

it "should set app name" do
  app.name.should eq "application_spec"  # app.name => "?"
end

One way to solve it is to remove a default argument of app_path.

tobyapi commented 7 years ago

In this request, I suggest better code.