Module: Spec::Example::ExampleGroupMethods

Defined in:
lib/remarkable_mongomapper/human_names.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.build_description_from(*args) ⇒ Object

This is for rspec >= 1.2.0.



29
30
31
32
# File 'lib/remarkable_mongomapper/human_names.rb', line 29

def self.build_description_from(*args)
  text = ExampleGroupMethods.build_description_with_i18n(*args)
  text == "" ? nil : text
end

.build_description_with_i18n(*args) ⇒ Object

This allows “describe User” to use the I18n human name of User.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/remarkable_mongomapper/human_names.rb', line 8

def self.build_description_with_i18n(*args)
  args.inject("") do |description, arg|
    arg = if arg.respond_to?(:human_name)
      arg.human_name(:locale => Remarkable.locale)
    else
      arg.to_s
    end

    description << " " unless (description == "" || arg =~ /^(\s|\.|#)/)
    description << arg
  end
end

.description_text(*args) ⇒ Object

This is for rspec <= 1.1.12.



23
24
25
# File 'lib/remarkable_mongomapper/human_names.rb', line 23

def self.description_text(*args)
  self.build_description_with_i18n(*args)
end