#RubyOnRails - 06 January 2019
« Back 1 day Forward 1 day »
[07:03:20] avalice: in form_with/form_for, why does label: <%= f.email_field :email %> not generate a <label> html element
[17:29:52] catbusters: Hi! I'm trying to use Grape to build an API, and I keep coming across examples that show `get "", root: :something`. What is the `root` supposed to do?
[21:14:59] mksybr: I'm getting URI::InvalidURIError: bad URI(is not URI?): http://example.com but git grep 'http://example.com' has no results? Where should I look. Its when I run tests.
[21:18:15] Radar: mksybr: /home/malik/Workspace/blog/test/controllers/articles_controller_test.rb:20:in `block (2 levels) in <class:ArticlesControllerTest>'
[21:18:36] Radar: (the way I found that was to look through the stacktrace until I found the first line from your application)
[21:19:18] Radar: The actual error you're seeing is: URI::InvalidURIError: bad URI(is not URI?): http://www.example.com:80#<Article:0x000055cf590f3c68>
[21:19:30] Radar: Where the end of the URL containing the .inspect'd version of the Article is invalid.
[21:20:34] Radar: Given this is a controller test, you should be making requests to the controller's actions. Therefore "post :create" instead of "post @article"
[21:23:45] mksybr: Also is there an easy way to know which .post() that is other than scrolling thru `ri post`
[21:25:02] Radar: The post method is this one: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/testing/integration.rb#L21
[21:25:16] Radar: You can see that file mentioned in the line above the last articles_controller_test stacktrace.
[21:25:41] Radar: Why are you inheriting a controller test from ActionDispatch::IntegrationTest? That seems strange to me. Maybe I am not up-to-date with the latest things that happen in Rails apps.
[21:26:15] mksybr: @Carpetsmoker Integration tests have replaced TestCase in Rails 5. – ArtOfCode Jul 17 '16 at 22:34
[21:26:15] mksybr: from https://stackoverflow.com/questions/35925504/uriinvalidurierror-bad-uriis-not-uri-testing-rails-controllers
[21:27:26] Radar: I've been using RSpec for yonks and so I'm not up-to-speed with the latest and greatest in MiniTest / Test::Unit lands.
[21:30:54] cnsvc: Radar: https://dpaste.de/T3JM it crashes whenever try to connect mysql like rake db:migrate
[21:32:15] Radar: cnsvc: I noticed two things. Your stacktrace contains this line: /usr/local/var/rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/activesupport-4.2.10
[21:32:35] Radar: The root of the problem seems to be this: /usr/local/var/rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/mysql2-0.4.10/lib/mysql2/mysql2
[21:33:08] Radar: 0.4.10 was released in November 2017. There's a new release of mysql, 0.5.2, released in July 2018. Does upgrading this mysql2 gem fix your issue?
[21:35:07] Radar: cnsvc: Could you update the log to show the same issue with those versions? Then I can definitely confirm it is the same thing at my end.
[22:02:56] mksybr: Radar fixtures or factories used with rspec? ^F my rspec book and nothing bout either came up, are they not used? Just hardcode the data into tests?
[22:03:27] mksybr: Like if for instance if you have a test with a controller that validates: presence: true or what ever
[22:11:13] Radar: cnsvc: Thanks very much for that. I am not sure what is happening here. I would suggest filing an issue on the mysql2 repo?