Sha256: 260b8d3013bbff32e8fba92609adf52edc989aac594df13a5f7bab763731740b

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

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 RAILS_I18N && 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 build_description_from(*args)
          text = ExampleGroupMethods.build_description_with_i18n(*args)
          text == "" ? nil : text
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
remarkable_activerecord-3.0.2 lib/remarkable_activerecord/human_names.rb
remarkable_activerecord-3.0.4 lib/remarkable_activerecord/human_names.rb
remarkable_activerecord-3.0.6 lib/remarkable_activerecord/human_names.rb
remarkable_activerecord-3.0.3 lib/remarkable_activerecord/human_names.rb
remarkable_activerecord-3.0.5 lib/remarkable_activerecord/human_names.rb
remarkable_activerecord-3.0.7 lib/remarkable_activerecord/human_names.rb
remarkable_activerecord-3.0.8 lib/remarkable_activerecord/human_names.rb