Module: Tsubaki::Shoulda::Matchers

Defined in:
lib/tsubaki/matchers.rb,
lib/tsubaki/matchers/validate_my_number_of_matcher.rb,
lib/tsubaki/matchers/validate_corporate_number_of_matcher.rb

Overview

Provides RSpec-compatible & Test::Unit-compatible matchers for testing Tsubaki modules.

RSpec

In spec_helper.rb, you’ll need to require the matchers:

require "tsubaki/matchers"

And include the module:

RSpec.configure do |config|
  config.include Tsubaki::Shoulda::Matchers
end

Example:

describe User do
  it { should validate_my_number_of(:digits) }
  it { should validate_validate_my_number_of(:digits).strict.with_divider('-') }
end

TestUnit

In test_helper.rb, you’ll need to require the matchers as well:

require "tubaki/matchers"

And extend the module:

class ActiveSupport::TestCase
  extend Tsubaki::Shoulda::Matchers

  #...other initializers...#
end

Example:

require 'test_helper'

class UserTest < ActiveSupport::TestCase
  should validate_validate_my_number_of(:digits)
  should validate_validate_my_number_of(:digits).strict.with_divider('-')
end

Defined Under Namespace

Classes: ValidateCorporateNumberOfMatcher, ValidateMyNumberOfMatcher

Instance Method Summary collapse

Instance Method Details

#validate_corporate_number_of(attribute_name) ⇒ Object

Ensures that the given instance or class validates the format of the corporate number as specified.

Example:

describe Corporation do
  it { should validate_corporate_number_of(:digits)
  it { should validate_corporate_number_of(:digits).strict.with_divider('-') }
end


12
13
14
# File 'lib/tsubaki/matchers/validate_corporate_number_of_matcher.rb', line 12

def validate_corporate_number_of(attribute_name)
  ValidateCorporateNumberOfMatcher.new(attribute_name)
end

#validate_my_number_of(attribute_name) ⇒ Object

Ensures that the given instance or class validates the format of the my number as specified.

Example:

describe User do
  it { should validate_my_number_of(:digits)
  it { should validate_my_number_of(:digits).strict.with_divider('-') }
end


12
13
14
# File 'lib/tsubaki/matchers/validate_my_number_of_matcher.rb', line 12

def validate_my_number_of(attribute_name)
  ValidateMyNumberOfMatcher.new(attribute_name)
end