Activity Graph

Page 1 of 1


[06:03:02] marz_d`ghostman: has joined #ruby
[07:20:29] marz_d`ghostman: I'm trying to test the format of logger, is there like a test specific stream I can use instead of a file?
[13:01:01] marz_d`ghostman: Iambchop: thanks I'll look into it
[13:02:42] marz_d`ghostman: Quit: Page closed


[08:45:40] marz_d`ghostman: has joined #ruby
[08:47:24] marz_d`ghostman: Tried creating a config.rb on my project root to declare some application wide constants. The constants defined in it doesn't seem to be accessible by other parts of my application, specifically under /lib.
[08:59:42] marz_d`ghostman: How do I test in rspec?
[09:02:59] marz_d`ghostman: Quit: Page closed


[05:58:40] marz_d`ghostman: has joined #ruby
[05:59:09] marz_d`ghostman: I already have an existing spec files for some of my .rb files. Is there a command to automatically generate spec files for newly created .rb files?
[06:50:55] marz_d`ghostman: Is it possible to create an instance variable from a module included in a class? Like inside self.included method of a module?
[06:51:52] marz_d`ghostman: baweaver: Where can I view the video?
[06:53:42] marz_d`ghostman: baweaver: I have created a module specifically for Logging which I just want to include in a class. In the said module, I want to create a specific log file for each instance of the class where I include it. So as to separate logging functionalities.
[06:53:53] marz_d`ghostman: or is it going too far?
[06:56:28] marz_d`ghostman: I guess I'll just have to create the logger in the class itself to make it simple
[06:57:08] marz_d`ghostman: Every instance of a class will run a different sync, so I want to log it on different files depending on the directory it is syncing
[07:08:11] marz_d`ghostman: baweaver: Is this a good design though?
[15:14:54] marz_d`ghostman: Quit: Page closed


[04:39:17] marz_d`ghostman: has joined #ruby
[04:39:57] marz_d`ghostman: How do I define a local variable for the given describe block. It appears the last declaration overrides all previous declarations of it.
[08:12:51] marz_d`ghostman: There is a bypass to simulate a failing command via (exit 1); is there anything that will make it output anything?
[08:13:47] marz_d`ghostman: havenwood: Oh, I'm trying to stub a command for rspec though
[08:14:14] marz_d`ghostman: havenwood: Like I want to feed a failing command that outputs to stderr to test if my code is handling it properly
[08:17:02] marz_d`ghostman: Guess I can feed it with (echo 'error' >&2; exit 1)
[15:33:23] marz_d`ghostman: Quit: Page closed


[03:16:43] marz_d`ghostman: Quit: Page closed


[04:48:14] marz_d`ghostman: has joined #ruby
[04:49:03] marz_d`ghostman: Pertaining instance variable, I've seen people assign values to instance variables then create a attr_reader with the same name as the instance variable so they can refer to the instance variable without '@'. How does that work and what's the advantage of doing it?
[06:08:55] marz_d`ghostman: baweaver: I see. Thanks for clarifying that one
[06:10:42] marz_d`ghostman: I'm trying to override a subject inside an inner context. However, it appears that the variable inside the inner context which is suppose to be local inside the context is overriding the subject outisde of the context.
[10:03:43] marz_d`ghostman: when doing tests in rsped for your class method do you put each method test via describe under one whole describe 'Class'?
[10:18:50] marz_d`ghostman: phaul: I'm trying to test each method of my class. So basically I have Rspec.describe Class then describe '#method'. However, my problems is I want to create a subject for each method is that even possible? I tried it but it appears that the subjects overrides each other
[10:20:22] marz_d`ghostman: phaul: Yeah. Also, when testing, I want to terminate after an expect is met. How do I do that? so it won't go on and continue the entire script
[10:24:10] marz_d`ghostman: I see, I'll try looking into that
[10:26:07] marz_d`ghostman: just found out after block gets executed before any ensure


[05:20:57] marz_d`ghostman: has joined #ruby
[05:38:10] marz_d`ghostman: I have a test in rspec: I'm just quite confused if I intentionally make the first expect to fail, it doesn't give me an error that that expects fails instead it gives me an error that the second expect failed.
[09:14:33] marz_d`ghostman: does system/backticks wait for the child process to finish or does it do it asynchronously?
[09:25:03] marz_d`ghostman: tbuehlmann: oh so the only additional feature Open3 gives is the capturing of stdout and stderr
[09:25:45] marz_d`ghostman: Is there a way I could capture stderr using plain old backticks though?
[11:36:15] marz_d`ghostman: Is it a good practice for a constructer of an object to assign the properties of an argument(object) as its own properties? Or will it be better to just immediately access the argument/object's properties?
[11:37:22] marz_d`ghostman: E.g. 'job-name', type: 'job-type) then you pass this object to, type: Job.type)? or just immediately use inside Task?
[11:39:13] marz_d`ghostman: phaul: so Job)? WHy?
[11:48:28] marz_d`ghostman: job: job seems simple for me too. Perhaps I'll just put in the documentation what job properties is required before it gets passed in to task
[13:00:26] marz_d`ghostman: phaul: Yeah, thanks for the suggestion. Guess tasks just executes job, so having job inside task makes sense.
[16:42:31] marz_d`ghostman: Ping timeout: 256 seconds


[07:59:49] marz_d`ghostman: has joined #ruby
[08:04:14] marz_d`ghostman: Having multiple expect inside an it block doesn't seem to work. Exit doesn't seem to be invoke as I'm getting 'expected :exit to be thrown, got nothing' error:
[08:31:28] marz_d`ghostman: so the statements inside after(:each) is also counted inside the it blocks, I have expect(File).to receive(:delete).with(arguments) inside my it block and one inside my after(:each), it counts twice.
[09:52:35] marz_d`ghostman: Quit: Page closed


[08:55:38] marz_d`ghostman: Quit: Page closed


[08:36:15] marz_d`ghostman: has joined #ruby
[08:37:18] marz_d`ghostman: I'm stubbing exit on my code by allow(object).to receive(:exit).and_throw :exit, then I have expect( :exit, but I'm getting uncaught throw :exit. Doesn't the expect automatically catch it though?
[09:09:47] marz_d`ghostman: my rescue code has a log function and exit, how do I expect two function calls? it seems calling expect ( receive(:log) and expect( raise_error(SystemExit) differently will not stub the exit on first call
[09:25:39] marz_d`ghostman: phaul:
[09:25:45] marz_d`ghostman: phaul: sorry for the delay
[09:28:06] marz_d`ghostman: I'm trying to expect that invokes the log_error and then exit. But having two expects doesn't work as the first one would exit the rspec when getting to the line in the code where it really exits
[09:33:05] marz_d`ghostman: phaul: that succeeds, expect { }.to raise_error(SystemExit). What I'm trying to do is also expect :log_error to get invoked before SystemExit
[09:58:45] marz_d`ghostman: phaul: Yes, that is correct.
[10:03:17] marz_d`ghostman: phaul: If you stub :exit to do nothing, the code will run though the rest of it which it shouldn't cause it should exit
[10:03:56] marz_d`ghostman: Is there something like allow to receive(:exit) continue with the next test? something like that
[10:18:15] marz_d`ghostman: phaul: Awesome! I've been searching and working on this one for a couple days. Just what I need. You're a lifesaver. Thanks man
[10:24:31] marz_d`ghostman: phaul: By the way, isn't the best convention for rspec structure goes something like this?
[10:24:59] marz_d`ghostman: phaul: Cause rubocop seems to be giving me warning about my Rspec.describe Class having too many lines currently [52/25]
[10:27:49] marz_d`ghostman: Ah, okay. Thought I'm doing something wrong cause I'm not yet done with the tests and I'm currently way beyond the 25 line rubocop is complaining about, hehe :)
[10:29:08] marz_d`ghostman: I'll do just that. By the way, you keen on blockchains?
[10:29:27] marz_d`ghostman: If so, you think ruby has a place on that field?
[10:31:01] marz_d`ghostman: haha, you have a point though
[10:33:56] marz_d`ghostman: just curious cause all I see being used are java and c++
[10:34:55] marz_d`ghostman: guess I'll do that :)
[10:36:20] marz_d`ghostman: I'm not really that familiar with binary trees and the likes since I don't have a good computer science background. Just jumped into programming head first. Any books or resources you can recommend to reinforce a layman's computer science fundamentals? :D


[09:40:05] marz_d`ghostman: has joined #ruby
[09:40:37] marz_d`ghostman: How do I configure rspec so it won't exit the whole suite when my code exits? I have a test testing a failing case where my code exits, and rspec exit totally not continuing the rest of the suites
[09:48:38] marz_d`ghostman: status402: I have something like this: If I stub exits it continues to trigger syn when shouldn't have to
[09:54:46] marz_d`ghostman: Yeah, the code just does what it does. I have a test not expecting for the next method to be invoked though since it will exit. Just wanted it not to end rspec though
[09:56:00] marz_d`ghostman: hmm, I should just test that it received exit, instead of testing not_to receive(:the_next_method)
[09:56:24] marz_d`ghostman: nah this class will run a job, and exits if it something fails
[09:57:38] marz_d`ghostman: Is there something like allow(object). to recieve(:exit) and continue to next step though?


[06:56:31] marz_d`ghostman: has joined #ruby
[06:56:47] marz_d`ghostman: Is it possible to stub a gem I am using in my script?
[06:56:52] marz_d`ghostman: for rspec testing?
[07:01:11] marz_d`ghostman: baweaver: How? I'm currently using double, doesn't seem to be working though. I'm trying to test that my conditionals are working if the gem succeeds/fails.
[07:46:19] marz_d`ghostman: baweaver: I'll try that, thanks.
[07:54:26] marz_d`ghostman: baweaver: Can't seem to make it work though. Am I missing something?
[08:04:09] marz_d`ghostman: hmmm, tried allow(Marz::Rsync).to receive(:run).with(any_args).and_yield(result), but output doesn't seem to be stubbed
[08:04:30] marz_d`ghostman: oh my bad, it is
[08:24:25] marz_d`ghostman: Does Rspec.describe run any methods prior to the test? I have a puts method inside my class and it seems to be invoked before the tests
[08:33:59] marz_d`ghostman: tbuehlmann: I have this method: and the puts gets invoked before any tests. Does that mean that the gem(Marz::Rsync) method gets invoked too?
[08:38:50] marz_d`ghostman: cause puts result.output is invoked apparently
[13:36:04] marz_d`ghostman: Quit: Page closed


[16:25:04] marz_d`ghostman: has joined #ruby
[16:25:17] marz_d`ghostman: My rspec tests has no failures but it says it failed
[16:36:05] marz_d`ghostman: havenwood: Am I testing my class correctly though?
[16:36:19] marz_d`ghostman: modified the spec now I'm getting failures on the examples
[17:04:26] marz_d`ghostman: phaul: replaced expect(sync) to expect( and it passes for all tests, weird
[17:04:44] marz_d`ghostman: phaul: no for the raise_error but for the .to receive
[17:10:30] marz_d`ghostman: interesting, I removed the subect { } and placed the after the it, and it passes
[17:10:54] marz_d`ghostman: ah rspec fails when my class exits with 1
[17:12:48] marz_d`ghostman: I have a block to exit 1 which I'm testing. If that gets invoked it exits 1 and also causes rspec to fail
[17:28:32] marz_d`ghostman: phaul: Oh, it means it invokes the log_error if pre_cmd fails
[17:29:44] marz_d`ghostman: you see, the Sync class accepts a mirror object argument. the mirror object contains the pre_cmd value, which the sync runs. If that fails, it should invoke the :log_error with the value which in the test is set to 'pre_cmd' literally
[17:34:07] marz_d`ghostman: phaul: invokes execute_cmd, then execute_cmd invokes log_error
[17:36:35] marz_d`ghostman: phaul: How do I configure rspec not to fail if the class being tested exits with 1?
[17:37:42] marz_d`ghostman: hmm, well thinking of it, since I'm already logging the error, I shouldn't exit with 1
[17:42:42] marz_d`ghostman: phaul: how about that? still receiving error that the method is not being received though
[17:44:04] marz_d`ghostman: uncommented the subject, and removed the double, it passes now
[17:46:23] marz_d`ghostman: everything is passing now, I can rest peacefully, lol
[17:46:33] marz_d`ghostman: phaul: thanks for the help
[18:23:54] marz_d`ghostman: Quit: Page closed


[06:52:44] marz_d`ghostman: I have this test: but it seems to pass whether I put expect_any_instance_of(DB).to receive(:update_sync_result_status) or expect_any_instance_of(DB).not_to receive(:update_sync_result_status)
[08:51:43] marz_d`ghostman: How to best design a class for database interaction?
[09:52:03] marz_d`ghostman: I have a module_function, how do I test it was invoked in rspec?
[21:36:27] marz_d`ghostman: Quit: Page closed


[00:08:37] marz_d`ghostman: I'm creating a ruby script with domain models. Do i have to place the domain models under the module though?
[00:08:54] marz_d`ghostman: like I have a gem rise-mirror_manager. So there would be modules Rise::MirrorManager
[00:09:09] marz_d`ghostman: Should I place the domain model under Rise::MirrorManager::?
[00:18:37] marz_d`ghostman: havenwood: okay thanks. When testing though, how do I make it so I wont have to define just
[00:21:39] marz_d`ghostman: havenwood: I see
[01:09:11] marz_d`ghostman: I added pg as a dependency on my gemspec via spec.add_dependency 'pg' but I"m getting an error when I run bundle exec rake --tasks
[01:09:19] marz_d`ghostman: Did a bundle install --path .bundle
[01:17:15] marz_d`ghostman: havenwood: Guess I needed the libpq-dev package installed on my system
[02:42:59] marz_d`ghostman: has joined #ruby
[02:43:19] marz_d`ghostman: I'm using standalone_migrations, and when running bundle exec rake db:new_migration[create_tablename], it seems that the command is nto found
[02:45:05] marz_d`ghostman: Okay, got it working with db:new_migration name=tableName
[03:28:25] marz_d`ghostman: Ping timeout: 256 seconds
[03:30:59] marz_d`ghostman: has joined #ruby
[03:31:04] marz_d`ghostman: How does this snippet work?
[03:31:09] marz_d`ghostman: what's with the <<*?
[03:39:01] marz_d`ghostman: baweaver: thanks
[03:39:21] marz_d`ghostman: baweaver: though migration only created the table under development and not test
[03:41:13] marz_d`ghostman: Does rspec automatically use the test environment?
[03:41:22] marz_d`ghostman: or do I have to set that up?
[03:50:18] marz_d`ghostman: How do I db:migrate for test environment?
[04:19:20] marz_d`ghostman: havenwood: I'm not using rails though, just plain ruby however, RAILS_ENV=test works :)


[09:37:38] marz_d`ghostman: has joined #ruby
[09:37:44] marz_d`ghostman: What's a good ORM for plain ruby?
[09:52:01] marz_d`ghostman: TvL2386: hmmm I'm looking into trying new technology. Perhaps MongoDB
[09:53:00] marz_d`ghostman: TvL2386: Nah, I think I'll stick with MySQL and use activerecord
[10:01:32] marz_d`ghostman: chichou_: I tried searching for one, it appears activerecord is the most popular
[22:55:31] marz_d`ghostman: I'm using dispatch and I have these lines: autocmd FileType ruby let b:dispatch = 'rspec %' nnoremap <F9> :Dispatch!<CR> but I'm getting an erorr: || make: *** No targets specified and no makefile found. Stop.
[22:55:41] marz_d`ghostman: I can run :Dispatch rspec % fine though


[20:17:20] marz_d`ghostman: has joined #ruby
[20:30:24] marz_d`ghostman: I have a gem mygem-my_util, so in my lib is ./lib/mygem/my_util/util/util.rb How do I describe it in RSpec? I tried Mygem/::Myutil::util::util
[20:35:22] marz_d`ghostman: havenwood: the util.rb is the main class and the util folder will contain the main class along with any modules and classes that needs to be created
[20:35:57] marz_d`ghostman: havenwood: Do I have to define a require somewhere? cause it's not working though
[20:39:01] marz_d`ghostman: havenwood:
[20:39:21] marz_d`ghostman: It's giving me the error: uninitialized constant Rise::MirrorManager::Sync
[20:40:43] marz_d`ghostman: Tried adding require 'rise/mirror_manager', didn't help though
[20:43:18] marz_d`ghostman: havenwood: I'm assuming I'll be creating another class for sync purposes or a module perhaps. To organize it, I'll just have all sync related files inside the sync/ dir
[20:47:45] marz_d`ghostman: Ping timeout: 252 seconds


[06:50:17] marz_d`ghostman: apeiros: Why can I declare a module, a method inside it and invoke the inject(:+) method directly? I though I need to include Enumerable first?
[12:26:46] marz_d`ghostman: Ping timeout: 246 seconds


[16:08:44] marz_d`ghostman: has joined #ruby
[16:09:12] marz_d`ghostman: Why can I declare a module, a method inside it and invoke the inject(:+) method directly? I though I need to include Enumerable first?


[05:49:55] marz_d`ghostman: has joined #ruby
[05:50:28] marz_d`ghostman: with ruby's logger, can it be customized to roll logs for everytime the app runs instead of daily/weekly/monthly?
[06:13:59] marz_d`ghostman: baweaver: I currently have this one, formatter: proc {|severity, datetime, progname, msg| "[#{}:#{Thread.current.object_id}][#{datetime}] #{severity} -- #{msg}\n" })
[06:14:11] marz_d`ghostman: baweaver: It seems to rotate daily
[06:15:19] marz_d`ghostman: baweaver: I'll just set the suffix though, maybe it gets appended due to it having the same suffix
[06:39:46] marz_d`ghostman: is Time.parse() still supported in Ruby 2.4? Cant' seem to see it here:
[07:07:53] marz_d`ghostman: How do I make this shortcut work? date = DateTime.parse('2018-09-07 13:38:38 +0800') { |date| date.strftime('%a,%d %b-%H:%M:%S')}
[08:46:16] marz_d`ghostman: If I pass a shift_age: 10 to, it will keep 10 logs files right?
[20:17:12] marz_d`ghostman: Quit: Page closed


[08:45:53] marz_d`ghostman: has joined #ruby
[09:14:24] marz_d`ghostman: I'm using => 8) to generate report. Is there a better alternative for it though?
[09:18:56] marz_d`ghostman: apeiros: something that could format an email that would be consistent
[09:19:20] marz_d`ghostman: apeiros: I'm sending it to a ticketing system, and it appears the format changes though
[09:20:27] marz_d`ghostman: apeiros: I'm using it to format an email though:
[09:33:22] marz_d`ghostman: hmmm, i don't how to start using this with just ruby and not rails, hahaha. anyway thanks dude I'll give this a shot, seems pretty cool
[13:27:31] marz_d`ghostman: So with slim, what's the difference between the layout and the content?
[13:35:37] marz_d`ghostman: So how do I pass a local variable to a slim template?
[14:16:05] marz_d`ghostman: darix: doesn't matter, no channel for it anyway. hehehe, was just hoping someone has used it here :)
[17:34:28] marz_d`ghostman: Quit: Page closed


[07:07:39] marz_d`ghostman: has joined #ruby
[07:08:50] marz_d`ghostman: If I want to serve a fiel generated by ruby via apache, do I need to use some framework like sinatra or RoR or can I simply use an .rb file?
[07:14:42] marz_d`ghostman: baweaver: can you suggest anything? I want something that would look like this:
[07:16:29] marz_d`ghostman: baweaver: not a lot when it comes to these kind of stuff. Just a webpage serving directories/files
[07:16:46] marz_d`ghostman: baweaver: cause I've been using ruby on my other scripts :)
[07:24:01] marz_d`ghostman: hmmm, maybe I'll give nodejs a try then
[07:26:02] marz_d`ghostman: apeiros: Will it be simple to just use sinatra?
[07:28:27] marz_d`ghostman: I guess defining simple isn't that simple, hehe. Just require sinatra, write ruby code have it serve the files, then voila!? haha, haven't tried sinatra though so I wouldn't know what I would be going through :)
[07:43:24] marz_d`ghostman: Quit: Page closed
[18:21:09] marz_d`ghostman: has joined #ruby
[18:21:39] marz_d`ghostman: How do I get the right size of a directory? File.stat(dir).size seems to return an incorrect one.
[18:35:06] marz_d`ghostman: havenwood: apeiros thanks
[18:36:37] marz_d`ghostman: havenwood: oh, also the subdirectories, I want the size of everything in the given directory
[18:39:25] marz_d`ghostman: havenwood: just what I've searched, find module, hehe, but in ruby 2.4
[18:42:10] marz_d`ghostman: havenwood: isn't the directory size derived from all the files inside it?
[18:43:50] marz_d`ghostman: havenwood: so a directory can have a different size of itself?
[18:47:09] marz_d`ghostman: havenwood: ah I get it now, everything is a file in unix
[19:22:42] marz_d`ghostman: havenwood: tried issuing a command on my temrinal `du -s -B1` there seems to be a difference, it says 61440, but in the browser it only has 55943
[19:24:54] marz_d`ghostman: havenwood: Find.find(dir).sum &File.method(:size)
[19:27:12] marz_d`ghostman: havenwood: but it shows a greater size
[19:29:17] marz_d`ghostman: havenwood: that would mean the symbolic links has greater size than those files they reference. Plausible
[19:33:00] marz_d`ghostman: havenwood: still the same size as before, 61440
[19:33:18] marz_d`ghostman: havenwood: that did it
[19:33:46] marz_d`ghostman: --apparent-size print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, and the like
[19:34:10] marz_d`ghostman: havenwood: don't really understand that one haha
[19:35:19] marz_d`ghostman: havenwood: nope, just plan ext4
[19:37:27] marz_d`ghostman: havenwood: I'll give that a read, thanks for the help. I appreciate it. :)
[19:57:01] marz_d`ghostman: Quit: Page closed


[05:08:19] marz_d`ghostman: has joined #ruby
[05:10:03] marz_d`ghostman: Any reason why shelljoin doesn't seem to work when I test it on irb.
[05:12:26] marz_d`ghostman: silly me, I have to require 'shellwords' sorry about that
[10:00:22] marz_d`ghostman: Is there anything I need to require to make `match` work in irb?
[21:32:15] marz_d`ghostman: Ping timeout: 252 seconds