Awesome
Oktobertest::Contrib
Contributed Oktobertest extensions.
Installation
Add this line to your application's Gemfile:
gem 'oktobertest-contrib', group: :test
# or this if you want to use oktobertest-contrib master
# gem 'oktobertest-contrib', group: :test, github: 'patriciomacadden/oktobertest-contrib'
And then execute:
$ bundle
Or install it yourself as:
$ gem install oktobertest-contrib
Optional dependencies
- rack-test if you want to use
oktobertest/rack/test
. - capybara and
poltergeist if you want to use
oktobertest/capybara
.
Usage
require
an extension to use it. If you want to use all of them, just
require 'oktobertest/contrib'
.
Available extensions
Extra assertions
This extension includes a lot of useful assertions. To use it, just require it:
require 'oktobertest'
require 'oktobertest/assertions'
scope do
test do
expected, actual = 1, 1
assert_equal expected, actual
end
end
Available assertions
assert_equal(expected, actual, message)
: asserts that the expected and the actual values are equal.assert_includes(collection, item, message)
: asserts that the collection includes the item.assert_instance_of(klass, object, message)
: asserts that the object is an instance of class.assert_kind_of(klass, object, message)
: asserts that the object is kind of class.assert_matches(matcher, object, message)
: asserts that the object matches the matcher.
Rack related assertions
This extesion includes rack related assertions. To use it, just require it:
require 'oktobertest'
require 'oktobertest/rack/test'
scope do
setup do
@app = Proc.new { |env| [200, {}, ['hello world']] }
end
test 'GET /' do
get '/'
assert_status 200
# equivalent to:
# assert_equal 200, last_response.status
end
end
Available assertions
assert_status(status_code, message)
: asserts that the response status code is equal tostatus_code
.assert_header(header, value, message)
: asserts that the response headerheader
is equal tovalue
.
Capybara
This extension includes automatic setup for Capybara.
require 'oktobertest'
require 'oktobertest/capybara'
Capybara.app = App
scope do
test 'works' do
visit '/'
assert page.has_content? 'hello world'
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
License
See the LICENSE.