Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby Spec tests - test filtering #2

Closed
MSP-Greg opened this issue Jul 1, 2017 · 1 comment
Closed

Ruby Spec tests - test filtering #2

MSP-Greg opened this issue Jul 1, 2017 · 1 comment

Comments

@MSP-Greg
Copy link
Owner

MSP-Greg commented Jul 1, 2017

@eregon

I created a blank repo for general build, test, and patch discussions re Ruby on Windows.

There's patch (see #1) that allows windows ruby to use fractional seconds for file times. There are several spec tests that have platform_is :linux do because of this issue. Obviously, one can allow windows test by using platform_is :linux, :windows do, but that isn't restricting the version.

So, I'd like the test to run if the platform is :linux or it's :windows and the version >= 2.5.0.

In what manner would you prefer to constrain a test for that type of criteria?

Thanks.

@eregon
Copy link

eregon commented Jul 2, 2017

There is unfortunately no easy way to do this currently.

It is however easier if we only need to test this extra feature on platforms supporting it (not asserting that it does not work on the other platforms, which I think is not so useful in this case).
The best way currently is to use shared specs:

describe :file_mtime_us, shared: true do
  it "returns the modification Time of the file with microseconds" do
    ...
  end
end

platform_is :linux do
  it_should_behave_like :file_mtime_us
end

platform_is :windows do
  ruby_version_is "2.5" do
    it_should_behave_like :file_mtime_us
  end
end

Going forward I would like to improve this as described in ruby/mspec#30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants