Sha256: e51684d49d02560e934e8d4d8442147e0b367819c95fbee3846b7618b4971956
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
module RSpec::RubyContentMatchers class HaveModule < RSpec::RubyContentMatcher attr_reader :name, :type, :postfix def initialize(name, postfix=nil) @name = name.to_s.camelize super @name @postfix = postfix.to_s.camelize if postfix @type = :module end def failure_message super "Expected there to be the #{type} #{name}" end def negative_failure_message super "Did not expected there to be the #{type} #{name}" end protected def main_expr "#{type}" + SPACES + "#{name}#{postfix}" + SPACES + ANY_GROUP end def alt_end type end end class HaveClass < HaveModule def initialize(name, postfix) super name, postfix @type = :class end end def have_module(module_name, postfix=nil) HaveModule.new(module_name, postfix) end alias_method :be_module, :have_module def have_class(module_name) HaveModule.new(module_name, :class) end def have_class(klass, postfix = nil) HaveClass.new(klass, postfix) end alias_method :be_class, :have_class def have_helper_class(klass) HaveClass.new(klass, :helper) end alias_method :be_helper_class, :have_helper_class def have_controller_class(klass) HaveClass.new(klass, :controller) end alias_method :be_controller_class, :have_controller_class end
Version data entries
3 entries across 3 versions & 1 rubygems