class TSCheck::RSpec::Matchers::TSTypeMatcher

Public Class Methods

new(type, options) click to toggle source
# File lib/tscheck/rspec/matchers/ts_type_matcher.rb, line 5
def initialize(type, options)
  @type = type
  @options = options
end

Public Instance Methods

description() click to toggle source
# File lib/tscheck/rspec/matchers/ts_type_matcher.rb, line 10
def description
  "match TypeScript type #{@type}"
end
failure_message() click to toggle source
# File lib/tscheck/rspec/matchers/ts_type_matcher.rb, line 20
def failure_message
  "expected #{@actual_string} to be of TypeScript type #{@type}, but type check failed with error:\n#{@ts_error}"
end
failure_message_when_negated() click to toggle source
# File lib/tscheck/rspec/matchers/ts_type_matcher.rb, line 24
def failure_message_when_negated
  "expected #{@actual_string} not to be of TypeScript type #{@type}, but type check succeeded"
end
matches?(actual) click to toggle source
# File lib/tscheck/rspec/matchers/ts_type_matcher.rb, line 14
def matches?(actual)
  @actual_string = actual.is_a?(String) ? actual : actual.to_json
  @ts_error = TSCheck::RSpec.server.check_type(@actual_string, type: @type, **@options)
  @ts_error.nil?
end