Update RSpec's Syntax

Bug #1816857 reported by Sofia Enriquez on 2019-02-20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Soledad Kuczala

Bug Description

The primary syntax provided by RSpec-expectations is based on the expect method, which explicitly wraps an object or block of code to set an expectation on it.

Currently, the Puppet's cinder-modules use deprecated syntax. [1]

The should-based syntax, which relies upon should being monkey-patched onto every object in the system. However, this syntax can at times lead to some surprising failures, since RSpec does not own every object in the system and cannot guarantee that it will always work consistently. A deprecation warning will be issued if you do not explicitly enable it. [2]

That being said, It's recommended to use the expect syntax instead of the should syntax.[3] We need to update all the cinder-modules to use the primary syntax. [4]

To upgrade to the expect, we can apply transpec[5], which can perform the conversion automatically for us.

[1] https://github.com/openstack/puppet-cinder/blob/master/spec/classes/cinder_nova_spec.rb#L7
[2] https://relishapp.com/rspec/rspec-expectations/v/3-4/docs/syntax-configuration#disable-should-syntax
[3] http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
[4] https://github.com/openstack/puppet-cinder/tree/master/spec/classes
[5] https://github.com/yujinakayama/transpec

Changed in puppet-cinder:
assignee: nobody → Sofia Enriquez (lsofia-enriquez)
Soledad Kuczala (solkz) on 2019-02-20
Changed in puppet-cinder:
assignee: Sofia Enriquez (lsofia-enriquez) → Soledad Kuczala (solkz)
status: New → In Progress
Changed in puppet-cinder:
status: In Progress → New
Changed in puppet-cinder:
status: New → Confirmed
Alex Schultz (alex-schultz) wrote :

Sofia, missed your IRC question about bundler. The docs for setting up an env for testing can be found @ https://docs.openstack.org/puppet-openstack-guide/latest/contributor/testing.html

Changed in puppet-cinder:
importance: Undecided → Medium
Soledad Kuczala (solkz) wrote :

Thanks Alex, I'm on it.

Changed in puppet-cinder:
status: Confirmed → In Progress

Reviewed: https://review.openstack.org/640863
Committed: https://git.openstack.org/cgit/openstack/puppet-cinder/commit/?id=c09a93456eb806f0cdb6e858470334413ac61ea6
Submitter: Zuul
Branch: master

commit c09a93456eb806f0cdb6e858470334413ac61ea6
Author: SolKuczala <email address hidden>
Date: Mon Mar 4 20:08:44 2019 +0000

    Modified archives from spec/classes with transpec tool

    Translated RSpec's Syntax deprecated from ruby archives in
    -Upgrade from RSpec 2 to RSpec 3 on corresponding files.
    Partial-Bug: #1816857

    Change-Id: I75cd0f348465c91500a8d3b8cd82ab53b3224c04

Reviewed: https://review.openstack.org/642135
Committed: https://git.openstack.org/cgit/openstack/puppet-cinder/commit/?id=ae0c571a525e22f3ba891c3157093ccda666e642
Submitter: Zuul
Branch: master

commit ae0c571a525e22f3ba891c3157093ccda666e642
Author: SolKuczala <email address hidden>
Date: Fri Mar 8 20:00:08 2019 +0000

    Convert specs to RSpec 3.8.0 syntax with Transpec

    This conversion is done by Transpec 3.4.0
    This patch complements c09a93456eb806f0cdb6e858470334413ac61ea6
    adding all files inside defines/ dir.

    Partial-Bug: #1816857
    Change-Id: Ic00f8b38c5b84ff19fc945512f4f13aa11221c8b

Change abandoned by Soledad Kuczala (<email address hidden>) on branch: master
Review: https://review.openstack.org/642889

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers