Skip to content

Instantly share code, notes, and snippets.

@paulspencerwilliams
Created October 24, 2014 08:21
Show Gist options
  • Save paulspencerwilliams/f54b581a7bf34db33df8 to your computer and use it in GitHub Desktop.
Save paulspencerwilliams/f54b581a7bf34db33df8 to your computer and use it in GitHub Desktop.
require 'rspec/expectations'
include ActionController::UrlFor
#include ActionController::RackDelegation
RSpec::Matchers.define :be_a_created_for do | expected |
match do | actual |
expect(actual).to have_http_status(:created)
expect(actual.headers["Locaton"]).to eql(url_for(expected))
end
failure_message do |actual|
"Expected response to be a <created>, but was #{actual.status}
Expected Location to be a <#{expected.location}>, but was #{actual.headers['Location']}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment