havenwood changed the topic of #ruby to: Ruby 3.2.2, 3.1.4, 3.3.0-preview1: https://www.ruby-lang.org | Rules: https://ruby-community.com | Logs: https://libera.irclog.whitequark.org/ruby
supay has quit [*.net *.split]
cnsvc has quit [*.net *.split]
hexology has quit [*.net *.split]
ross has quit [*.net *.split]
entropie has quit [*.net *.split]
micro has quit [Changing host]
_whitelogger has joined #ruby
yosafbridge has joined #ruby
rvalue has joined #ruby
hexology has joined #ruby
smp has joined #ruby
Byteflux has joined #ruby
helveticamono has joined #ruby
jimeh has joined #ruby
dannyAAM has joined #ruby
desnudopenguino has joined #ruby
Demi has joined #ruby
mx has joined #ruby
pvalenta has joined #ruby
weyhmueller has joined #ruby
pvalenta has quit [Changing host]
pvalenta has joined #ruby
victori has joined #ruby
Pixi has joined #ruby
sphex has joined #ruby
pounce has joined #ruby
deadmarshal_ has joined #ruby
isene has joined #ruby
duderonomy has joined #ruby
NightMonkey has joined #ruby
xuochi has joined #ruby
Sampersand has joined #ruby
<Sampersand> Heh, i segfaulted ruby
<Sampersand> `GC.stress = ""; !GC.stress`
<adam12> Sampersand: Nice. I think there's an open bug for that right now?
<Sampersand> there is?
<adam12> At least, GC.stress and segfault is a recent memory from the bug tracker.
<Sampersand> I was writing the RBS for GC and i came across this
<Sampersand> So I just did `  def self.stress=: (Integer flag) -> Integer | (bool flag) -> bool` because I figure anything else is a mistake
<adam12> I can't find the email so maybe I'm going crazy.
xuochi has quit [Quit: leaving]
<Sampersand> i fitured out the problem tho, it jsut doesnt mark the stress when sweeping
<Sampersand> doesn't mark stress when marking the `GC` object *
<adam12> Yeah> Weird.
<Sampersand> i suspect it's because of the documentation, where they only talk about it being true, false, or an integer OR of 0x1, 0x2, and 0x4
<Sampersand> so no one thought about it
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
OverCoder has joined #ruby
jetchisel has joined #ruby
heinrich5991 has quit [Server closed connection]
heinrich5991 has joined #ruby
hightower3 has joined #ruby
con3 has quit [Server closed connection]
hightower2 has quit [Ping timeout: 240 seconds]
con3 has joined #ruby
Sampersand has quit [Ping timeout: 245 seconds]
mahlon has quit [Server closed connection]
mahlon has joined #ruby
Vonter has quit [Ping timeout: 240 seconds]
Vonter has joined #ruby
constxqt has joined #ruby
nemesit|znc has quit [Server closed connection]
nemesit has joined #ruby
constxqt has quit [Ping timeout: 255 seconds]
weathere1watcher has quit [Ping timeout: 258 seconds]
weatheredwatcher has joined #ruby
_ht has joined #ruby
grenierm has joined #ruby
nona has quit [Ping timeout: 255 seconds]
nona has joined #ruby
benjaminwil has quit [Server closed connection]
benjaminwil has joined #ruby
_ht has quit [Quit: _ht]
Linux_Kerio has joined #ruby
z4kz has quit [Server closed connection]
z4kz has joined #ruby
sarna has quit [Ping timeout: 255 seconds]
unveiledly has joined #ruby
nona has quit [Ping timeout: 252 seconds]
nona has joined #ruby
teclator has joined #ruby
konsolebox has joined #ruby
nona has quit [Ping timeout: 255 seconds]
nona has joined #ruby
willfish has joined #ruby
unveiledly has quit [Ping timeout: 255 seconds]
phocoid has joined #ruby
nona has quit [Read error: Connection reset by peer]
yziquel has quit [Quit: Client closed]
sam113101 has quit [Ping timeout: 240 seconds]
sam113102 has joined #ruby
sam113102 is now known as sam113101
hd1 has joined #ruby
hd1 has left #ruby [#ruby]
summerisle has quit [Server closed connection]
summerisle has joined #ruby
Linux_Kerio has quit [Ping timeout: 245 seconds]
graywolf has joined #ruby
hightower3 has quit [Ping timeout: 255 seconds]
hightower2 has joined #ruby
hightower2 has quit [Read error: Connection reset by peer]
yziquel has joined #ruby
u0_a115 has joined #ruby
u0_a115 is now known as misper
yziquel has quit [Ping timeout: 245 seconds]
misper has quit [Ping timeout: 255 seconds]
fercell has quit [Read error: Connection reset by peer]
misper has joined #ruby
fercell has joined #ruby
nona has joined #ruby
misper has quit [Remote host closed the connection]
Linux_Kerio has joined #ruby
Thanzex has quit [Quit: The Lounge - https://thelounge.chat]
gr33n7007h has quit [Ping timeout: 258 seconds]
Linux_Kerio has quit [Quit: Konversation terminated!]
Linux_Kerio has joined #ruby
gr33n7007h has joined #ruby
nona has quit [Read error: Connection reset by peer]
gr33n7007h has quit [Ping timeout: 252 seconds]
gr33n7007h has joined #ruby
RDMengineer has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
TomyWork has joined #ruby
TomyWork has quit [Ping timeout: 252 seconds]
TomyWork has joined #ruby
grenierm has quit [Ping timeout: 245 seconds]
infinityfye has joined #ruby
konsolebox has quit [Quit: Leaving]
nona has joined #ruby
<nona> hi all
<gr33n7007h> o/
<nona> what's the MiniTest-esque way of doing `allow(String).to receive(:to_mouse).and_return(cheese)`?
Rounin has quit [Remote host closed the connection]
<adam12> nona: minitest has a stub method that could work, but most people bring in mocha.
<adam12> nona: I don't personally care for either. I might reach for mocktail in future projects
<nona> adam12: you don't care for either ... meaning you feel like that sort of thing ought not to be done?
<adam12> nona: Well, I've been personally trying to use mocks a lot less, but sometimes it's not completely avoidable.
<adam12> nona: As far as minitest stub works, it's sufficient but fairly simple and has some weird edgecases around Ruby 3 keyword args. It's good in a pinch.
<nona> ah ok ... i suspect i'm in one of those "sometimeses".
<adam12> nona: Mocha has been around since mid-2000's and is solid. But it doesn't support Spies so I find it more often then not less than useful. It has a very rspec-like DSL similar to the one above.
* nona will try and see
<nona> thank you!
<adam12> Mocktail is new and from Justin Searls. I tried it in one project but ran into a bug, but it looks like it's fixed, so I might try it again.
<adam12> Oh, another thing I don't like about Mocha is it breaks the AAA pattern of tests. You don't manually assert on the mocks, so some tests might have no assertions, which is weird.
taupiqueur_shiny has quit [Remote host closed the connection]
<adam12> I've been trying to model my code more akin to James shore's testing without mocks style (which overlaps a lot with the Eventide project).
taupiqueur_shiny has joined #ruby
<adam12> In essence, create substitutes/null objects that you can configure their responses, and allow them to publish telemetry that you can listen to.
* nona googles AAA pattern
<adam12> Ah. AAA is Arrange Act Assert
<nona> oh
<nona> am i in the process discoving how to write tests and feel good about it?
<nona> hmm ok, so, "write tests the way you'd expect they should be written"
<adam12> More like, how you'd expect to understand them
<adam12> When the test concludes, I want to know that what I expected to happen, happened. Normally if this is at the beginning of the test the flow feels weird.
<nona> and i thought i was just having OCD
<adam12> If you're curious, here's the implementation for that CommandRunner. https://gist.github.com/adam12/d74f96d5f5b92627fe5f4a8ae90cc048
John_Ivan has quit [Read error: Connection reset by peer]
<adam12> Wherever I use CommandRunner in a collaborator, I pass it the substitute instead, which allows me to configure the response and see what it's been called with.
<nona> it looks cool but i'll resist the temptation to read it from start to end, and go down a different rabbit hole than the one i need to be going down right now :)
<adam12> Haha. Yeah
<adam12> Isn't software great...
John_Ivan has joined #ruby
<adam12> I don't use "mocks" or "stubs" anywhere in this project.
<adam12> James Shore does an interesting TDD where he does a video in JS about this. It's worth a watch. https://www.jamesshore.com/v2/projects/lunch-and-learn
<nona> adam12: what i'm having to do right now is test the methods we have which use Auth0, but without connecting to their servers. i suspect this won't be possible without mocking.
<adam12> nona: If it's not your Auth0 client, I normally wrap them with my own interface, then build a substitute around that.
<nona> how do you mean, if it's not my client?
<adam12> nona: And then I have one test class that compares the real implementation with the substitute, interfacing with the real Auth0 server.
<nona> oh wow
<adam12> nona: I mean, if you did `gem install auth0` or `bundle add auth0` in your repo, then just hooked into `Auth0.validate` or something, then I would wrap it.
<adam12> And control the responses.
<adam12> It's more upfront work
<nona> unfortunately i didn't write the code. and the person who wrote it is gone now. and their implementation is very convoluted.
<nona> but yeah `bundle add auth0` was done.
<adam12> Yeah. Not wrapping external interfaces is usually what gets you _way_ down the line
<nona> man, mocktail does look much nicer and easier than any of the others i've seen, including what you'd do with rspec
<adam12> Because you don't control the boundary, you're prone to whatever churn the library might invoke, and those changes could cause "shotgun surgery" inside your codebase, depending on how prolific the dependency is.
<nona> adam12: i don't understand "getting down the line"
<adam12> Yeah. Mocktail (from what little I used it) was pretty good
<adam12> nona: Well, a lot of projects I work on are 10+ years old.
<adam12> nona: Not everyone wants to maintain their Ruby gems for that long, or are prone to large rewrites.
<nona> hmm i think my problem with "getting down the line" are more profound. as in, not being a native speaker of English profound :)
<nona> problems*
<adam12> Ooh, I see.
<adam12> It's not now that these dependencies cause the issues. It's 10 years from now :)
<nona> aaaaah
<nona> right
dviola has joined #ruby
<nona> wait, let me check with management if they're okay with me adding a separation layer in this
<nona> alright, nope :-P
<adam12> LOL
<adam12> Oh well.
<adam12> If you look at Mocktail docs, I think even they recommend wrapping third party libs
<nona> I totally see why doing that would make sense.
<nona> Like, I WANT to do it.
<nona> Alas, if I did it, I'd die from being shot with a barrage of NerfGun rockets.
<nona> adam12: in the actual project, i can't use Mocktail (yet). We'll be stuck on Ruby 2.7 until at least next spring or so.
<nona> Sad :(
<adam12> :|
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
polishdub has joined #ruby
otisolsen70 has joined #ruby
dorian has quit [Server closed connection]
dorian has joined #ruby
infernix has quit [Quit: ZNC - http://znc.sourceforge.net]
xmachina has quit [Server closed connection]
xmachina has joined #ruby
TomyWork has quit [Remote host closed the connection]
nona has quit [Ping timeout: 255 seconds]
_ht has joined #ruby
<adam12> One interesting side-effect of running gemdocs.org is I look at it periodically throughout the week to see how it's going with gems, and sometimes come across some interesting ones.
<adam12> http://gemdocs.org/gems/na/1.2.55/ looks neat. I think I could see myself using that.
nona has joined #ruby
<ox1eef_> I use a notion doc for that. GitHub issues are too formal.
nona has quit [Ping timeout: 245 seconds]
nona has joined #ruby
nona has quit [Ping timeout: 255 seconds]
gr33n7007h has quit [Ping timeout: 252 seconds]
nona has joined #ruby
gr33n7007h has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
<nona> adam12: so now i did this thing where i wrote some tests, happily hacking away without checking in between, using a mix of the Minitest::Spec style and Mocha-based mocking. and it looks neat. and then I run it (explicitly saying `ruby -Ilib:test test/models/user_test.rb`) and it goes all "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips" on me. did you ever have something like that?
<adam12> nona: Nope.
<adam12> nona: You're using spec-style `describe` and `it` inside user_test.rb?
<nona> yes
<nona> is that not what i'm supposed to be doing? because it's a model?
<adam12> nona: Seems fine.
<adam12> nona: What happens if you put a flunking test somewhere.
<adam12> nona: ie. Inside a describe block, `def test_flunks; flunk; end`
<nona> oh! good idea!
<nona> same thing
<nona> as if it wasn't there
<ox1eef_> Did you require minitest/autorun
<nona> even when i make the whole file as small as possible: https://gist.github.com/sixtyfive/7ef686c74eb67ddaf556b9f337a690b4
<nona> (so yes, ox1eef_)
<ox1eef_> Are you sure that works ? Try it { flunk }.
<nona> same
<ox1eef_> Or, subclass Minitest::Test if you want to use 'def test_foo; end'.
<ox1eef_> It works for me.
<ox1eef_> require 'minitest'
<ox1eef_> require 'minitest/autorun'
<nona> ox1eef_: i added a few puts. only the first two output anything.
<ox1eef_> describe 'foo' do
<ox1eef_> def test_flunks; flunk; end
<ox1eef_> end
<nona> perhaps because i'm stuck on ruby 2.7.8?
<ox1eef_> Might be. I tried with 3.2.
<nona> hmm
<nona> not ruby's fault
<nona> if i run JUST your code then it's fine
<nona> once Rails's config/environment.rb is required, that's when it stops working. interesting.
<nona> this app has pretty bad history and is full of code smell
<adam12> Remove autorun line
<adam12> I'm assuming it's handled automatically by ActiveSupport.
<nona> doesn't make it worse. doesn't make it work, either :)
<nona> huh ... `WEBMASTER_EMAIL = 'webmaster@domain.tld'.freeze` ... do people have any good reason for freezing a string being assigned to a constant in a configuration file loaded once on startup?
<ox1eef_> Frozen string literals are a common default. Usually you'd achieve it with a magic comment though (# frozen_string_literal: true).
<ox1eef_> It is done for performance, and for your own sanity. Something like a webmaster's email should not be modified at runtime. If it is, it's probably a mistake.
<nona> ox1eef_: i know about the performance topic. but all uppercase letters means it's a constant anyways. what am i missing?
<leftylink> strings are mutable.
<leftylink> WEBMASTER_EMAIL.clear
<leftylink> oops, you no longer have a webmaster email aymore
<leftylink> that's you freeze
<leftylink> that's why you freeze.
<nona> woah!! didn't know about #clear on constants! not even a warning?!
<leftylink> pandabot: ri String#clear
<nona> but but but ... _constant_!!!
<ox1eef_> A constant is something that should not be reassigned, mutating the reference is something else.
* nona feels cheated by Ruby
<nona> how is FOO="bar" ; FOO.clear different from FOO="" and therefore _not_ a reassignment?
<ox1eef_> FOO.clear doesn't create a new object.
<nona> hmm. i still feel like a constant shouldn't allow itself to be cleared without causing a warning. it's called a _constant_ because it's not variable.
<ox1eef_> The warning is there as long as you freeze the string.
<nona> that's it. i'm putting that magic comment _every_where.
<nona> also, riddle with minitest solved: it works fine until you wish to use the spec syntax. then it stops working. at least with this app.
<leftylink> in the same vein, you should of course also freeze any arrays or hashes that you do not need to modify. there is no comment for that, so you have to call #freeze.
<nona> why no comment for that?
<leftylink> who knows
<nona> and what about more advanced data types?
<nona> oh great Matz, I call upon thee ... why hathst though forsaken thy principle of predictability?
<leftylink> sure, freeze anything mutable that shouldn't be modified. I actually only restricted my initial statement because I thought that user-defined classes won't have a #freeze by default and/or it won't actually freeze, but upon quick inspection... they might actually, which is interesting
<ox1eef_> For your own objects, you'd implement #freeze and #frozen?, then check @frozen anywhere you might mutate the object. Object#freeze is probably not enough.
helge has quit [Server closed connection]
helge has joined #ruby
<johnjaye> ox1eef_: is the syntax for the attr_accessor just foo.frozen
<ox1eef_> You'd probably want to implement #initialize_dup as well, where you set @frozen back to false.
<ox1eef_> johnjaye: frozen? is a predicate, and freeze is the setter, that sets @frozen to true. You wouldn't need attr_accessor.
<nona> what's a predicate?
<johnjaye> ah ok. i was thinking the syntax to access an instance variable is just foo.bar
<johnjaye> which is the same as a method
<johnjaye> nona: it's from First order logic. basically a function returning true or false.
* nona googles first order logic
<johnjaye> ruby is very lisp in that it puts a ? on such functions often
<johnjaye> and a ! on mutators as well. very elegant
<nona> i know both
<nona> and i like it
<nona> it immediately lets you see things
<nona> but lisp scares me
<nona> "First-order logic uses quantified variables over non-logical objects, and allows the use of sentences that contain variables, so that rather than propositions such as "Socrates is a man", one can have expressions in the form "there exists x such that x is Socrates and x is a man", where "there exists" is a quantifier, while x is a variable." <--- this, too, scares me
<ox1eef_> In Ruby a predicate method can be described as a method that ends in ?, and returns either a truthy or falsey value. Some would argue it should return strictly true or false but there's not complete agreement on that.
<leftylink> what was a well-known example where a ? method doesn't return a boolean... I don't quite remember. I know defined? doesn't, but it's not a method so it doesn't fit the letter of the question (but I guess it fits the spirit which matters much much more?)
<leftylink> pandabot rb a = 5; defined?(a)
<pandabot> "local-variable" - https://carc.in/#/r/frt8
grenierm has joined #ruby
konsolebox has joined #ruby
<leftylink> hey speaking of Ruby keywords. where was that Ruby program that was Keywords Only?
<leftylink> ah here we are: The Most Reserved Ruby Program: https://github.com/tric/trick2018/blob/master/01-kinaba/entry.rb
<ox1eef_> :))
<johnjaye> lol how does that even work
yziquel has joined #ruby
<ox1eef_> That's part of its appeal. Dissecting it to make sense of it.
grenierm has quit [Quit: Client closed]
xuochi has joined #ruby
nona has quit [Read error: Connection reset by peer]
infinityfye has quit [Ping timeout: 252 seconds]
nona has joined #ruby
yziquel has quit [Quit: Client closed]
konsolebox has quit [Ping timeout: 255 seconds]
_ht has quit [Quit: _ht]
xuochi has quit [Quit: leaving]
fercell has quit [Ping timeout: 252 seconds]
fercell has joined #ruby
OverCoder has quit [Quit: Connection closed for inactivity]
otisolsen70 has quit [Quit: Leaving]
gthank has joined #ruby
MarvelousWololo has joined #ruby
willfish has quit [Ping timeout: 255 seconds]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 240 seconds]
desnudopenguino1 is now known as desnudopenguino
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
Linux_Kerio has quit [Ping timeout: 255 seconds]
graywolf has quit [Quit: WeeChat 4.0.4]
MarvelousWololo has quit [Read error: Connection reset by peer]
Vonter has quit [Ping timeout: 255 seconds]
Vonter has joined #ruby
FetidToot8 has joined #ruby
FetidToot has quit [Ping timeout: 255 seconds]
FetidToot8 is now known as FetidToot