forked from remarkable-rb/remarkable
-
Notifications
You must be signed in to change notification settings - Fork 6
/
human_names.rb
37 lines (32 loc) · 996 Bytes
/
human_names.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
if defined?(Spec)
module Spec #:nodoc:
module Example #:nodoc:
module ExampleGroupMethods #:nodoc:
# This allows "describe User" to use the I18n human name of User.
#
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
# This is for rspec <= 1.1.12.
#
def self.description_text(*args)
self.build_description_with_i18n(*args)
end
# This is for rspec >= 1.2.0.
#
def self.build_description_from(*args)
text = ExampleGroupMethods.build_description_with_i18n(*args)
text == "" ? nil : text
end
end
end
end
end