module Tsubaki::Shoulda::Matchers
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
Public Instance Methods
validate_corporate_number_of(attribute_name)
click to toggle source
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
# 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)
click to toggle source
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
# File lib/tsubaki/matchers/validate_my_number_of_matcher.rb, line 12 def validate_my_number_of(attribute_name) ValidateMyNumberOfMatcher.new(attribute_name) end