Skip to content

Collection of RSpec matchers for verbose testers.

License

Notifications You must be signed in to change notification settings

mdeering/phillumeny

Repository files navigation

Collection of RSpec matchers for verbose testers.

Configuration

# spec/support/phillumeny.rb
require 'phillumeny'

# require 'phillumeny/active_record'

RSpec.configure do |config|
  config.include Phillumeny::ActiveModel,  type: :model
  config.include Phillumeny::ActiveRecord, type: :model
  config.include Phillumeny::FactoryBot,   type: :model
end

ActiveModel

RSpec.describe Webpage, type: :model do

  it { should     validate_presence_of_any(:headline, :title).valid_values(title: 'this') }
  it { should_not validate_presence_of_any(:headline, :title) }
  it { should_not validate_presence_of_any(:headline, :title).valid_value(:title, 'that') }

end

ActiveRecord

RSpec.describe Post, type: :model do

  [[:include_in_sitemap, :published_at], :published_at].each do |columns|
    it { should cover_query_with_indexes(columns) }
  end

  {
    include_in_sitemap:       true,
    sitemap_change_frequency: 'monthly',
    sitemap_priorty:          5,
    title:                    nil
  }.each do |attribute, value|
    it { should have_default_value_of(value).for(attribute).in_the_database }
  end

end

Factory Bot

# spec/models/user_spec.rb
require 'spec_helper'

RSpec.describe User, type: :model do

  context 'Factories' do

    it { should have_a_valid_factory }

    it { should_not have_a_valid_factory.with_trait(:something_wrong) }

  end
end

About

Collection of RSpec matchers for verbose testers.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages