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

Add Launchy option to launch spec results instead of reading terminal output. #196

Merged
merged 12 commits into from
Sep 22, 2013

Conversation

vanboom
Copy link
Contributor

@vanboom vanboom commented Sep 3, 2013

The HTML format for rspec is beautiful. The master branch of guard-rspec does not have an option to launch the html output in a browser, as far as I can tell.

So I have implemented the :launchy option which will use Launchy to launch the rspec output file.

Please consider this feature as I think it will be valuable to many users to view the HTML format of rspec vs. the console output.

thanks!
Don

@coveralls
Copy link

Coverage Status

Coverage decreased (-84.91%) when pulling 9dfc9b3 on vanboom:master into dae32b3 on guard:master.

@thibaudgg
Copy link
Member

Sounds like a very good idea thanks, but I can't merge it without specs, could you please add some? Thanks!

@vanboom
Copy link
Contributor Author

vanboom commented Sep 4, 2013

Ok - I'll try. Sorry, I am still learning rspec and not yet proficient.
thanks,
Don

@thibaudgg
Copy link
Member

Great, don't hesitate to ask question, I'll review your specs with pleasure!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.32%) when pulling 21f2b0f on vanboom:master into dae32b3 on guard:master.

@vanboom
Copy link
Contributor Author

vanboom commented Sep 17, 2013

The execution flow is...

  1. Configure the Guardfile by adding: --out <filename.html> to the :cli, and :launchy=><filename.html> to the guard options.
  2. Guard should launch rspec, output the <filename.html> then launch Launchy to open the file in a browser.
  3. Launchy is not called unless <filename.html> exists after the rspec command is run.

Could you help with the skeleton of how you would test this behavior? How do we test that rspec properly created the output file? How can we test that Launchy.open(<filename.html>) was actually called.

Sorry, this is my first time writing rspec, and I am getting more proficient at model/view/controller spect, but testing system commands is way over my head.

thanks!

cmd_parts << "bundle exec" if bundle_exec?
cmd_parts << rspec_executable
cmd_parts << "--help"
`#{cmd_parts.join(' ')}`.include? "--failure-exit-code"
Copy link
Member

Choose a reason for hiding this comment

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

Indentation shouldn't change here no?

@thibaudgg
Copy link
Member

Regarding specs, the better is to mock Launchy.open call, try something like:

expect(Launchy).to receive(:open)

make sense to you?

…Moved require Launchy call to within the block where launchy option is detected.
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.29%) when pulling f0a381c on vanboom:master into dae32b3 on guard:master.

@@ -168,7 +176,7 @@ def run_via_drb(paths, options)
rescue DRb::DRbConnError
# Fall back to the shell runner; we don't want to mangle the environment!
run_via_shell(paths, options)
end
end
Copy link
Member

Choose a reason for hiding this comment

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

no tab here, right?

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.01%) when pulling 83495da on vanboom:master into dae32b3 on guard:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.15%) when pulling 83495da on vanboom:master into dae32b3 on guard:master.

expect(Launchy).to receive(:open).with("./tmp/test.html").and_return(true)
subject.run(['spec'], options)
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Looks nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - this was way over my head! Always learning. Thanks for a killer gem - guard-rspec is awesome! Glad I could contribute!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.12%) when pulling afc1320 on vanboom:master into dae32b3 on guard:master.

thibaudgg added a commit that referenced this pull request Sep 22, 2013
Add `launchy' option to launch spec results instead of reading terminal output.
@thibaudgg thibaudgg merged commit 354ffff into guard:master Sep 22, 2013
@thibaudgg
Copy link
Member

Thanks, version 3.1.0 released!

@vanboom
Copy link
Contributor Author

vanboom commented Sep 25, 2013

Thanks for merging, and for helping me through the pull request process.
Cheers!

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.

None yet

3 participants