<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cyril on Medium]]></title>
        <description><![CDATA[Stories by Cyril on Medium]]></description>
        <link>https://medium.com/@cyrilllllll?source=rss-2a0917c38a58------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WnSjhmSk9wzCEZhoLNRU5A.jpeg</url>
            <title>Stories by Cyril on Medium</title>
            <link>https://medium.com/@cyrilllllll?source=rss-2a0917c38a58------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:34:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cyrilllllll/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing a new RSpec]]></title>
            <link>https://cyrilllllll.medium.com/introducing-a-new-rspec-850d48c0f901?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/850d48c0f901</guid>
            <category><![CDATA[rspec]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[testing-tools]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Fri, 02 Jul 2021 16:52:13 GMT</pubDate>
            <atom:updated>2021-07-02T16:52:13.455Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week, I released the first stable version of <a href="https://r-spec.dev/">RSpec clone</a>, a minimalist reimplementation of RSpec to enforce the guidelines and best practices outlined in the community <a href="https://rspec.rubystyle.guide/">RSpec style guide</a>. This clone includes most of RSpec’s DSL to express expected outcomes with no magical powers.</p><p><a href="https://asciinema.org/a/422210?autoplay=1&amp;speed=2">RSpec clone demo</a></p><p>To avoid confusion in the community, please note that the gem of this project is <strong>not </strong><a href="https://rubygems.org/gems/rspec"><strong>rspec</strong></a>, it is <a href="https://rubygems.org/gems/r_spec-clone"><strong>r_spec-clone</strong></a>, and it is totally independent of <a href="https://rspec.info/">rspec.info</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*DYki4_DI3x6VJOBguw10mA.jpeg" /><figcaption>A man in front of a dashboard with two RSpec buttons.</figcaption></figure><p>If you want to try it on test suites, please note that it may require more effort than just adding an underscore to migrate to this clone since there are <a href="https://asciinema.org/a/423547?autoplay=1&amp;speed=2">some behavioural reinterpretations</a> to place emphasis on correctness, security and standardization.</p><p>You can read more on <a href="https://r-spec.dev/">the project page</a>, <a href="https://rubydoc.info/gems/r_spec-clone">the documentation</a> or directly in <a href="https://github.com/cyril/r_spec-clone.rb">the code</a>.</p><p>Happy testing with Ruby!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=850d48c0f901" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Motionless development]]></title>
            <link>https://cyrilllllll.medium.com/motionless-development-539c6024299d?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/539c6024299d</guid>
            <category><![CDATA[art]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Mon, 11 Apr 2016 09:11:25 GMT</pubDate>
            <atom:updated>2016-04-11T09:11:25.089Z</atom:updated>
            <content:encoded><![CDATA[<p>Every developer has an awesome project in mind. Such projects can take some time, depending on ambitions, skill, resources.</p><p>Let’s consider someone planning to implement his own in 5 years, by working daily, assuming he will not use immediately the keyboard to avoid endless debugging. At this point, a first study over several months would save at least one or two years of refactoring, bringing the project to approximately 4 years. Then, it would be wise to choose a few abstractions, to increase productivity. In all cases, the time for learning and benchmarking those would be amortized during development.</p><p>Months pass and things starts to take shape after the third year. And better frameworks come, reducing development time to a week.</p><p>While this is good for the project, he will have wasted his time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=539c6024299d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building RSpec with Fix]]></title>
            <link>https://cyrilllllll.medium.com/building-rspec-with-fix-bb2feb240bd3?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb2feb240bd3</guid>
            <category><![CDATA[testing-tools]]></category>
            <category><![CDATA[rspec]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Sun, 01 Nov 2015 02:44:57 GMT</pubDate>
            <atom:updated>2021-07-02T17:09:12.747Z</atom:updated>
            <content:encoded><![CDATA[<p>First of all, to avoid confusion in the Ruby community, please note that:</p><blockquote>The code and the gem that I’m going to write about is not coming from <a href="http://rspec.info/">rspec.info</a>’s <a href="https://rubygems.org/gems/rspec">rspec</a>, but from <a href="https://r-spec.dev/">a personal project</a> named <a href="https://rubygems.org/gems/r_spec-clone">r_spec-clone</a>.</blockquote><blockquote>My r_spec-clone project is totally independent from <a href="http://rspec.info/">rspec.info</a>, even if its interface is directly inspired by <a href="http://rspec.info/">rspec.info</a>’s rspec.</blockquote><blockquote>Also, while the namespace of both gems is the same (I follow <a href="http://guides.rubygems.org/name-your-gem/#use-underscores-for-multiple-words">the gem naming convention</a>), the r_spec-clone internal is however quite different than <a href="http://rspec.info/">rspec.info</a>’s, as shown in this article.</blockquote><p>Having said that, I am pleased to blog about how to build an RSpec clone that can handle some basic features, and maybe replace the original in your next project, who knows?</p><p>But for now, let’s hack some code!</p><h4>Initial setup</h4><p>Instead of re-inventing the wheel, we will include those small, cryptographically signed and well focused gems coming from a few <a href="https://fixrb.dev/">Ruby Fix</a> projects:</p><ul><li><a href="https://rubygems.org/gems/fix">fix</a>, a fresh new specing framework.</li><li><a href="https://rubygems.org/gems/fix-expect">fix-expect</a>, to provide the expect syntax.</li><li><a href="https://rubygems.org/gems/fix-its">fix-its</a>, to provide “its” method for attribute matching.</li><li><a href="https://rubygems.org/gems/matchi-rspec">matchi-rspec</a>, to extend matchers with some RSpec’s ones.</li></ul><p>To start with, our Gemfile could be:</p><pre>source &#39;https://rubygems.org&#39;</pre><pre>gem &#39;matchi-rspec&#39;, &#39;~&gt; 0.0.2&#39;<br>gem &#39;fix-expect&#39;,   &#39;~&gt; 0.3.0&#39;<br>gem &#39;fix-its&#39;,      &#39;~&gt; 0.4.0&#39;</pre><p>And instead of manually requiring all these dependencies, we’ll ask Bundler to do it for us:</p><pre>require &#39;bundler/setup&#39;<br>Bundler.require</pre><p>At this point, we can define our namespace. Let’s call it RSpec.</p><pre>module RSpec<br>end</pre><p>It will have to include a “describe” class method, taking a described class and a block of specs to execute. The <a href="https://github.com/fixrb/fix/blob/8b59ec1d56237f20507503981660b5e2b6991796/lib/fix/test.rb">Fix’s Test class</a> should do the job.</p><p>Also, after reporting the results, the test must exit with a success or a failure termination status.</p><p>Here is an implementation:</p><pre>def self.describe(front_object, options = {}, &amp;specs)<br>  t = ::Fix::Test.new(front_object, options, &amp;specs)<br>  print &quot;#{t.report}&quot; if options.fetch(:verbose, true)<br>  exit t.pass?<br>end</pre><p>Now, let’s pretend that our application is the following:</p><pre>app = &#39;Hello, world!&#39;</pre><p>A test set could thus be:</p><pre>RSpec.describe String do<br>  context &#39;I am talking to Alice&#39; do<br>    let(:person) { &#39;Alice&#39; }<br>    it &#39;replaces &quot;world&quot; by &quot;Alice&quot;&#39; do<br>      value = app.gsub(&#39;world&#39;, person)<br>      expect(value).to eq &#39;Hello, Alice!&#39;<br>    end<br>  end</pre><pre>  context &#39;I am talking to Bob&#39; do<br>    let(:person) { &#39;Bob&#39; }<br>    it &#39;replaces &quot;world&quot; by &quot;Bob&quot;&#39; do<br>      value = app.gsub(&#39;world&#39;, person)<br>      expect(value).to eq &#39;Hello, Bob!&#39;<br>    end<br>  end<br>end</pre><p>Is it passing?</p><pre>$ ruby test.rb<br>..<br><br>Ran 2 tests in 0.02856 seconds<br>100% compliant - 0 infos, 0 failures, 0 errors</pre><p>No surprise, it is. One thing that can be noted, however, is the presence of those two contexts:</p><ul><li>I am talking to Alice</li><li>I am talking to Bob</li></ul><p>They were able to <strong>ensure an isolation of the tested code</strong>. This protection was useless due to the absence of side effects, but let’s try once again with the “gsub!” method. 💩</p><p><a href="https://asciinema.org/a/29070">What did you RSpec?</a></p><p>As we can see, the build is passing against our testing script, but no longer against rspec.</p><blockquote>Indeed, despite a test set with contexts, rspec don’t evaluate the code in isolation to prevent side effects.</blockquote><p>Thus, the behavior of our clone does not behave in quite the same way, and that’s fine.</p><p>Now, we could continue with a “before” method for test setup, a “describe” method to group a set of related examples and a “subject” method to override the implicit receiver… <a href="https://github.com/cyril/r_spec/blob/ae1406cc1eccf68c61aa0d09a23b985eaf115e45/lib/fix/on.rb#L5-L41">by overriding the Fix::On class</a>.</p><p>In the same fashion, the “described_class” implementation could be done <a href="https://github.com/cyril/r_spec/blob/ae1406cc1eccf68c61aa0d09a23b985eaf115e45/lib/fix/it.rb#L5-L8">by overriding the Fix::It class</a>.</p><h4>Showtime!</h4><p>In addition to “its” and “let” keywords, it is all the Fix’s syntax which becomes available, so…</p><blockquote>What about replacing the flat-expect syntax for the benefit of <a href="https://www.ietf.org/rfc/rfc2119.txt">RFC 2119</a>’s keywords to start qualify your expectation?</blockquote><h4>Conclusion</h4><p>This experimental script living <a href="https://github.com/cyril/r_spec">on GitHub</a> demonstrates that we can build great tools with some super simple pieces of code that everyone can read and understand.</p><p>Such tools should be accessible for everybody, including less experienced developers. By the way, did you read some rspec code? Anyway,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*XS1I1WLqNu1phkVSIh0LlQ.jpeg" /><figcaption>I don’t always test my code with RSpec, but when I do I do it with <a href="https://github.com/cyril/r_spec">r_spec</a>.</figcaption></figure><p>For any questions or concerns, please do not hesitate to <a href="https://twitter.com/cyri_">get in touch</a>.</p><p>Happy testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb2feb240bd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expectations with RFC 2119 compliance]]></title>
            <link>https://cyrilllllll.medium.com/a-spectus-tutorial-expectations-with-rfc-2119-compliance-1fc769861c1?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fc769861c1</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[rfc]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Sat, 12 Sep 2015 01:37:07 GMT</pubDate>
            <atom:updated>2021-07-19T13:27:06.914Z</atom:updated>
            <content:encoded><![CDATA[<p>In the Ruby community, the two main testing frameworks offer different syntaxes to check the code:</p><ul><li>In <strong>RSpec</strong>, until recently, both <em>expect</em> and <em>should</em> syntaxes was available. For some <a href="http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/">technical reasons</a>, however, the <em>should</em> syntax is not recommended.</li><li>In <strong>minitest</strong>, expectations can be expressed through the Ruby or in an RSpec style. In the second case, a “#test_*” method would be dynamically defined per spec in order to be translated into a test. By the way, <a href="http://docs.seattlerb.org/minitest/Minitest/Expectations.html">spec matchers</a> are aliased by <a href="http://docs.seattlerb.org/minitest/Minitest/Assertions.html">test matchers</a>.</li></ul><p>So we have several different syntaxes, but only one same level of requirement: <em>absolute</em>, which would correspond to <strong>MUST</strong> keyword in the RFCs.</p><p>However, as human beings, we would not write RFCs with a single level of requirement. Instead, we would prefer to <strong>qualify expectations</strong>, using the additional keywords “SHOULD” and “MAY” as defined in <a href="https://www.ietf.org/rfc/rfc2119.txt">RFC 2119</a>.</p><p>That’s precisely what <a href="https://github.com/fixrb/spectus"><strong>Spectus</strong></a> is made for.</p><h3>Enter Spectus!</h3><p>Spectus is a very small and well focused <a href="https://rubygems.org/gems/spectus">Ruby gem</a>. It can be installed with:</p><pre>gem install spectus</pre><h3>What Does Spectus Look Like?</h3><p>Various combinations can occur between the requirement levels and the code that could be evaluated as:</p><ul><li>Implemented &amp; Matched</li><li>Implemented &amp; Not matched</li><li>Implemented &amp; Exception</li><li>Not implemented</li></ul><p>As expectation is an assertion that is either true or false, Spectus results can respectively pass or fail.</p><p>To see a little clearer, let’s take a look at some examples… Because Spectus is basically a module defining methods that can be used to qualify expectations in specifications, for convenience we will also instantiate some matchers from the <a href="https://github.com/fixrb/matchi">Matchi library</a>:</p><pre>gem install matchi</pre><p>Let’s now make Spectus available:</p><pre>require &quot;spectus&quot;<br>require &quot;matchi/helper&quot;</pre><pre>include Matchi::Helper</pre><p>We are now ready to experiment!</p><h4>Absolute Requirement expectation</h4><p>There is exactly one bat:</p><pre>definition = Spectus.must equal 1<br>definition.call { &quot;🦇&quot;.size }<br># =&gt; Expresenter::Pass(actual: 1, error: nil, expected: 1, got: true, matcher: :equal, negate: false, level: :MUST</pre><p>The test is passed.</p><h4>Absolute Prohibition expectation</h4><p>Truth and lies:</p><pre>definition = Spectus.must_not be_true<br>definition.call { false }<br># =&gt; Expresenter::Pass(actual: false, error: nil, expected: nil, got: true, matcher: :be_true, negate: true, level: :MUST</pre><h4>Recommended expectation</h4><p>A well-known joke. The addition of 0.1 and 0.2 is deadly precise:</p><pre>definition = Spectus.should equal 0.3<br>definition.call { 0.1 + 0.2 }<br># =&gt; Expresenter::Pass(actual: 0.30000000000000004, error: nil, expected: 0.3, got: false, matcher: :equal, negate: false, level: :SHOULD</pre><h4>Not Recommended expectation</h4><p>This should not be wrong:</p><pre>definition = Spectus.should_not match &quot;123456&quot;<br>definition.call do<br>  require &quot;securerandom&quot;<br>  SecureRandom.hex(3)<br>end<br># =&gt; Expresenter::Pass(actual: &quot;ce22e3&quot;, error: nil, expected: &quot;123456&quot;, got: true, matcher: :match, negate: true, level: :SHOULD</pre><p>In any case, as long as there are no exceptions, the test passes.</p><h4>Optional expectation</h4><p>An empty array is blank, right?</p><pre>definition = Spectus.may be_true<br>definition.call { [].blank? }<br># =&gt; Expresenter::Pass(actual: nil, error: #&lt;NoMethodError: undefined method `blank?&#39; for []:Array&gt;, expected: nil, got: nil, matcher: :be_true, negate: false, level: :MAY</pre><p>My bad! ActiveSupport was not imported. 🤦‍♂️</p><p>Anyways, the test passes because the exception produced is NoMethodError, meaning that the functionality is <em>not implemented</em>.</p><h3>Spectus’s Matchers</h3><p>Because Spectus relies on <a href="https://github.com/fixrb/matchi">Matchi</a>, a <a href="https://github.com/fixrb/matchi#built-in-matchers">collection of expectation matchers</a> is available:</p><ul><li><strong>eql</strong>: equivalence matcher</li><li><strong>equal</strong>: identity matcher</li><li><strong>match</strong>: regular expressions matcher</li><li><strong>raise_exception</strong>: expecting errors matcher</li><li><strong>be_true</strong>: truth matcher</li><li><strong>be_false</strong>: untruth matcher</li><li><strong>be_nil</strong>: nil matcher</li><li><strong>be_an_instance_of</strong>: type/class matcher</li></ul><p>Note: If you look at <a href="https://github.com/fixrb/matchi">the source for matchi</a>, you’ll see that each matcher is mainly a class responding to “#matches?” method.</p><h3>Running Spectus Specs In Your Tests</h3><p>Generally, running Spectus tests can use the same mechanisms as you would for RSpec or minitest tests, so there’s not much to do:</p><pre>require &quot;spectus&quot;<br>require &quot;rake/testtask&quot;</pre><pre>Rake::TestTask.new do |t|<br>  t.pattern = File.join(&quot;test&quot;, &quot;**&quot;, &quot;*.rb&quot;)<br>end</pre><pre>task default: :test</pre><h3>Give It A Try</h3><p>So next time you’re starting on a new small and well focused Ruby project, before requiring RSpec or minitest, give Spectus a try!</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fc769861c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From RSpec to Fix]]></title>
            <link>https://cyrilllllll.medium.com/from-rspec-to-fix-688a4ba274d2?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/688a4ba274d2</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[rspec]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Sun, 06 Sep 2015 19:40:52 GMT</pubDate>
            <atom:updated>2022-02-20T13:11:51.162Z</atom:updated>
            <content:encoded><![CDATA[<p>Short article to introduce <a href="https://fixrb.dev/">Fix</a> 0.7 features, and compare it with <a href="http://rspec.info/">RSpec</a> 3.3.</p><h3>How heavy is the package?</h3><p>On the one hand, the <a href="https://github.com/rspec/rspec/releases/tag/v3.3.0">rspec</a> gem (which is 7 LOC) runtime dependencies are:</p><ul><li><a href="https://github.com/rspec/rspec-core/releases/tag/v3.3.2">rspec-core</a>: 6689 LOC</li><li><a href="https://github.com/rspec/rspec-expectations/releases/tag/v3.3.1">rspec-expectations</a>: 3697 LOC</li><li><a href="https://github.com/rspec/rspec-mocks/releases/tag/v3.3.2">rspec-mocks</a>: 3963 LOC</li><li><a href="https://github.com/rspec/rspec-support/releases/tag/v3.3.0">rspec-support</a>: 1509 LOC</li><li><a href="https://github.com/halostatue/diff-lcs/releases/tag/v1.2.5">diff-lcs</a>: 1264 LOC</li></ul><p>On the other hand, the <a href="https://github.com/fixrb/fix/releases/tag/v0.7.0">fix</a> gem (which is 148 LOC) runtime dependencies are:</p><ul><li><a href="https://github.com/fixrb/spectus/releases/tag/v2.3.1">spectus</a>: 289 LOC</li><li><a href="https://github.com/fixrb/matchi/releases/tag/v0.0.9">matchi</a>: 73 LOC</li></ul><blockquote>This makes a total of <strong>17129 LOC for RSpec</strong> against <strong>510 LOC for Fix</strong>.</blockquote><h3>Exhibition game</h3><p>Despite a huge difference (of 16619 LOC), let’s compare the common features between both frameworks. And to do so, we’ll play with this monster abstraction:</p><pre>class Monster<br>  def self.get<br>    {<br>      boo: {<br>        name: &quot;Boo&quot;,<br>        life: 123,<br>        mana: 42<br>      },<br>      hasu: {<br>        name: &quot;Hasu&quot;,<br>        life: 88,<br>        mana: 40<br>      }<br>    }<br>  end</pre><pre>  def get(id)<br>    self.class.get.fetch(id)<br>  end<br>end</pre><p>Using RSpec, the spec of monsters’ could be transcribed such that:</p><pre>require_relative &quot;monster&quot;<br>require &quot;rspec/autorun&quot;<br><br>RSpec.describe Monster do<br>  describe &quot;.get&quot; do<br>    subject(:monsters) { described_class.get }<br><br>    describe &quot;#keys&quot; do<br>      it { expect(monsters.keys).to eql %i(boo hasu) }<br>    end<br>  end<br><br>  describe &quot;.new&quot; do<br>    subject(:described_instance) { described_class.new }<br><br>    describe &quot;#get&quot; do<br>      subject(:monster) { described_instance.get(name) }<br><br>      context &quot;with Boo monster&quot; do<br>        let(:name) { :boo }<br>        it { expect(monster).to eql({ name: &quot;Boo&quot;, life: 123, mana: 42 }) }<br>      end<br><br>      context &quot;with Boom monster&quot; do<br>        let(:name) { :boom }<br>        it { expect { monster }.to raise_exception KeyError }<br>      end<br>    end<br>  end<br>end</pre><p>Now, the same spec into Fix:</p><pre>require_relative &quot;monster&quot;<br>require &quot;fix&quot;</pre><pre>Fix.describe Monster do<br>  on :get do<br>    on :keys do<br>      it { MUST eql %i(boo hasu) }<br>    end<br>  end</pre><pre>on :new do<br>    on :get, :boo do<br>      it { MUST eql({ name: &quot;Boo&quot;, life: 123, mana: 42 }) }<br>    end</pre><pre>    on :get, :boom do<br>      it { MUST raise_exception KeyError }<br>    end<br>  end<br>end</pre><p>As we can see, the spec is a bit shorter and easier to read, with a “DRY” approach.</p><blockquote>Fix allows to describe methods with one expression, <strong>whatever that it concerns a class method’s name or an instance method’s name</strong>.</blockquote><p>In addition, all specifications are derived from the described front object that is populated at the root.</p><blockquote>Unlike in RSpec, there is no concept of implicit or explicit subjects. There is just one read-only <strong>dynamic subject</strong> which is deduced from the front object and the described methods.</blockquote><p>Finally, while an RSpec expectation needs sometimes a parameter to handle <a href="http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec%2FMatchers%3Aeql">equivalence matcher</a>, sometimes a block to handle <a href="http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec%2FMatchers%3Araise_error">expect error matcher</a>, Fix’s expectations are always written the same way, regardless of the responsibility and structure of matchers.</p><p>This article has presented some differences in syntax between two frameworks.</p><p>I hope you will like the new test interface proposed by Fix.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=688a4ba274d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Announcing Ruby Fix 0.7!]]></title>
            <link>https://cyrilllllll.medium.com/announcing-ruby-fix-0-7-2d259579bfc7?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d259579bfc7</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[rspec]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Thu, 03 Sep 2015 00:25:57 GMT</pubDate>
            <atom:updated>2022-02-20T11:27:13.633Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://speakerdeck.com/cyril/konbanha-tiao-jian-yabiheibiatesuto">After several drafts</a>, we’re proud to announce the release of <a href="https://github.com/fixrb/fix">Fix</a>!</p><p>With 148 lines of <strong>simple code</strong> built on top of <a href="https://github.com/fixrb/spectus">Spectus expectation library</a>, facilities such as benchmarking and mocking are not supported. <strong>Fix</strong> offers however a <strong>consistent</strong> syntax to focus your BDD.</p><p>While specs behave like <strong>documents</strong> which can be logic-less, their interpretation should not be questioned regardless of the version of <strong>Fix</strong>, preventing from software erosion. Also, Fix specs are compliant with <a href="http://tools.ietf.org/html/rfc2119"><strong>RFC 2119</strong></a>, to qualify requirements.</p><p>Monkey-patching, <a href="http://blog.arkency.com/2013/06/are-we-abusing-at-exit/">magic tricks and friends</a> are not included. Instead, animated by <strong>authentic</strong> and <strong>unmuted</strong> Ruby objects, unambiguous, understandable and structured specs are encouraged.</p><h3>Why Fix instead of RSpec?</h3><p>Let me start with a confession. Despite 10 years of Ruby, I still do not understand anything about the source code of <a href="http://rspec.info/">RSpec</a>.</p><p>This is alarming when one considers that if the <strong>programming complexity</strong> of the testing tool on which we pin our expectations is greater than the complexity of the program to be tested, tests are less significant.</p><p>However the current implementation of this tool is probably more complex than most programs to be tested with. And when I do anyway against a piece of code, I feel like using a sledgehammer to crack a nut. Worst, I can not help doubting the results RSpec provides.</p><p>Here is why, with a basic example:</p><pre>class App<br>  def equal?(*)<br>    true<br>  end<br>end</pre><pre>require &quot;rspec&quot;</pre><pre>RSpec.describe App do<br>  it &quot;is the answer to life, the universe and everything&quot; do<br>    expect(described_class.new).to equal(42)<br>  end<br>end</pre><p>And now, let’s look at the result:</p><pre>$ rspec wat_spec.rb<br>.</pre><pre>Finished in 0.00146 seconds (files took 0.17203 seconds to load)<br>1 example, 0 failures</pre><blockquote>You got it, according to RSpec, App.new is 42.</blockquote><p>While this one could be fixed quickly, by <a href="https://github.com/rspec/rspec-expectations/blob/995d1acd5161d94d28f6af9835b79c9d9e586307/lib/rspec/matchers/built_in/equal.rb#L40">reversing actual and expected values</a>, such bugs alert us against the possible impact on the final application.</p><h3>Writing A Spec With Fix</h3><p>Given this duck class:</p><pre># duck.rb<br>class Duck<br>  def walks<br>    &quot;Klop klop!&quot;<br>  end<br><br>  def swims<br>    &quot;Swoosh...&quot;<br>  end<br><br>  def quacks<br>    puts &quot;Quaaaaaack!&quot;<br>  end<br>end</pre><p>When we write this spec:</p><pre># duck_spec.rb<br>require_relative &quot;duck&quot;<br>require &quot;fix&quot;<br><br>@bird = Duck.new<br><br>Fix.describe @bird do<br>  on :swims do<br>    it { MUST eql &quot;Swoosh...&quot; }<br>  end<br><br>  on :speaks do<br>    it { MUST raise_exception NoMethodError }<br>  end<br><br>  on :sings do<br>    it { MAY eql &quot;♪... ♫...&quot; }<br>  end<br>end</pre><p>Then we should see:</p><pre>$ ruby duck_spec.rb<br>..I<br><br>1. Info: undefined method `sings&#39; for #&lt;Duck:0x007fb60383b740&gt; (NoMethodError).<br><br>Ran 3 tests in 0.00038 seconds<br>100% compliant - 1 infos, 0 failures, 0 errors</pre><h3>What’s Next</h3><p>For 1.0.0 there are no major changes planned. Please, tell us what you think. Like. Dislike. We would like to hear it all.</p><p>Thanks for reading and happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d259579bfc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing should be simpler]]></title>
            <link>https://cyrilllllll.medium.com/testing-should-be-simpler-d65c4d3e815b?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/d65c4d3e815b</guid>
            <category><![CDATA[complexity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Mon, 24 Aug 2015 20:29:06 GMT</pubDate>
            <atom:updated>2015-08-24T20:29:06.233Z</atom:updated>
            <content:encoded><![CDATA[<p>We, programmers, are such artists. We program like painters paint, and there is nothing scientific here because no results can be proved.</p><p>Thus, as long as the design is not satisfactory, or that in any case the specifications are not met, the work is not over. And to know when it is, we just give it a try.</p><p>Indeed, as long as it’s not tested, it is impossible to know if it’s done. And when it is, maybe with another test it would no longer work. So where it is not possible to test all, a reasonable set of use cases should be chosen with attention to match the most likely scenarios and reach 100% of code coverage.</p><p>But once again, while the tests of the program are not tested, we can not know if they’re done. And add tests over tests would be an endless race.</p><p>Tests are the Achilles heel of the whole code, but also the guard rail of the program. To minimize risks, tests (including their dependencies) have to be simpler. The programming complexity of the testing tool on which we pin our expectations should always be lower than the complexity of the program to be tested. Otherwise, tests would not be significant and as a result, the program too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d65c4d3e815b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A hundred network stories]]></title>
            <link>https://cyrilllllll.medium.com/a-hundred-network-stories-bc0ba5ef6a41?source=rss-2a0917c38a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc0ba5ef6a41</guid>
            <category><![CDATA[network-security]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Cyril]]></dc:creator>
            <pubDate>Fri, 07 Aug 2015 14:21:32 GMT</pubDate>
            <atom:updated>2015-08-07T23:05:19.497Z</atom:updated>
            <content:encoded><![CDATA[<p>Tradition has it that, having a crowd of packets gathered in a dark network where a hundred specs would be performed inside an eerie atmosphere, the last matched one may yield an event…</p><p>That’s when the NIDS demon — called <a href="https://github.com/cyril/aoandon.rb">Aoandon</a> — was said to appear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/0*J-S09QmfCuiNcDd0.jpg" /><figcaption>The Blue Lantern Ghost</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc0ba5ef6a41" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>