lucasb has quit [Quit: Connection closed for inactivity]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 246 seconds]
ashirase has quit [Ping timeout: 272 seconds]
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 272 seconds]
gangstacat has quit [Quit: Ĝis!]
rohitpaulk has joined #crystal-lang
chemist69 has quit [Ping timeout: 240 seconds]
chemist69 has joined #crystal-lang
gangstacat has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
sagax has quit [Quit: Konversation terminated!]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
gtramontina has joined #crystal-lang
gtramontina has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
simerax has joined #crystal-lang
<simerax>
Hello together, im fairly new to using crystal. Right now im writing an application which uses the HTTP::WebSocket inside a Connection Class. I want to write tests for this class but I dont really know how. Im thinking about mocking the HTTP::WebSocket class however i dont quite know how to mock the constructor of HTTP::WebSocket since the connection is already established inside the constructor.
<simerax>
what i want is that the Constructor of HTTP::WebSocket does not fail bcs it cannot connect but still get a valid WebSocket Object
<simerax>
did not really think about that...thanks for the example! i will look into it
rohitpaulk has quit [Ping timeout: 250 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
laaron has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter>
<straight-shoota> simeray, it depends on what you want to test. You don't need to test the websocket implementation itself, that's already covered in stdlib specs. But you might still want to have some kind of integration test which includes going through the network stack to ensure that everyting's really working as expected. But it's probably not necessary to run all specs this way. But you should be able to mock a
<FromGitter>
... websocket connection by creating a `HTTP::Websocket` instance with an IO. This constructor is not documented, though and I can't tell if everything works as expected.
<FromGitter>
<bajro17> is anyone plan to record course for udemy or some other learning site for crystal
<FromGitter>
<bajro17> or please tell me if you know some
<FromGitter>
<Blacksmoke16> benefit of 1 is its more explicit and dont have to worry about another file. benefit of 2 is you wouldnt need a code change to change middleware, and could have env specific configs
<FromGitter>
<r00ster91> I vote for number 1. I think this can be easily in one file.
<FromGitter>
<Blacksmoke16> well assume the config file would be used for other similar things
<FromGitter>
<Blacksmoke16> but yea, this specific example its a bit overkill. Was thinking this + CORS + db stuff maybe + etc :shrug:
trashhalo[m] has joined #crystal-lang
<FromGitter>
<Simerax> is there a way to get the *LINE* and *FILE* inside a function from the caller perspective? Im Tinkering with the Logger::Formatter, i would like to see in my Logger messages the line and file on which the log was written. for example inside my File "foo.cr" i call log.error("something happend") on line 40 then i would like to get something like "something happend in file foo at line 40". I did try using *LINE*
<FromGitter>
... and *FILE* inside the Logger::Formatter.new but this of course gives me the line on which i created the formatterstring
<FromGitter>
<Simerax> well line and file should have __ around them
<FromGitter>
<Simerax> i just thought about it its probably not as simple as getting the caller...the caller is probably somewhere inside the Logger Module so this would not be enough
<FromGitter>
<Simerax> Is there a simple way of doing this or do i have to write a wrapper around Logger?
DTZUZO has quit [Ping timeout: 245 seconds]
laaron has joined #crystal-lang
<FromGitter>
<Blacksmoke16> :shrug:
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
DTZUZO has joined #crystal-lang
f1refly has joined #crystal-lang
f1refly has quit [Quit: WeeChat 1.6]
f1refly has joined #crystal-lang
rohitpaulk has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<sergiotapia> I'm a firm believer of fate and synchronicity. Many examples of it in my life. Since yesterday I've been weighing Rust, Nim and Crystal - flipflopping between them. This morning I got an email for Cirque Do Soleil Crystal lol. And just now, my wife turned on the TV to Cake Wars and the guest baker is named...Crystal. ⏎ ⏎ I think my choice is made. Time to buy the Crystal book.
<FromGitter>
<Blacksmoke16> well i kinda realized ill have to do my route checking *after* the cors check, otherwise would 404 on OPTIONS
<FromGitter>
<ryanstout> question if anyone has a sec. Is there a way to get the AST directly in a crystal macro and do transforms, then return a new AST?
<FromGitter>
<Blacksmoke16> transforms as in?
<FromGitter>
<ryanstout> For example building a DSL as a marco.
<FromGitter>
<ryanstout> ^ I mean passing code written in a DSL to a macro
<FromGitter>
<ryanstout> I might be able to accomplish the same thing another way, was just curious if you could get the AST directly
<FromGitter>
<Blacksmoke16> i.e. `StringLiteral` vs `String`
<FromGitter>
<Blacksmoke16> do you have an example of what you're trying to do
<FromGitter>
<ryanstout> yea, sorry I don't have a more specific example. Just trying to understand whats possible. I read that args were passed in as ASTNodes. Is it possible to call a macro with what looks like a block and get the AST for the block in the macro definition?
<FromGitter>
<ryanstout> @Blacksmoke16 thanks for the help btw
<FromGitter>
<ryanstout> ok, cool. Yea, I read all the docs on macro's. It's not possible to pass a block to a macro though? (forgive my noobness) Thinking something like this (fictitious example that adds benchmarking timings in): ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c8d8c04f3dbbd230c6a436f]
<FromGitter>
<Blacksmoke16> no but could just use a method called `benchmark` and use your macro logic in that method?
<FromGitter>
<ryanstout> ok, so ```benchmark``` would be a normal method? Would llvm inline that extra call? (not that it matters, just curious)