yebyen

Activity Graph

Page 1 of 2 | Next »

2019-02-26

[18:38:59] yebyen: Quit: later

2019-01-12

[15:35:47] yebyen: thanks phaul for that explanation, I just re-read it all and that really demystified it for me
[15:36:05] yebyen: any_instance_of(Object) really is way more nebulous than it needed to be
[15:36:44] yebyen: expect(subject).to receive would work just as well
[15:37:20] yebyen: i'm just not accustomed to method names starting with capital letters
[15:38:00] yebyen: that's a go convention i could've recognized though, i'm pretty sure... i don't use go much, but every function exposed by a module has to be capitalized afaik
[15:38:07] yebyen: that's probably accidental
[15:38:22] yebyen: but I get it now, it's not ClassName()
[15:38:38] yebyen: it's (implied self) .Method()
[15:39:19] yebyen: there is probably a bug in there resulting in that stack too deep infinite recursion
[15:39:35] yebyen: but could also be, if i went down the rabbit hole i'd find an implementation detail of rspec that explains why it has to be like this
[15:40:13] yebyen: i bet i find an issue if i search for it that says "don't intercept methods on instance of Kernel, ya big dummy"
[15:40:54] yebyen: or maybe i'm the first person to think of doing that... yeah no

2019-01-11

[15:31:10] yebyen: has joined #ruby
[15:32:06] yebyen: I'm upgrading my stuff to 2.6 and I have a test that does: expect(BigDecimal).to receive(:new).with(any_args).at_least(:once).and_call_original
[15:32:39] yebyen: the test is called "uses BigDecimal" and it's only there to verify that nobody decided to replace the implementation with float or something less safe
[15:33:02] yebyen: and it doesn't work anymore because BigDecimal.new is deprecated, so we're calling BigDecimal like you're supposed to
[15:33:10] yebyen: BigDecimal("1.5") for example
[15:33:21] yebyen: is there a way to capture that in rspec?
[15:33:45] yebyen: i understand that BigDecimal(_,_) is a global method I guess?
[15:33:53] yebyen: is that the same as calling it on Kernel? or instance of Kernel?
[15:34:20] yebyen: ok, I'm on the right track then... so I tried:
[15:34:21] yebyen: expect_any_instance_of(Kernel).to receive(:BigDecimal).with(any_args).at_least(:once).and_call_original
[15:34:34] yebyen: and I got a stack too deep crash
[15:34:47] yebyen: I think expect_any_instance_of works on modules
[15:35:13] yebyen: (it seems to intercept the method call, I think "and_call_original" is what fails)
[15:35:45] yebyen: maybe i'd get better results if I don't try to use any_args
[15:35:55] yebyen: or and_call_original
[15:36:02] yebyen: just explicitly call BigDecimal(xyz) myself instead
[15:37:18] yebyen: i guess i could also just take this test out
[15:38:45] yebyen: it proves that i took your param passed in and actually sent it forward to the bigdecimal library
[15:39:15] yebyen: is there a good reason to make this deprecation? I really don't understand why it was done
[15:39:19] yebyen: i've never heard of a global function before
[15:39:31] yebyen: is there anything else that you call like BigDecimal(xyz)?
[15:40:30] yebyen: https://github.com/ruby/bigdecimal/blob/04f782f31b496dc250a02e0ee43f84c907b4aa25/ext/bigdecimal/bigdecimal.c#L3298
[15:41:27] yebyen: not really, if it was just a regular method then i'd be able to find a "def" for it somewhere
[15:41:37] yebyen: i'm pretty sure this is where it's defined though, in some C code
[15:41:51] yebyen: i'm not a ruby kernel developer though so i could be completely wrong about that
[15:42:56] yebyen: i guess it's documented as a regular instance method
[15:42:59] yebyen: http://ruby-doc.org/stdlib-2.6/libdoc/bigdecimal/rdoc/Kernel.html
[15:44:41] yebyen: i'm sure it has something to do with the way it's defined
[15:44:45] yebyen: this is probably a bug in rspec
[15:45:51] yebyen: i've got 9 failing tests to fix and this is the easiest one of them, so
[15:46:00] yebyen: i'll remove that line
[15:47:26] yebyen: wow cool, and I actually know what a module function is because i've been using them :D
[15:47:34] yebyen: that clarifies that for me
[15:48:04] yebyen: so I really should be able to intercept Kernel.BigDecimal()
[15:48:14] yebyen: rather than "instance of kernel"
[15:48:49] yebyen: i think that's how testing module functions worked anyway
[15:49:20] yebyen: if it's a module function, there is no instance it's called on
[15:54:23] yebyen: when did http error response bodies stop being nil and start being blank?
[15:54:29] yebyen: this one has bitten me before
[15:55:51] yebyen: this is the restclient gem I think
[15:56:05] yebyen: probably between whatever version i upgraded from and whatever version I upgraded to, never mind...
[15:59:39] yebyen: awesome thanks for doing that!
[16:15:44] yebyen: phaul: should I report this to rspec? or are you already going to
[16:17:58] yebyen: ok, i'll iterate on it for a day or so and see if i can find out more about what's going wrong before I bother anyone else with it
[16:18:01] yebyen: thanks for the gist
[16:33:57] yebyen: aha well that makes sense because there is no instance
[16:34:13] yebyen: but it's not intercepting at all if you say expect(Module).to receive
[16:34:48] yebyen: or would you say that there is actually an instance of the kernel here wherever we're calling BigDecimal
[16:41:04] yebyen: that works
[16:41:18] yebyen: :thumbsup:
[16:46:28] yebyen: so what you have in the gist now works too
[16:46:43] yebyen: that makes more sense and i think it's how i've been using rspec to test module functions
[16:46:58] yebyen: (just pretend that it's an instance of the module)
[17:04:18] yebyen: if i said that, it's not what i meant
[17:04:36] yebyen: i just want to be sure that they're not deciding unilaterally that "bigdecimal is no longer needed"
[17:04:54] yebyen: if they're going to do that, they're on the hook to remove the test that asserts "we used bigdecimal because it's safe" too
[17:05:39] yebyen: the expectation isn't on the object, the expectation is that we're calling a method BigDecimal
[17:05:43] yebyen: (on what) was the question
[17:05:46] yebyen: Object, not Kernel
[17:05:50] yebyen: good enough for me
[17:06:00] yebyen: *isn't on Object

2018-05-04

[01:08:04] yebyen: Ping timeout: 260 seconds

2018-05-02

[01:29:04] yebyen: blackcross: did you figure it out? the answer I think, is to configure nginx
[01:29:29] yebyen: by default rails in production mode will not serve assets, I think
[01:29:50] yebyen: so nginx needs to know the location of the precompiled assets and redirect any requests for assets into there
[01:30:21] yebyen: there are also modern(er) webpackerish ways to do this I guess, but I think they all involve this kind of reconfiguration of nginx
[01:30:32] yebyen: the block in my nginx.conf (i'll go fetch it)
[01:32:30] yebyen: well, why would you want to see my nginx conf when there are perfectly fine blog post examples
[01:32:33] yebyen: http://vladigleba.com/blog/2014/03/27/deploying-rails-apps-part-4-configuring-nginx/
[01:32:36] yebyen: blackcross: ^ this blog post
[01:33:09] yebyen: the line to nota bene is >> try_files $uri/index.html $uri @unicorn;
[01:34:02] yebyen: and also this block >> location ^~ /assets/ {
[01:35:16] yebyen: look at that, a dev error page
[01:35:54] yebyen: at least it doesn't dump you out in a dev console
[01:36:05] yebyen: index of routes is half as bad though
[01:36:47] yebyen: hah, I wasn't going to check :D
[01:37:33] yebyen: turbolinks!
[01:38:19] yebyen: sorry i'm new here, is this a trope already
[01:38:44] yebyen: leeeroy, turbolinks!
[02:03:45] yebyen: the copy on this page
[02:03:47] yebyen: What We Do
[02:03:49] yebyen: Behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics.
[02:03:57] yebyen: ^ this is pure gold
[02:04:35] yebyen: " I cannot tell you how beautiful it is to see again... "
[02:05:12] yebyen: it's pretty clear this is not configured in production env because it is not a production website :D
[02:06:13] yebyen: However "Heroku recommends always using RAILS_ENV=production"
[02:06:28] yebyen: paraphrasing because I can't find the citation
[02:07:03] yebyen: if your dev environment is deployed from CI especially, and you want it to be nearly perfect copy of prod
[02:07:10] yebyen: it makes sense to use RAILS_ENV=prod
[02:07:39] yebyen: so that everything (else) also is to be configured just like in prod
[02:08:25] yebyen: I guess that's probably `staging` then, not dev so much
[02:08:48] yebyen: this applies I think though even if you're not using Heroku or CI

2018-05-01

[19:34:48] yebyen: does anyone know off the top of your head if it is mandatory to pass params as :symbols to params.require and params.permit?
[19:35:03] yebyen: or is it allowed to pass strings in place of symbols
[20:40:46] yebyen: FrostCandy: do you know &. or the try! method
[20:41:16] yebyen: or actually, the method you're looking for is Hash#dig
[20:41:30] yebyen: r.dig('one', 'two').present?
[20:41:43] yebyen: (or r.dig('one', 'two').nil?)
[20:42:11] yebyen: unemployment scam maybe!
[20:42:23] yebyen: "i had an interview and they didn't hire me"
[20:42:46] yebyen: that's probably not an unemployment scammer I guess
[20:43:11] yebyen: probably overslept his 2pm alarm, if it's a college student
[20:43:38] yebyen: isn't that exactly the method you always wished you knew about?
[20:43:42] yebyen: it's new in ruby 2.3 i think
[20:44:08] yebyen: &. is the safe navigation operator
[20:44:13] yebyen: almost as cool
[20:44:46] yebyen: and i mentioned try! specifically because i've been writing mega code golfs to get try(:x) to do what try!(:x) does
[20:47:11] yebyen: yeah i'm guilty myself, i need rubocop in a precommit hook
[20:51:01] yebyen: i got a little precommit happy and put all kinds of expensive tests in the precommit hooks
[20:51:12] yebyen: then i got in the habit of running `git commit -n`
[20:51:26] yebyen: then I finally got rid of all the precommit hooks
[20:51:46] yebyen: now we have CI so I don't really need to run the tests before I push
[20:52:22] yebyen: but rubocop would still be handy for telling me things like "you don't need this unless assignment, just use ||="

2018-04-25

[13:23:29] yebyen: has joined #RubyOnRails
[13:23:48] yebyen: hmm! so I was at RailsConf this past week and heard a talk about multiple databases in Rails
[13:25:14] yebyen: well the theme of the talk is that it's currently still too hard
[13:25:24] yebyen: and that it's going to get better in rails 6
[13:25:41] yebyen: and I was thinking back to my last job and the replicating mysql databases we had, without which we could not have operated at the scale that we did!
[13:26:35] yebyen: my app will probably have 10 concurrent users max peak and they will each operate on mostly just a single record at a time
[13:26:39] yebyen: so this is not a concern for me now
[13:27:04] yebyen: but i was coming to see if anyone uses the octopus gem since that seems to be the answer to my question
[13:27:34] yebyen: "how do I send Read operations to a slave and Write operations to the master, unobtrusively through AR"
[13:27:57] yebyen: https://medium.com/kkempin/postgresql-master-slave-replication-on-heroku-with-ruby-on-rails-bf0eb8d69fe
[13:28:35] yebyen: it means that I don't need to build separate UserReader and UserWriter models that point at separate databases
[13:28:47] yebyen: where say, UserWriter < ApplicationRecord
[13:29:05] yebyen: and UserReader < ReaderDatabase
[13:29:20] yebyen: I can just do "User.where" and Rails recognizes that i'm trying to read, so I need the read slave
[13:29:53] yebyen: but if I do "User.new" it says hey, you need to write? i'll send you to the master for writes
[13:31:06] yebyen: the three-tiered config that's being proposed for Rails 6 as i understand it
[13:31:09] yebyen: doesn't handle this
[13:31:17] yebyen: is mainly for sharding
[13:32:24] yebyen: it looks like octopus gem is for my use case
[13:34:18] yebyen: anyway I just wanted to talk about it with someone before I go make an issue on github/rails/rails
[13:41:28] yebyen: or hop onto an existing issue
[15:01:11] yebyen: *.net *.split
[15:03:08] yebyen: has joined #RubyOnRails

2018-04-07

[03:40:05] yebyen: Remote host closed the connection

2018-04-04

[14:14:30] yebyen: can I ask a question of anyone that is using fixtures in rails (with rspec? not sure if that part is important)
[14:15:26] yebyen: the question is, when you invoke "fixtures :whatevers" at the top of your file's first describe block
[14:16:03] yebyen: is that the end of the story or are you later going down and asking for particular fixtures within a given test like whatever(:certain_one)
[14:16:42] yebyen: i am not doing that, and my fixture data is still available during the test
[14:16:53] yebyen: and I'm trying to understand why... if it's because of something I've done, or what version I'm on
[14:23:57] yebyen: http://www.betterspecs.org/#factories <- "Use Factories and not fixtures"
[14:24:03] yebyen: seems to be talking about a different kind of fixture
[15:04:44] yebyen: I adjusted my RSpec config to use database cleaner and truncate before each suite
[15:05:07] yebyen: I don't like it but it works, I can run rspec twice and it doesn't have surprise failures the second time
[18:27:11] yebyen: does anyone know about pre_loaded_fixtures ?
[18:27:23] yebyen: i'm trying to find documentation on it
[18:36:04] yebyen: aha, this is not a popular option because it's not an option in rspec at all!
[18:37:41] yebyen: fcser_: http://api.rubyonrails.org/v5.1/classes/ActiveRecord/FixtureSet.html
[18:38:33] yebyen: and in the 4.2.9 version I'm using too
[18:38:39] yebyen: but it's not an option in RSpec Core config
[19:19:25] yebyen: FLeiXiuS: put the 'pry' gem in there and drop a 'binding.pry' statement on the line before it blows up
[19:19:45] yebyen: then you can `cd f_name` and `ls` and see what kind of methods you have
[19:19:58] yebyen: and run `class` if you want and see what kind of object it really is at that point
[19:20:25] yebyen: pry is better imho, you can run "modules" and get a list of modules in the web console
[19:20:32] yebyen: but "ls" is a thing of beauty
[19:20:53] yebyen: the pry ecosystem!
[19:21:07] yebyen: i am such a poseur, I don't know anything

2018-03-10

[19:26:16] yebyen: has left #ruby: ()

2018-02-27

[09:58:50] yebyen: has joined #ruby

2018-01-24

[07:03:26] yebyen: Ping timeout: 268 seconds
[07:03:42] yebyen: has joined #ruby

2017-12-18

[15:33:39] yebyen: has joined #RubyOnRails
[15:33:44] yebyen: has joined #ruby
[15:34:40] yebyen: does anyone know if there's a way to trap a server error during a (feature) test with capybara? I have this condition that my design spec has promised will never happen, and I want to make sure the right error shows up in the server log when it inevitably happens anyway
[15:35:07] yebyen: i'm using expect { bad_button.click }.to raise_error err_class.constantize
[15:35:28] yebyen: but that does not work because the error is not raised out of the user side
[15:36:42] yebyen: The output from cucumber just tells me that the error was simultaneously not encountered and not handled (it was raised, it wasn't raised...)
[15:36:58] yebyen: this is with Capybara.run_server=true
[15:40:13] yebyen: I mean, I guess I could reconfigure the app to display the error instead of just logging it
[15:40:37] yebyen: but it seems like a lot of trouble for something that was promised not to ever happen, by the admin users, in the specs
[15:41:04] yebyen: i'd rather just display the "something went horribly wrong" page
[15:54:51] yebyen: waseem_: coverage?
[15:55:01] yebyen: it's potentially really bad if that is allowed to pass
[15:55:15] yebyen: (it's a Budget Change object, and there are no budget changes allowed without an approver...)
[15:55:35] yebyen: If this error does not come at this particular time, then a budget change may be allowed through the workflow with no approver :D
[15:57:05] yebyen: I think I'm just going to catch the exception and display it on the "new" page
[15:57:28] yebyen: there's a pretty obvious place to rescue and render 'new'
[16:11:40] yebyen: which of course means I have to make it look pretty... :\

2017-07-29

[01:04:20] yebyen: Ping timeout: 268 seconds

2017-07-18

[18:27:23] yebyen: has joined #RubyOnRails
[18:27:58] yebyen: Greetings, I am wondering if anyone knows how to manipulate sessions in ActionController::Integration::Session
[18:28:01] yebyen: eg in the rails console
[18:28:47] yebyen: I found out that I can do "rails console" and run "app.get '/'" and get back a request response and use this way to do debugging
[18:29:21] yebyen: but my login process goes out to CAS for auth and I'm not sure how the authorization is handled, because it's done by rack-cas
[18:29:39] yebyen: I just need to make sure that session["cas"]["user_id"] is set before the request is handled
[18:30:03] yebyen: but app.session is "not yet loaded"
[18:30:09] yebyen: and when I do set variables in there, they don't seem to stick
[18:30:25] yebyen: new one for me
[18:32:15] yebyen: how do I get an ActionDispatch::Integration::Runner?
[18:32:28] yebyen: in rails console, I just use "app" and find the Integration::Session
[18:33:10] yebyen: i was hoping for a way to get the session so I could manipulate it directly...
[18:33:27] yebyen: this looks like I could set up a session and manipulate it through posts, if I have a post endpoint for what I'm trying to do
[18:34:33] yebyen: its a part of Test::Unit?
[18:34:42] yebyen: i don't seem to have open_session in rails console
[18:35:19] yebyen: no i'm in the console just outside of shell
[18:35:42] yebyen: if you start an interactive rails console eg. 'rails c'
[18:36:02] yebyen: the ActionDispatch::Integration::Session object is available to you as 'app'
[18:36:17] yebyen: i am almost
[18:36:36] yebyen: app.get '/' is roughly equivalent to "get '/'" in an integration test
[18:36:43] yebyen: i think they are actually the same thing
[18:37:11] yebyen: i could disable the actual CAS part of rack-cas for my debugging/testing session
[18:37:36] yebyen: and send a simple post with a username and password to whatever FakeCAS endpoint is listening, like rack-cas does in ENV=test
[18:38:07] yebyen: that might be the best thing to do, because honestly I don't think I need to manipulate the session directly for anything other than to get past my authenticate before
[18:39:01] yebyen: it looks a little bit like this is not exposed as a public API on purpose
[19:23:02] yebyen: havenwood: i wound up just dropping a pry statement in before the point that checks if session['cas']['user'] is set
[19:23:10] yebyen: and setting it when that pry comes along the first time
[19:23:34] yebyen: now I can app.get '/' and follow redirects to my heart's content, session persists without any open_session tricks
[19:23:49] yebyen: i have no idea why just sending a post to /login doesn't work with rack-cas fakecas
[19:24:04] yebyen: i get back a redirect with a blank Location: header
[19:24:30] yebyen: not sure what's supposed to happen after that, but in my browser I wind up logged in
[19:25:11] yebyen: normally the 302 comes with a location target
[19:25:27] yebyen: maybe there's something that isn't set in the rack-cas fakecas middleware when you do it this way
[20:10:36] yebyen: does anyone know what kind of redirect comes with a blank Location: header?
[20:10:54] yebyen: other than, one that goes nowhere
[20:11:19] yebyen: rack-cas seems to be sending me a redirect with no destination, but in my browser it definitely goes
[20:14:56] yebyen: could it be some kind of csrf protection issue?
[20:15:05] yebyen: because I'm not sending any cookies with the first request

2017-07-06

[13:41:54] yebyen: Remote host closed the connection

2017-06-20

[19:23:52] yebyen: and might never affect you, so it's not worth learning
[19:23:59] yebyen: (until it does)
[19:24:19] yebyen: people who are successful at writing tutorials and documentation tend to be very good at understanding this
[19:25:20] yebyen: it's a feature of the language, "convention over configuration"
[19:25:53] yebyen: if something is used everywhere, it is considered a convention, and then you're new and you've never seen it before, and unfortunately this is inevitable too
[19:26:09] yebyen: you'll pick it up! don't be discouraged eindoofus