Class: Spec::Runner::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/spec-i18n/runner/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rspec_languageObject (readonly)

Returns the value of attribute rspec_language.



5
6
7
# File 'lib/spec-i18n/runner/configuration.rb', line 5

def rspec_language
  @rspec_language
end

Instance Method Details

#languageObject

Return the current language in configure block



24
25
26
# File 'lib/spec-i18n/runner/configuration.rb', line 24

def language
  rspec_language
end

#load_all_matchersObject



67
68
69
# File 'lib/spec-i18n/runner/configuration.rb', line 67

def load_all_matchers
  Spec::Matchers.register_all_matchers
end

#load_dsl_keywordsObject



50
51
52
# File 'lib/spec-i18n/runner/configuration.rb', line 50

def load_dsl_keywords
  Spec::DSL::Main.register_adverbs       
end

#load_example_keywordsObject



58
59
60
61
# File 'lib/spec-i18n/runner/configuration.rb', line 58

def load_example_keywords
  Spec::Example::ExampleGroupMethods.register_example_adverbs
  Spec::Example::Pending.translate_pending_keywords
end

#load_expectation_keywordsObject



54
55
56
# File 'lib/spec-i18n/runner/configuration.rb', line 54

def load_expectation_keywords
  Kernel.register_expectations_keywords
end

#load_hooks_keywordsObject



63
64
65
# File 'lib/spec-i18n/runner/configuration.rb', line 63

def load_hooks_keywords
  Spec::Example::BeforeAndAfterHooks.register_hooks
end

#load_languageObject

Translate all the keywords for the language specified



30
31
32
33
34
35
36
37
38
# File 'lib/spec-i18n/runner/configuration.rb', line 30

def load_language
  load_dsl_keywords
  load_expectation_keywords
  load_example_keywords
  load_hooks_keywords
  load_all_matchers
  load_subject_keywords
  load_shared_examples_keywords
end

#load_shared_examples_keywordsObject



76
77
78
79
80
# File 'lib/spec-i18n/runner/configuration.rb', line 76

def load_shared_examples_keywords
  Spec::DSL::Main.translate_shared_examples_for
  Spec::DSL::Main.translate_share_as_keywords
  Spec::Example::ExampleGroupMethods.translate_it_should_behave_like
end

#load_subject_keywordsObject



71
72
73
74
# File 'lib/spec-i18n/runner/configuration.rb', line 71

def load_subject_keywords
  Spec::Example::Subject::ExampleGroupMethods.register_subjects
  Spec::Example::Subject::ExampleMethods.register_subjects
end

#spec_language(language_for_translated) ⇒ Object

Method to put in the Spec::Runner configure block and translated all the Rspec methods

Spec::Runner.configure do |config|

config.spec_language :es
...

end



15
16
17
18
19
20
# File 'lib/spec-i18n/runner/configuration.rb', line 15

def spec_language(language_for_translated)
  @rspec_language = language_for_translated ? language_for_translated.to_s : raise(UndefinedLanguageError, 'Language #{language_for_translated.class}')
  warning_messages_for_incomplete_languages!(SpecI18n.natural_language)
  load_language
  rspec_language
end

#warning_messages_for_incomplete_languages!(natural_language) ⇒ Object

Return a Warning for incomplete language Nil if natural_language is complete



43
44
45
46
47
48
# File 'lib/spec-i18n/runner/configuration.rb', line 43

def warning_messages_for_incomplete_languages!(natural_language)
  if natural_language.incomplete?
    message = "\n Language Warning: Incomplete Keywords For The Language '#{language}' \n"
    Kernel.warn(message)
  end
end