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

Refactored spec tests #104

Merged
merged 2 commits into from Feb 27, 2015
Merged

Refactored spec tests #104

merged 2 commits into from Feb 27, 2015

Conversation

ghost
Copy link

@ghost ghost commented Feb 19, 2015

Broke out all config files to fixtures, tried to minimize code duplication.

@ghoneycutt
Copy link
Owner

I think the issue is with r.push Packages to build the require string. Here's how I solved this before

https://github.com/ghoneycutt/puppet-module-ntp/blob/master/spec/classes/init_spec.rb#L252-288

@ghost
Copy link
Author

ghost commented Feb 19, 2015

@ghoneycutt I wanted to keep packages and requirements as arrays as long as possible, to prepare for the vas tests in #102, I hope that's ok.

@ghost
Copy link
Author

ghost commented Feb 20, 2015

@ghoneycutt I added 2 commits that are not part of the spec test, but are problems I found when writing them. Not sure if this should be separate pull requests.

@ghoneycutt
Copy link
Owner

Separate PR's are not needed, though putting them in a separate commit is nice to make it obvious what is a refactor and what is new. Since you are adding missing tests instead of functionality to code, this is easy. If you were adding functionality to the code, then that should always be in a separate PR from a bugfix or refactor.

@@ -990,7 +990,7 @@
require => Package[$my_package_name],
}

file { 'pam_common_noninteractive_session':
file { 'pam_common_session_noninteractive':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the resource title? This could potentially be construed as a breaking change if someone tightly coupled their module to ours and they have a relationship to this resource.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's part of the "Standardize naming" commit. It would remove some special cases from the spec tests, but it not needed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I don't understand what reversing the name buys us. Does it make spec tests easier or something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it removes the logic that has to handle that file as a special case. See https://github.com/emahags/puppet-module-pam/commit/b0b56684c24e2e891e2bb50db23a00dac42956f0

@ghost
Copy link
Author

ghost commented Feb 23, 2015

@ghoneycutt I have rebased the pull request without the 2 changes to noninteractive_session and suse 9 package requirements, I'll do them as separate PRs. Is there something you see that needs to be changed or added?

@ghoneycutt
Copy link
Owner

Hi @Phil-Friderici

If you have the time, I would really appreciate an extra set of eyes on this PR to ensure that no tests were accidentally dropped.

@Phil-Friderici
Copy link
Contributor

@ghoneycutt I'll have a look on it
@emahags impressive work !

@Phil-Friderici
Copy link
Contributor

@ghoneycutt There was a double check (in my eyes) that was removed. Should be ok because the file is tested as fixture that does not contain the line in question.
https://github.com/ghoneycutt/puppet-module-pam/blob/v2.15.0/spec/classes/init_spec.rb#L384-L385

@Phil-Friderici
Copy link
Contributor

@ghoneycutt @emahags did check el5 today, think that others get faster now. Continue tomorrow (hopefully)

@ghoneycutt
Copy link
Owner

Thanks @Phil-Friderici !

I did functional tests of EL6 and 7 and no changes, as expected.

@ghost
Copy link
Author

ghost commented Feb 25, 2015

@Phil-Friderici I updated lines 372 and 397 with your recommendation. Had to filter out solaris though as they don't use those files.

@Phil-Friderici
Copy link
Contributor

@emahags I don't see the checks for symlinks in the output anymore, even though I can see the code. Maybe the problem is in this line: https://github.com/emahags/puppet-module-pam/blob/spec/spec/classes/init_spec.rb#L302

Will be rebased, doing separate commit for clarity.
@ghost
Copy link
Author

ghost commented Feb 27, 2015

@Phil-Friderici Good find, I forgot to change that name.

@Phil-Friderici
Copy link
Contributor

@emahags tests for :vas_major_version => '4' are lost

@ghost
Copy link
Author

ghost commented Feb 27, 2015

@Phil-Friderici
Copy link
Contributor

@ghost
Copy link
Author

ghost commented Feb 27, 2015

@Phil-Friderici Did you want me to do something about this and if so what?

@Phil-Friderici
Copy link
Contributor

@emahags I am just looking for completness at the moment. If there is no difference between 3 and 4 there is no need to test it. But there were specific test for 3 and 4 in the old spec tests.
Decide yourself if you think they are needed or obsolete.

@Phil-Friderici
Copy link
Contributor

@emahags I can go into the details when finished with completeness checks.

@ghost
Copy link
Author

ghost commented Feb 27, 2015

@Phil-Friderici Unless something in the test logic isn't working, I do have tests for version 3 and the default version (4). I guess I could change my context to make it more clear that the default vas version is used.

@Phil-Friderici
Copy link
Contributor

@emahags hahahaha... yes I agree too now 👍
Your new tests are done in the same way like the old ones. Making the context aware of that would help people like me ;)

@Phil-Friderici
Copy link
Contributor

@ghoneycutt:
what I did:

  • verified that all checks are still existing by comparing the output of old and new style rspec testings

what I didn't:

  • did not verify the content of fixture files compared to the old style

conclusion:
@emahags spec testings are a big step forward ! 👍
Some stuff got fixed, some missing tests were added (dependency checks)

I would merge it

@emahags Thanks a lot for this hard work !

ghoneycutt added a commit that referenced this pull request Feb 27, 2015
@ghoneycutt ghoneycutt merged commit 2a2d717 into ghoneycutt:master Feb 27, 2015
@ghoneycutt
Copy link
Owner

@emahags @Phil-Friderici

Amazing work! Can't believe that init_spec.rb is 80% smaller. This is really going to help people add features with the simplified testing framework.

@ghost ghost deleted the spec branch March 2, 2015 14:18
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

Successfully merging this pull request may close these issues.

2 participants