Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "rspec"
-
I'm editing the sidebar on one of our websites, and shuffling some entries. It involves moving some entries in/out of a dropdown and contextual sidebars, in/out of submenus, etc. It sounds a little tedious but overall pretty trivial, right?
This is day three.
I learned React+Redux from scratch (and rebuilt the latter for fun) in twice that long.
In my defense, I've been working on other tasks (see: Alerts), but mostly because I'd rather gouge my freaking eyes out than continue on this one.
Everything that could be wrong about this is. Everything that could be over-engineered is. Everything that could be written worse... can't, actually; it's awful.
Major grievances:
1) The sidebars (yes, there are several) are spread across a ridiculous number of folders. I stopped counting at 20.
2) Instead of icon fonts, this uses multiple images for entry states.
3) The image filenames don't match the menu entry names. at all. ("sb_gifts.png" -> orders); active filenames are e.g. "sb_giftsactive.png"
4) The actions don't match the menu entry names.
5) Menu state is handled within the root application controller, and doesn't use bools, but strings. (and these state flags never seem to get reset anywhere...)
6) These strings are used to construct the image filenames within the sidebar views/partials.
7) Sometimes access restrictions (employee, manager, etc.) are around the individual menu entries, sometimes they're around a partial include, meaning it's extremely difficult to determine which menu entries/sections/subsections are permission-locked without digging through everything.
8) Within different conditionals there are duplicate blocks markup, with duplicate includes, that end up render different partials/markup due to different state.
9) There are parent tags outside of includes, such as `<ul>#{render 'horrific-eye-stabbing'}</ul>`
10) The markup differs per location: sometimes it's a huge blob of non-semantic filthiness, sometimes it's a simple div+span. Example filth: section->p->a->(img,span) ... per menu entry.
11) In some places, the markup is broken, e.g. `<li><u>...</li></u>`
12) In other places, markup is used for layout adjustments, such as an single nested within several divs adorned with lots of styles/classes.
13) Per-device layouts are handled, not within separate views, but by conditionally enabling/disabling swaths of markup, e.g. (if is_cordova_session?).
14) `is_cordova_session` in particular is stored within a cookie that does not expire, and within your user session. disabling it is annoying and very non-obvious. It can get set whether or not you're using cordova.
15) There are virtually no stylesheets; almost everything is inline (but of course not actually everything), which makes for fun layout debugging.
16) Some of the markup (with inline styling, no less) is generated within a goddamn controller.
17) The markup does use css classes, but it's predominately not for actual styling: they're used to pick out elements within unit tests. An example class name: "hide-for-medium-down"; and no, I can't figure out what it means, even when looking at the tests that use it. There are no styles attached to that particular class.
18) The tests have not been updated for three years, and that last update was an rspec version bump.
19) Mixed tabs and spaces, with mixed indentation level (given spaces, it's sometimes 2, 4, 4, 5, or 6, and sometimes one of those levels consistently, plus an extra space thereafter.)
20) Intentional assignment within conditionals (`if var=possibly_nil_return_value()`)
21) hardcoded (and occasionally incorrect) values/urls.
... and last but not least:
22) Adding a new "menu sections unit" (I still haven't determined what the crap that means) requires changing two constants and writing a goddamn database migration.
I'm not even including minor annoyances like non-enclosed ternaries, poor naming conventions, commented out code, highly inefficient code, a 512-character regex (at least it's even, right?), etc.
just.
what the _fuck_
Who knew a sidebar could be so utterly convoluted?6 -
Testing hell.
I'm working on a ticket that touches a lot of areas of the codebase, and impacts everything that creates a ... really common kind of object.
This means changes throughout the codebase and lots of failing specs. Ofc sometimes the code needs changing, and sometimes the specs do. it's tedious.
What makes this incredibly challenging is that different specs fail depend on how i run them. If I use Jenkins, i'm currently at 160 failing tests. If I run the same specs from the terminal, Iget 132. If I run them from RubyMine... well, I can't run them all at once because RubyMine sucks, but I'm guessing it's around 90 failures based on spot-checking some of the files.
But seriously, how can I determine what "fixed" even means if the issues arbitrarily pass or fail in different environments? I don't even know how cli and rubymine *can* differ, if I'm being honest.
I asked my boss about this and he said he's never seen the issue in the ten years he's worked there. so now i'm doubly confused.
Update: I used a copy of his db (the same one Jenkins is using), and now rspec reports 137 failures from the terminal, and a similar ~90 (again, a guess) from rubymine based on more spot-checking. I am so confused. The db dump has the same structure, and rspec clears the actual data between tests, so wtf is even going on? Maybe the encoding differs? but the failing specs are mostly testing logic?
none of this makes any sense.
i'm so confused.
It feels like i'm being asked to build a machine when the laws of physics change with locality. I can make it work here just fine, but it misbehaves a little at my neighbor's house, and outright explodes at the testing ground.4 -
Out of necessity (or rather: lack of support) I've been neglecting my test suite for the past ~month. Now that one of the beta versions of RSpec has better Rails 6 support, I can finally get back to writing tests. Yay!
I just merged staging into my testing branch, and it's now 344 commits ahead of origin! eep.
So, I've got lots of tests to write. yay.random root loves her tests test suite yay! i didn't break anything! rspec root talks in third person in the tags surprise!3 -
THIS FUCKING DEBUGGER IS IGNORING MY FUCKING BREAKPOINTS
GO TO HELL YOU PIECE OF SHIT
AND RSPEC: FUCK YOUR LIMITED METHOD HIT-COUNTING BULLSHIT! ONE HIT-COUNT PER METHOD FOR THE ENTIRE SPEC IS NOT GOOD ENOUGH!
FJA;KLGAKLGJFKSDHG17 -
How many people have faced this?
When the test suite completes 99% and fails on one stupid test thats not even part of what you updated.5 -
Mocking hardcoded data in frozen constants in Rails is such a fucking pain! Why must this be so difficult!?
asfdfakldsjfuck9 -
Oh, RSpec.
Adding recaptcha tests, I copy a passing login spec
and because I'm bored, I run it again just to check.
I paste in the passing mock
and run it in my new block
and oh no, why are you failing? What the heck!?1 -
RSpec:
Undefined method 'agent_authorization=' for #<Periodic::Payment:0x000000C0FFEE>
Rails Console:
> Periodic::Payment.last.agent_authorization = "PPD"
=> "PPD"
> puts "Hmmm."
=> "Hmmm."rant oh rails you drunk rspec i've spent two hours on this already rails too tired for your shenanigans11 -
It’s late, and stupid RSpec has decided to only mock calls to a particular method in some specs but not in others.
`allow(object).to receive(:method).with(resource_arg).and_return(“some\ntext”)`
Works in a few specs, but not the rest. Why? Who the fuck knows. Probably some shared state between specs that isn’t supposed to happen.
HAHA JUST KIDDING
After refactoring my specs to use unique ‘resource’ names for each call because I’ve had shared state issues before.
and after refactoring my model code to remove a lot of now-unused dependency injection (because maybe it was mocking a different object than got passed in?)
Guess what?
When creating my mock objects, I forgot to link them together. That’s it. A 14-character change. And suddenly they all pass.
Asdjklfajg.
Time for bed.3 -
I want to light this project on fire and walk away. Nothing is making any bloody sense.
According to specs, It’s updating a google wallet object via api, but isn’t generating the data to send along, despite every possible code path hitting that first. It also apparently isn’t calling any of the methods along the way. Obviously this is false, but that’s what the specs are reporting.
It’s also updating the object when nothing has changed. That might be, but shouldn’t, because I can see it calling the `should_update?` method which returns false, and it nopes out after that. so wth.
I’m so ready to never see this craziness ever again.
wtb kerosene or Greek fire pot, good price, pst. open to trade5 -
Spent about six hours writing tests and coding a user log in system for a Rails app last night. Finally finished at around 2:00am. Commited, pushed and merged, then called it a night.
Woke up today and Postgres is refusing to play nice. Spent twenty mins or so fixing that and then ran rspec.... Two thirds of my tests are missing - everything I wrote last night. I check my code and sure enough, they aren't there.
Wild panic ensues for a solid 5 mins before I realise I didn't actually pull the updated master branch after deleting my feature branch last night.
Now I feel like an idiot, but a relieved one. -
More adventures in fixing specs.
This particular failing spec is in an included spec helper; I cannot run the spec itself because rubymine is stupid and doesn't know how. Not kidding. I also don't know the codepath it's actually testing because it's fucking convoluted, so I need (rather: want) a debugger to progress. I put breakpoints everywhere I thought it could be, and... nothing.
The stacktrace shows the calling spec in the helper module, a generic `process` method that just calls `super` (from where? who knows!), and a `wrap_every_action` in the ApplicationController. in other words: absolutely nothing helpful. I stepped through the code for most of an hour and didn't get anywhere; just saw lots of rails internals.
ugh,
I'm going to keep bashing my head against this, but what the fuck, why can't you give me something goddamn useful!?4 -
Holy. Shit. Tests. I am testing. All week. Nothing but tests. I am one with the spec. You know what I realised today? Tests are a bit like life. Life is just one big spec suite that takes 75 years to run. Except there's no prod environment at the end of the DMT tunnel waiting for our green pass docket to say 'take me Lucifer, you absolute visionary: I'm ready'. We're all just a spec with no application. We're doomed. Nothing matters. I need to lie down4
-
My pair partner and I managed to break every feature test written by our 16 strong team today while fixing a login form. Fixing other people's non-refactored rspec tests is not a pleasant experience lol
-
As a Vim evangelist, it's agonizing watching someone debug unit tests in RubyMine.
It physically pains me.