Skip to content
This repository was archived by the owner on Aug 18, 2026. It is now read-only.

Latest commit

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SequelSpec

SequelSpec is a refactor of rspec_sequel_matchers borrowing concepts from shoulda-matchers. In contrast with rspec_sequel_matchers it provides a sweeter syntax and it doesn't rely on a specific mocking framework.

Installation

Add this line to your application's Gemfile:

gem 'sequel_spec', :group => :test

And then execute:

$ bundle

Or install it yourself as:

$ gem install sequel_spec

Usage

The matchers are automatically included on RSpec. Just use them at will.

Association

it{shouldhave_many_to_many:items}it{shouldhave_many_to_one:item}it{shouldhave_one_to_many:comments}it{shouldhave_one_to_one:photo}it{shouldhave_one_through_one:author}

You can specify options using #with_options

it{shouldhave_one_through_one(:author).with_options:key=>:user_id}

Validation

# Formatit{shouldvalidate_format_of(:name).with(/\w+/)}# Inclusionit{shouldensure_inclusion_of(:name).in(['John','Smith'])}# Integrity (valid integer)it{shouldvalidate_integrity_of(:age)}# Lengthit{shouldvalidate_length_of(:name).is(20)}it{shouldvalidate_length_of(:name).is_at_least(20)}it{shouldvalidate_length_of(:name).is_at_most(20)}it{shouldvalidate_length_of(:name).is_between(2..20)}# Not nullit{shouldvalidate_not_null(:category_id)}# Numericality (valid float)it{shouldvalidate_numericality_of(:price)}# Typeit{shouldvalidate_type_of(:birthdate).isDate}# Uniquenessit{shouldvalidate_uniqueness_of(:username)}

This matchers accepts options through #with_options as well

it{shouldvalidate_uniqueness_of(:username).with_options:message=>"This username is already taken"}

Or with the specialized helpers: #allowing_nil, #allowing_blank, #allowing_missing, and #with_message

it{shouldvalidate_length_of(:name).is(20).allowing_nil}it{shouldvalidate_length_of(:name).is(20).allowing_blank}it{shouldvalidate_length_of(:name).is(20).allowing_missing}it{shouldvalidate_length_of(:name).is(20).with_message"Name should be 20 chars long"}

Contributing

  1. Fork it ( http://github.com//sequel_spec/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Credits

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages