No release in over 3 years
Low commit activity in last 3 years
There's a lot of open issues
Black-box web app configuration testing
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

RSpec::WebserviceMatchers

Maintainability Gem Version

A gem to black-box test a web server configuration. For example, whether a site's SSL certificate is correctly configured and not expired:

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 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

$ 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 score >= 85. Expects the environment variable WEBSERVICE_MATCHER_INSIGHTS_KEY to contain a Google "server" API key with PageSpeed Insights API enabled.
enforce_https_everywhere Passes if the site will only allow SSL connections. See the EFF project, 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 destination

Example

Here's an example which uses them all:

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 }
  end

  it 'serves the "about" page without redirecting' do
    expect('http://www.myapp.com/about').to be_status 200
  end

  it 'only serves via www' do
    expect('http://myapp.com').to redirect_permanently_to 'http://www.myapp.com/'
  end

  it 'forces visitors to use https' do
    expect('myapp.com').to enforce_https_everywhere
  end
end

Related Projects