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

document only_if for controls #760

Closed
chris-rock opened this issue May 16, 2016 · 9 comments · Fixed by #5038
Closed

document only_if for controls #760

chris-rock opened this issue May 16, 2016 · 9 comments · Fixed by #5038
Labels
Aspect: Docs Write the Fine Manual Component: Website inspec.io website
Milestone

Comments

@chris-rock
Copy link
Contributor

chris-rock commented May 16, 2016

Description

With #619 we introduced only_if for controls, but we have not documented it yet.

control 'hello' do
  only_if { os[:family] != 'arch' }
  describe 1 do
    it { should eq 2 }
  end
end

InSpec and Platform Version

0.22.0

Aha! Link: https://chef.aha.io/features/SH-2193

@chris-rock chris-rock added the Aspect: Docs Write the Fine Manual label May 16, 2016
@chris-rock chris-rock added this to the 1.0.0 milestone Jul 26, 2016
@nvtkaszpir
Copy link
Contributor

+1

@chris-rock chris-rock modified the milestones: 1.0.0, 1.1.0 Sep 21, 2016
@Zeerg
Copy link

Zeerg commented May 4, 2018

Any update on this?

@avishefi
Copy link

I think this is already documented: https://www.inspec.io/docs/reference/dsl_inspec/#exclude-specific-test

@walterdolce
Copy link

Is there any chance when someone types only_if in the website's search bar the comment above (and/or any additional piece of documentation related to this) could appear as a search result?

@calebwhitt
Copy link

@walterdolce sounds like a great idea. This is still not the case, and I only found https://www.inspec.io/docs/reference/dsl_inspec/#exclude-specific-test because I remembered where I'd seen a mention of only_if before in the docs. Are there any updates on this? I feel the current documentation for only_if isn't extensive enough.

@miah miah added the Component: Website inspec.io website label Mar 2, 2019
@rdonkin
Copy link

rdonkin commented Apr 18, 2019

I agree that the documentation is not complete for only_if - from reading https://www.inspec.io/docs/reference/dsl_inspec/#exclude-specific-test it's not clear whether this applies to the whole control clause, or is tied to the next describe only.

It would also be good to have documented somewhere how this differs from using skip if ...:

    before do
      skip if some_condition
    end

Examples like in that page are great, but deeper docs are also needed for reference - Ansible and Terraform are reasonable examples here.

@stale
Copy link

stale bot commented Apr 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label Apr 17, 2020
@walterdolce
Copy link

Here's some activity 😉

@stale stale bot removed the Stale label Apr 17, 2020
@james-stocks
Copy link
Contributor

james-stocks commented Apr 20, 2020

A couple of points worth documenting:

  • it applies to the control (maybe document what happens if an only_if is attempted outside of a control block)
  • Only one is allowed per control, but you can && multiple conditions
  • it results in a skip and not a pass - it should not be used where the "only if" condition means that the system-under-test is compliant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect: Docs Write the Fine Manual Component: Website inspec.io website
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants