Jim Gay · @saturnflyer
619 followers · 861 posts · Server ruby.social

Pro-tip for writing custom RSpec methods and trying to report the correct file and line number:

# WHY won't RSpec let me set the location!? (ノಠ益ಠ)ノ彡┻━┻
RSpec::Core::Metadata::RESERVED_KEYS.delete(:location)

Someone please tell me how I’m doing it wrong and that there’s actually a good idea in somewhere to make your own spec methods.

#rspec

Last updated 1 year ago

takeonrules · @takeonrules
210 followers · 231 posts · Server dice.camp

A walk through of building fast tests to iterate on a low-level function. This post talks about the idea of using test tables to help provide examples of both given inputs and expected outputs. I also walk through a .

Please reach out if you'd like to learn more or are curious about how me and my team might be able to help you meet your business needs.

takeonrules.com/2023/08/24/tes

#rspec #ruby #refactoring

Last updated 1 year ago

Sunny :autumnleaf6: · @sunny
170 followers · 514 posts · Server boitam.eu

@ynote_hk Awesome! Unfortunately search engines still point to the Relish website...

#rspec

Last updated 1 year ago

Jason Garber · @jgarber
163 followers · 1690 posts · Server mastodon.cc

This is very specific, but passing `-- headless=new` to (Chromium, to be precise) v115 using and on running in is a recipe for pain.

Intermittent system spec failures surfaced as anything from failed page navigations to obscure session errors. I _think_ the browser was crashing between spec setup and `visit`.

Removing `=new` and the intermittent failures appear to have ceased. “Solved” in an entirely unsatisfying manner. 🤦🏻‍♂️

#ruby #rspec #docker #alpinelinux #selenium #capybara #chrome

Last updated 1 year ago

Esparta :ruby: · @esparta
243 followers · 1186 posts · Server ruby.social

So I had a Patch Request fixing our CI at work because an error was persistently showing up, suddenly, out of the blue. No changes in the reported specs failing - they were introduced by me18 days ago.

Let's keep this between us. Don't tell anybody. It's a secret between you, me, my coworkers and the internet.

#meaculpa #ci #development #ruby #rspec

Last updated 1 year ago

Arnaud · @oz
42 followers · 198 posts · Server ruby.social

Sometimes I see tests with the classic "describe SomeClass do ..." beginning for a class-scoped test suite.

IIRC, Rspec will implicitly call SomeClass.new when a test references "subject" directly.

With that in mind, what's your favorite pattern to instantiate SomeClass with different keyword params in different tests? Do you still use subject for that?

#rspec

Last updated 1 year ago

Zee Spencer (He/They) · @Zee
800 followers · 2899 posts · Server social.coop

I kinda want an `eventually` keyword in so I can write `expect { foo }.eventually(wait: 5).to be_present?` which will re-evaluate the block and then make the assertion...

#rspec

Last updated 1 year ago

aristotelesbr · @aristotelesbr
18 followers · 48 posts · Server ruby.social

“É melhor ter teste ruim do que não ter testes.”

Já eu, penso o contrário. Acredito que é melhor *não* ter teste do que ter teste ruim. Se você não tem testes você é obrigado a testar de forma manual toda vez que alterar algo no seu código e isso, querendo ou não, pode trazer mais confiabilidade do que uma suíte frágil, repleta de falso positivo, mistery guest pra todo lado com mais lógica do que a que própria implementação.

#ruby #test #rspec

Last updated 1 year ago

Kevin Murphy · @kevin_j_m
203 followers · 318 posts · Server ruby.social

I wrote about each of these options to test inherited behavior using and .

Thanks to all who participated in the poll.

kevinjmurphy.com/posts/testing

#ruby #rspec

Last updated 1 year ago

FastRuby.io · @FastRuby
31 followers · 108 posts · Server ruby.social
Sean Earle · @sean_earle
35 followers · 331 posts · Server mastodon.gamedev.place

Shout outs to the rspec-wait gem, makes testing a lot easier and more consistent!

rubygems.org/gems/rspec-wait

#ruby #rspec #testing #rails

Last updated 1 year ago

Paul 🇺🇦 · @pauldruziak
33 followers · 39 posts · Server ruby.social

I use this when I need to fix a bug with the race conditions

#rspec

Last updated 1 year ago

Zane · @zolyguy
13 followers · 40 posts · Server ruby.social

@pauldruziak Regarding for developers, as long as your "expect" blocks test enough of the function of the class, I think it's good. An example of inadequate tests would be something like having tests that have no expect blocks and simply exist to make sure no exceptions are thrown, or tests that mock too much of the functionality and barely end up doing anything except guard against basic exceptions being thrown.

#rspec #ruby

Last updated 1 year ago

Tobias Maier · @tmaier
8 followers · 8 posts · Server muenchen.social
christine · @christine
271 followers · 269 posts · Server ruby.social

This makes me happy. I added more tests, but sped up the test suite with applying some best practices with new test, and cleanup some of the existing ones. It's nice to leave things better than you found them, especially legacy code bases 😁

Went from a full test suite run:
1 minute 4.93 seconds (files took 1.97 seconds to load)
96 examples, 0 failures

To:
58.19 seconds (files took 1.97 seconds to load)
112 examples, 0 failures

#rspec

Last updated 1 year ago

Todd A. Jacobs · @todd_a_jacobs
4 followers · 33 posts · Server ruby.social

comes with its own version of built in. However, I can't seem to find a Crystal equivalent for , although I've heard anecdotally that Turnip (which embeds into RSpec) works even if it lacks some of Cucumber's full feature set. What do Crystal programmers use as a drop-in replacement or alternative implementation for Cucumber?

#crystallang #rspec #cucumberbdd #gherkinsyntax #rubylang

Last updated 1 year ago

Dan · @bruisedthumb
5 followers · 39 posts · Server mas.to

When I write my pytests I ask myself, "how would I do this in rspec?"

#Python #sorrynotsorry #Ruby #rspec

Last updated 1 year ago

Henrik Nyh · @henrik
187 followers · 442 posts · Server ruby.social

Had a fun flake hunting session thanks to @olleolleolle teeing me up with a RSpec bisect repro.

The flaky test basically did

x = double(:bucket).as_null_object
x.fields

This would sometimes raise “unknown encoding name - #[Double :bucket]”.

Enabling full backtraces showed that the error was from… FormHelper.

Turned out a view component spec indirectly did `Object.include(ActionView::Helpers::FormHelper)` which includes methods like `fields` in every object, including doubles.

#rspec

Last updated 2 years ago

Michael Toulouse · @MichaelT
122 followers · 1170 posts · Server ruby.social

I will never tire of speeding up my tests. Here's the version with fixtures... (1/2)

#rails #rspec

Last updated 2 years ago

Thiago Figueiró · @thiagocsf
18 followers · 415 posts · Server techhub.social

nitpick number 17: when your named subject is a verb.

#rspec

Last updated 2 years ago