mastodon.world is one of the many independent Mastodon servers you can use to participate in the fediverse.
Generic Mastodon server for anyone to use.

Server stats:

8.4K
active users

#rspec

1 post1 participant0 posts today
Kyle<p>TIL in <a href="https://mastodon.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a> ‘describe’ blocks are evaluated when the file is parsed, not when the spec is executed. That one took me a few hours! :yikes: :michaelwazowski: </p><p><a href="https://mastodon.social/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a> <a href="https://mastodon.social/tags/programming" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>programming</span></a></p>
postmodern<p>Is there a RSpec matcher to expect that a value exists in an Array of expected values? If not, there should be. I don't like inverting my expect() statement to be:</p><p>expect(expected_values).to include(subject.thing_i_am_testing) # not ideal</p><p>Ideally it would look like:</p><p>expect(subject.foo).to eq_any_of(expected_values) # better</p><p><a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a></p>
Bradley Schaefer<p>Heads up: rspec-mocks 3.13.3 (released May 1) is a BAD version.</p><p>There's something wrong with verifying mocks that seems like it causes a problem with mocking methods that take keyword arguments and a block. It seems like the vast majority of mocking works, just some kind of nesting edge case.</p><p>rspec-mocks 3.13.4 (released May 5) fixes the apparent problem</p><p>I can't immediately spot what it was, something about the invoking flag</p><p><a href="https://github.com/rspec/rspec/compare/rspec-mocks-v3.13.3...rspec-mocks-v3.13.4" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">github.com/rspec/rspec/compare</span><span class="invisible">/rspec-mocks-v3.13.3...rspec-mocks-v3.13.4</span></a></p><p>cc <span class="h-card" translate="no"><a href="https://fosstodon.org/@JonRowe" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>JonRowe</span></a></span> </p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a></p>
Aaron Sumner<p>Hey friends! Just a reminder that this sale is going on all month. ❤️ to all your support these past 15 years. (And if $9 is out of your budget, DM me for a freebie link, no questions asked) <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a> <a href="https://mastodon.social/tags/RubyOnRails" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RubyOnRails</span></a> <a href="https://mastodon.social/tags/RubyFriends" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RubyFriends</span></a> <a href="https://mastodon.social/tags/IndiePublisher" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>IndiePublisher</span></a><br><a href="https://mastodon.social/@ruralocity/114435425017295122" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">mastodon.social/@ruralocity/11</span><span class="invisible">4435425017295122</span></a></p>
Aaron Sumner<p>Anyone have better approaches to wiping Active Storage files after <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a> test runs in <a href="https://mastodon.social/tags/RubyOnRails" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RubyOnRails</span></a>?</p><p>```<br> config.after(:suite) do<br> dir = ActiveStorage::Blob.services.fetch(:test).root<br> FileUtils.rm_rf(dir)<br> FileUtils.mkdir_p(dir)<br> FileUtils.touch(File.join(dir, ".keep"))<br> end<br>```</p>
Aaron Sumner<p>Welp, my improptu 15th anniversary sale became a "just needed to buy a new washer/dryer" sale 😭 $9 for lifetime free updates to my <a href="https://mastodon.social/tags/RubyOnRails" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RubyOnRails</span></a> <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a> book! Sharing is caring! <a href="https://leanpub.com/everydayrailsrspec/c/everyday-rails-15" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">leanpub.com/everydayrailsrspec</span><span class="invisible">/c/everyday-rails-15</span></a></p>
Jay McGavren<p>The output of RSpec's "expect(thing).to recieve(:act).with('foo')" can be a pain to debug if "act" is called with things other than "foo". But TIL combining "expect" with "allow" lists the calls:</p><p>class Dog<br> def say(sound); end<br>end</p><p>it "says bark" do<br> dog = Dog.new<br> allow(dog).to receive(:say)<br> expect(dog).to receive(:say).with("bark")<br> dog.say("meow")<br> dog.say("oink")<br>end</p><p># Failure message:<br>expected:<br>("bark")<br>got:<br>("meow") (1 time)<br>("oink") (1 time)</p><p><a href="https://mastodon.social/tags/Ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Ruby</span></a> <a href="https://mastodon.social/tags/Rails" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Rails</span></a> <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a></p>
François<p><a href="https://ruby.social/tags/Ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Ruby</span></a> friends! I have a large number <a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a> files. I added Sorbet and I want to have a rough idea if things are good or not before submitting to CI.</p><p>I'd like to run specs, but let's say 10% of specs within files.</p><p>Does anyone have a quick something already done? Or should I add a before block and cancel the example if rand &gt; 0.1?</p>
Cédric Delalande :ruby:<p>Made a small gem to allow switching from class to test - and back - in <a href="https://ruby.social/tags/zed" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>zed</span></a></p><p><a href="https://github.com/MoskitoHero/zed-test-toggle" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">github.com/MoskitoHero/zed-tes</span><span class="invisible">t-toggle</span></a> </p><p>It’s still at an early stage, so I suspect it might not work in some projects. But it understands if you are using <a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a> or <a href="https://ruby.social/tags/minitest" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>minitest</span></a>.</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/gem" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>gem</span></a></p>
Aaron Sumner<p>💥 I shipped a new chapter for the current edition of Everyday Rails Testing with <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a>! I’ve overhauled my introduction to testing in isolation with mocks (and stubs, and fakes, and spies, and doubles, oh my). 💥</p><p>Free update on Leanpub: <a href="https://leanpub.com/everydayrailsrspec/" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="">leanpub.com/everydayrailsrspec/</span><span class="invisible"></span></a></p><p><a href="https://mastodon.social/tags/RubyOnRails" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RubyOnRails</span></a></p>
Aaron Sumner<p>Updating coverage of the Ruby "VCR" mocking package in my <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a> book, and thinking how many younger people have likely never even seen a VCR, much less a TiVo—which then reminded me of the behemoth ReplayTV that sat under my cathode ray television in the aughts. 👴</p>
Bradley Schaefer<p>I got to pull out a nice RSpec trick today - using compound expectations.</p><p>I wanted to check that a method was called with a (rather large) string that had a few different substrings in it.</p><p>expect(instance).to receive(:method).with(<br> a_string_including("thing 1") &amp;<br> a_string_including(obj.message) &amp;<br> a_string_including("asdfasdfgasd")<br>)</p><p>The trick here is combining matchers with &amp; </p><p>There's other ways you might do this, but the test output is really nice this way.</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a></p>
Aaron Sumner<p>Finally got an update to my <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a> book for <a href="https://mastodon.social/tags/RubyOnRails" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RubyOnRails</span></a> shipped this afternoon, with new content on tools for DRYer tests, and when they're a good idea or a bad idea. Free update as usual! <a href="https://leanpub.com/everydayrailsrspec" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="">leanpub.com/everydayrailsrspec</span><span class="invisible"></span></a></p>
Aaron Sumner<p>Heya <a href="https://mastodon.social/tags/TDD" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>TDD</span></a> fans, especially <a href="https://mastodon.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a> users: Feelings about testing at a single level of abstraction? Debating whether to include it again (with revisions) in my RSpec book updates. I like it in principle; is the extra setup worth the improved readability to you? <a href="https://www.glennespinosa.com/ruby/refactoring/2015/09/26/specing-at-single-level-abstraction.html" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://www.</span><span class="ellipsis">glennespinosa.com/ruby/refacto</span><span class="invisible">ring/2015/09/26/specing-at-single-level-abstraction.html</span></a></p>
Peter Solnica<p>One more prompt and we found the culprit 🙃 Now I just asked it to find which specific spec scenario causes our failure and 💥 got it, fixed it, and now I also know that there's state leaking between specs which I want to address in a generic way. Win!</p><p><a href="https://hachyderm.io/tags/aicoding" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>aicoding</span></a> <a href="https://hachyderm.io/tags/testing" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>testing</span></a> <a href="https://hachyderm.io/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a> <a href="https://hachyderm.io/tags/debugging" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>debugging</span></a> <a href="https://hachyderm.io/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a></p>
Bradley Schaefer<p>Category of totally random. OSX Mojave doesn't play nice with `rspec --bisect` anymore because it crashes out when forking, like so:</p><p>objc[49901]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.</p><p>My colleague told me to try running with the environment variable `OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES` and it works.</p><p>OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES rspec --bisect --seed 1234</p><p>What is this magic?</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/osx" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>osx</span></a> <a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a></p>
Bradley Schaefer<p>My favorite RSpec workflow is using the --next-failure option.</p><p>1. Run your entire test suite to generate the list of failing specs<br>2. Run `rspec --next-failure`<br>3. Debug and fix failure, continue repeating step 2 until the test passes and you have a new failure<br>4. Step 2 succeeds? Run the entire test suite again to ensure none of the fixes broke something else</p><p>You can plow through a lot of broken tests that way. I fixed 50 failing tests in about an hour yesterday by this method.</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a></p>
codeDude :archlinux: :neovim:<p>Please don't write <a href="https://fosstodon.org/tags/jest" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>jest</span></a> unit test like <a href="https://fosstodon.org/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a> unit test, they are hard to debug, <a href="https://fosstodon.org/tags/javascript" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>javascript</span></a> is not <a href="https://fosstodon.org/tags/rubyOnRails" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rubyOnRails</span></a></p>
WNB.rb<p>The amazing Jess Sullivan is leading our :ruby: WNB.rb :ruby: bookclub for this session. We as a group are tackling Effective Testing with RSpec 3 Build Ruby Apps with Confidence by Myron Marston and Erin Dees (<span class="h-card" translate="no"><a href="https://ruby.social/@undees" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>undees</span></a></span> ). We are already at Chapter 3 and have had some great conversations about testing and <a href="https://ruby.social/tags/rspec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>rspec</span></a> </p><p>If you too want to join up (because we have WAY more chapters to go) head to <a href="https://www.wnb-rb.dev/join-us" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://www.</span><span class="">wnb-rb.dev/join-us</span><span class="invisible"></span></a> and join us!</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/testing" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>testing</span></a> <a href="https://ruby.social/tags/online" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>online</span></a> <a href="https://ruby.social/tags/bookclub" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>bookclub</span></a></p>
christine<p>Because I CAN'T just go by the book, I am making work for myself that no one asked me to do... because learning. So I am working through Effective Testing with <a href="https://ruby.social/tags/RSpec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RSpec</span></a> 3 with the <span class="h-card" translate="no"><a href="https://ruby.social/@wnb_rb" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>wnb_rb</span></a></span> bookclub, but it uses <a href="https://ruby.social/tags/sinatra" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>sinatra</span></a> which is a perfectly nice, very easy to use framework. And I just wanted to try something else.</p>