Sha256: e2a6a0408a8aa846776d4efe53a964fbacac81ee681c1f514aae2bac9238cc48

Contents?: true

Size: 1.02 KB

Versions: 29

Compression:

Stored size: 1.02 KB

Contents

riml_include 'dsl.riml'

class Person
  def initialize(name)
    self.name = name
  end

  defm get_name()
    return self.name
  end
end

class PersonNameMatcher
  defm match(expected, actual)
    self.result = actual.get_name()
    return self.result == expected
  end

  defm failure_message_for_match(expected, actual)
    return "expected person name to be “#{expected}” but was “#{self.result}”"
  end

  defm failure_message_for_mismatch(expected, actual)
    return "expected person name to not be “#{expected}” but was “#{self.result}”"
  end
end

matcher = new PersonNameMatcher()
define_matcher('to_have_name', 'to_not_have_name', matcher)

class PersonNameMatcherSpec
  defm describe
    return 'Custom matcher to_have_name and to_not_have_name'
  end

  defm before_each
    self.person = new Person('john')
  end

  defm it_can_check_for_persons_name
    expect(self.person).to_have_name('john')
  end

  defm it_can_check_for_negation_of_persons_name
    expect(self.person).to_not_have_name('foo')
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
speckle-0.2.0 spec/matchers/custom_matcher_spec.riml
speckle-0.1.31 spec/matchers/custom_matcher_spec.riml
speckle-0.1.30 spec/matchers/custom_matcher_spec.riml
speckle-0.1.29 spec/matchers/custom_matcher_spec.riml
speckle-0.1.28 spec/matchers/custom_matcher_spec.riml
speckle-0.1.27 spec/matchers/custom_matcher_spec.riml
speckle-0.1.26 spec/matchers/custom_matcher_spec.riml
speckle-0.1.25 spec/matchers/custom_matcher_spec.riml
speckle-0.1.24 spec/matchers/custom_matcher_spec.riml
speckle-0.1.23 spec/matchers/custom_matcher_spec.riml
speckle-0.1.22 spec/matchers/custom_matcher_spec.riml
speckle-0.1.21 spec/matchers/custom_matcher_spec.riml
speckle-0.1.20 spec/matchers/custom_matcher_spec.riml
speckle-0.1.19 spec/matchers/custom_matcher_spec.riml
speckle-0.1.18 spec/matchers/custom_matcher_spec.riml
speckle-0.1.17 spec/matchers/custom_matcher_spec.riml
speckle-0.1.16 spec/matchers/custom_matcher_spec.riml
speckle-0.1.15 spec/matchers/custom_matcher_spec.riml
speckle-0.1.14 spec/matchers/custom_matcher_spec.riml
speckle-0.1.13 spec/matchers/custom_matcher_spec.riml