Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dogweather/rspec-webservice_matchers
Black-box web app testing
https://github.com/dogweather/rspec-webservice_matchers
devops rspec-matchers ruby tdd
Last synced: about 23 hours ago
JSON representation
Black-box web app testing
- Host: GitHub
- URL: https://github.com/dogweather/rspec-webservice_matchers
- Owner: dogweather
- License: mit
- Created: 2014-01-07T23:11:50.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-12-08T20:09:07.000Z (about 1 year ago)
- Last Synced: 2025-01-17T04:06:09.857Z (8 days ago)
- Topics: devops, rspec-matchers, ruby, tdd
- Language: Ruby
- Homepage: https://dogsnog.blog/2014/01/16/new-open-source-library-for-test-driven-devops/
- Size: 354 KB
- Stars: 78
- Watchers: 4
- Forks: 5
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RSpec::WebserviceMatchers
[![Maintainability](https://api.codeclimate.com/v1/badges/501f791f1ea83905e992/maintainability)](https://codeclimate.com/github/dogweather/rspec-webservice_matchers/maintainability) [![Gem Version](https://badge.fury.io/rb/rspec-webservice_matchers.svg)](https://badge.fury.io/rb/rspec-webservice_matchers)
A [gem](https://rubygems.org/gems/rspec-webservice_matchers) to black-box test a web server configuration. For example, whether a site's SSL certificate is correctly configured and not expired:
```ruby
expect('github.com').to have_a_valid_cert
```It's a tool for doing **Test Driven Devops** (I just made that up). See [my introductory blog post](https://dogsnog.blog/2014/01/16/new-open-source-library-for-test-driven-devops/) for the backstory.
This library takes a minimalist approach: it simply adds new RSpec matchers. Therefore, you can use your own RSpec writing style; there's no new DSL to learn.
Installation
------------
```Shell
$ gem install rspec-webservice_matchers
```What You Get
------------
These new RSpec matchers:| | Notes
|-------------------------------|------------------------------------------------
|**be_up** | Looks for a 200, but will follow up to four redirects
|**be_fast** | Checks for Google [PageSpeed](https://developers.google.com/speed/pagespeed/insights/) score >= 85. Expects the environment variable `WEBSERVICE_MATCHER_INSIGHTS_KEY` to contain a [Google "server" API key](https://developers.google.com/speed/docs/insights/v2/getting-started) with PageSpeed Insights API enabled.
|**enforce_https_everywhere** | Passes if the site will _only_ allow SSL connections. See the [EFF project, HTTPS Everywhere](https://www.eff.org/https-everywhere)
|**have_a_valid_cert** | Will fail if there's no cert, or it's expired or incorrectly configured
|**be_status** | A low-level matcher to explicitly check for a 200, 503, or any other code
|**redirect_permanently_to** | Checks for 301 and a correct destination URL
|**redirect_temporarily_to** | Checks for 302 or 307 and a correct destinationExample
-------Here's an example which uses them all:
```Ruby
require 'rspec/webservice_matchers'describe 'My app' do
context 'www.myapp.com' do
it { should be_up }
it { should be_fast }
it { should have_a_valid_cert }
endit 'serves the "about" page without redirecting' do
expect('http://www.myapp.com/about').to be_status 200
endit 'only serves via www' do
expect('http://myapp.com').to redirect_permanently_to 'http://www.myapp.com/'
endit 'forces visitors to use https' do
expect('myapp.com').to enforce_https_everywhere
end
end
```Related Projects
----------------
* [json-schema-rspec](https://github.com/sharethrough/json-schema-rspec)
* [serverspec](http://serverspec.org)
* [HTTP Assertions](https://github.com/dogweather/HTTP-Assertions): A precusor to this library. Written in the older test case / assert style.