RSpec matchers for Sequel which tests database, not model
RSpec.configure do |config|
config.include RSpec::Matchers::Sequel
end
describe DB do
it { expect(DB).to have_enum('role_types').with_values(%w(admin manager user)) }
end
describe 'companies table' do
let(:table) { :companies }
it { expect(table).to have_primary_keys(:id, :city_id) }
it { expect(table).to have_column(:name).of_type(String).not_null.with_default('') }
it { expect(table).to have_unique_index_on(:email) }
it { expect(table).to have_index_on([:password, :email]).named('companies_credentials') }
it { expect(table).to refer_to(:city).from_fk(:city_id).to_pk(:id).on_update(:cascade).on_delete(:set_null) }
end
Add this line to your application's Gemfile:
gem 'rspec-sequel_expectations'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-sequel_expectations
- Fork it ( https://github.com/Ptico/rspec-sequel_expectations/fork )
- 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 a new Pull Request