Socket
Book a DemoInstallSign in
Socket

workable_json_assertions

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workable_json_assertions

0.1.2
bundlerRubygems
Version published
Maintainers
2
Created
Source

WorkableJsonAssertions

This gem adds basic JSON assertions to your controller tests.

Installation

Add this line to your application's Gemfile:

group :test do
  gem 'workable_json_assertions'
end

And then execute:

$ bundle

Or install it yourself as:

$ gem install workable_json_assertions

Usage

assert_json_response_empty

class BasicControllerTest < ActionController::TestCase
	def test_success
		get :index # {}
		assert_json_response_empty
	end
end

assert_json_response_equal

class BasicControllerTest < ActionController::TestCase
	def test_success
		get :index # { 'key': 'value' }
		assert_json_response_equal { key: 'value' }
	end
end

assert_json_response_equal_except

class BasicControllerTest < ActionController::TestCase
	def test_success
		get :index # { 'key': 'value', 'created_at': '2016-07-25', 'updated_at': '2016-07-26' }
		assert_json_response_equal_except { key: 'value' }, %i(created_at updated_at)
	end
end

assert_json_response_includes

class BasicControllerTest < ActionController::TestCase
	def test_success
		get :index # { 'key': 'value', 'created_at': '2016-07-25', 'updated_at': '2016-07-26' }
		assert_json_response_includes({ key: 'value' })
    assert_json_response_includes({ created_at: '2016-07-25' })
	end
end

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 20 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.