[yast-devel] rspec 3.0
Hi, in this blog post http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3 is summary of changes in new rspec 3.0. I do not think that we will use it for SLE-12 tests, but maybe it will be used for 13.2. In general I think we should not use new syntax now, but what we can do is to not use deprecated syntax as there is already alternatives to prevent future problems. Josef -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
In general I
think we should not use new syntax now, but what we can do is to not use deprecated syntax as there is already alternatives to prevent future problems.
In my POV, it would be nice to convert tests from old testsuite into rspec ... And than convert from rspec into another rspec ;-) In general, I think that there is no need to use obsolete syntax as we write specs from the scratch. Michal -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On Fri, 23 May 2014 09:55:24 +0200 "Michal Filka" <michal.filka@suse.cz> wrote:
In general I
think we should not use new syntax now, but what we can do is to not use deprecated syntax as there is already alternatives to prevent future problems.
In my POV, it would be nice to convert tests from old testsuite into rspec ... And than convert from rspec into another rspec ;-)
In general, I think that there is no need to use obsolete syntax as we write specs from the scratch.
Michal
I agree. I just see one of rspec test using obsolete monkey patching with `instance.stub(...)`, so I will like to raise it to have easy switch to new rspec. Josef -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Dne 23.5.2014 10:04, Josef Reidinger napsal(a):
I agree. I just see one of rspec test using obsolete monkey patching with `instance.stub(...)`, so I will like to raise it to have easy switch to new rspec.
RSpec allows to configure the used syntax, it's quite easy, just add this snippet to your spec_helper.rb: # allow only the new "expect" RSpec syntax RSpec.configure do |config| config.expect_with :rspec do |c| c.syntax = :expect end config.mock_with :rspec do |c| c.syntax = :expect end end (see https://github.com/yast/yast-registration/blob/master/test/spec_helper.rb#L1...) This configuration removes .stub method definition so if it is used somewhere in the tests it will fail with "undefined method `stub'" error. You should easily find the places to fix. -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On 12.8.2014 15:22, Ladislav Slezak wrote:
Dne 23.5.2014 10:04, Josef Reidinger napsal(a):
I agree. I just see one of rspec test using obsolete monkey patching with `instance.stub(...)`, so I will like to raise it to have easy switch to new rspec.
I've been just checking a PR made by Schubi: https://github.com/yast/yast-services-manager/pull/101 This also changes: - expect(ServicesManager.import(data)).to be_true + expect(ServicesManager.import(data)).to eq(true) According to documentation at https://github.com/rspec/rspec-expectations - we should be using expect(ServicesManager.import(data)).to be true but according to Ancor, we have to use expect(ServicesManager.import(data)).to eq(true) because this works with both, the old and the new version of RSpec. I wanted to make this clear so everyone has the same expectations when it comes to reviewing others' code. Thanks && Bye Lukas -- Lukas Ocilka, Systems Management (Yast) Team Leader Cloud & Systems Management Department, SUSE Linux -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
On 12/17/2014 01:15 PM, Lukas Ocilka wrote:
On 12.8.2014 15:22, Ladislav Slezak wrote:
Dne 23.5.2014 10:04, Josef Reidinger napsal(a):
I agree. I just see one of rspec test using obsolete monkey patching with `instance.stub(...)`, so I will like to raise it to have easy switch to new rspec.
I've been just checking a PR made by Schubi: https://github.com/yast/yast-services-manager/pull/101 This also changes:
- expect(ServicesManager.import(data)).to be_true + expect(ServicesManager.import(data)).to eq(true)
According to documentation at https://github.com/rspec/rspec-expectations - we should be using
expect(ServicesManager.import(data)).to be true
but according to Ancor, we have to use
expect(ServicesManager.import(data)).to eq(true)
because this works with both, the old and the new version of RSpec.
To be precise 1) x.to be_true Works only with RSpec 2. That's why we are changing it. It succeeds if x is evaluated to be true, that is, anything but nil or false. 2) x.to be(true) Works with both versions. It succeeds only if x is exactly a boolean true. Internally uses x.equal?(true) for comparison, which leads to confusing messages sometimes if the comparison fails. 3) x.to eq(true) Works with both versions. Very similar to (2) but using "==" for comparison, which leads to more understandable messages (and is probably what the author meant). 4) x.to be_truthy Works only with RSpec 3. The equivalent to be_true in the new RSpec version. In some document (which I cannot find right now) eq(true) or eql(true) was suggested as migration path from be_true, so we adopted it. In my opinion, it makes more sense semantically. Cheers. -- Ancor González Sosa YaST Team at SUSE Linux GmbH -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
participants (5)
-
Ancor Gonzalez Sosa
-
Josef Reidinger
-
Ladislav Slezak
-
Lukas Ocilka
-
Michal Filka