rspec-i18n 0.2.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +13 -0
- data/History.rdoc +17 -2
- data/License.txt +1 -1
- data/README.rdoc +17 -6
- data/Rakefile +6 -4
- data/TODO.txt +5 -5
- data/VERSION.yml +3 -3
- data/examples/i18n/pt/person_spec.rb +117 -12
- data/lib/spec-i18n/command_line/language_help_formatter.rb +67 -14
- data/lib/spec-i18n/command_line/options.rb +18 -17
- data/lib/spec-i18n/dsl/main.rb +1 -1
- data/lib/spec-i18n/example/before_and_after_hooks.rb +14 -9
- data/lib/spec-i18n/example/example_group_methods.rb +1 -1
- data/lib/spec-i18n/example/subject.rb +29 -0
- data/lib/spec-i18n/example.rb +2 -1
- data/lib/spec-i18n/expectations/extensions/kernel.rb +1 -1
- data/lib/spec-i18n/languages.yml +40 -3
- data/lib/spec-i18n/matchers/be.rb +19 -0
- data/lib/spec-i18n/matchers/method_missing.rb +25 -0
- data/lib/spec-i18n/matchers/register_all_matchers.rb +10 -0
- data/lib/spec-i18n/matchers/translate_basic_matchers.rb +28 -0
- data/lib/spec-i18n/matchers.rb +6 -0
- data/lib/spec-i18n/parser/natural_language.rb +19 -27
- data/lib/spec-i18n/runner/configuration.rb +3 -0
- data/lib/spec-i18n/spec_language.rb +3 -0
- data/lib/spec-i18n.rb +2 -1
- data/rspec-i18n.gemspec +57 -18
- data/spec/spec-i18n/command_line/language_help_formatter_spec.rb +73 -4
- data/spec/spec-i18n/dsl/main_spec.rb +1 -1
- data/spec/spec-i18n/example/subject_spec.rb +125 -0
- data/spec/spec-i18n/expectations/kernel_spec.rb +1 -0
- data/spec/spec-i18n/matchers/be_close_spec.rb +40 -0
- data/spec/spec-i18n/matchers/be_instance_of_spec.rb +32 -0
- data/spec/spec-i18n/matchers/be_kind_of_spec.rb +37 -0
- data/spec/spec-i18n/matchers/be_spec.rb +61 -0
- data/spec/spec-i18n/matchers/eql_spec.rb +33 -0
- data/spec/spec-i18n/matchers/equal_spec.rb +26 -0
- data/spec/spec-i18n/matchers/exist_spec.rb +45 -0
- data/spec/spec-i18n/matchers/have_spec.rb +61 -0
- data/spec/spec-i18n/matchers/include_spec.rb +34 -0
- data/spec/spec-i18n/matchers/match_spec.rb +36 -0
- data/spec/spec-i18n/matchers/raise_error_spec.rb +25 -0
- data/spec/spec-i18n/matchers/register_all_matchers_spec.rb +17 -0
- data/spec/spec-i18n/matchers/satisfy_spec.rb +28 -0
- data/spec/spec-i18n/parser/natural_language_spec.rb +42 -58
- data/spec/spec-i18n/spec_examples/pt/pessoa_spec.rb +153 -0
- data/spec/spec-i18n/spec_language_spec.rb +6 -0
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +44 -0
- metadata +66 -13
- data/pkg/rspec-i18n-0.1.0.gem +0 -0
- data/pkg/rspec-i18n-0.2.0.gem +0 -0
- data/spec/spec-i18n/example_spec.rb +0 -47
data/lib/spec-i18n/languages.yml
CHANGED
@@ -4,11 +4,14 @@
|
|
4
4
|
# If you want several aliases for a keyword, just a separate them
|
5
5
|
# with a | character. Make sure there are no ambiguities in the keywords
|
6
6
|
|
7
|
+
# The English language => Just for example
|
7
8
|
"en":
|
8
9
|
name: English
|
9
10
|
native: English
|
10
11
|
describe: describe
|
11
12
|
it: it|specify
|
13
|
+
its: exemplo_do_assunto # I don't know about this word
|
14
|
+
subject: subject
|
12
15
|
should: should
|
13
16
|
should_not: should_not
|
14
17
|
before: before
|
@@ -18,13 +21,29 @@
|
|
18
21
|
all: all
|
19
22
|
suite: suite
|
20
23
|
matchers:
|
21
|
-
|
24
|
+
be: be
|
25
|
+
be_a_kind_of: be_a_kind_of
|
26
|
+
be_close: be_close
|
27
|
+
be_an_instance_of: be_an_instance_of
|
28
|
+
eql: eql
|
29
|
+
equal: equal
|
30
|
+
exist: exist
|
31
|
+
have: have
|
32
|
+
have_exactly: have_exactly
|
33
|
+
have_at_least: have_at_least
|
34
|
+
have_at_most: have_at_most
|
35
|
+
include: include
|
36
|
+
match: match
|
37
|
+
raise_error: raise_exception
|
38
|
+
satisfy: satisfazer
|
22
39
|
|
23
40
|
"pt":
|
24
41
|
name: Portuguese
|
25
42
|
native: português
|
26
43
|
describe: descreva|contexto
|
27
44
|
it: exemplo|especificar
|
45
|
+
its: exemplo_do_assunto # I don't know about this word
|
46
|
+
subject: assunto
|
28
47
|
should: deve
|
29
48
|
should_not: nao_deve
|
30
49
|
before: antes
|
@@ -34,7 +53,21 @@
|
|
34
53
|
all: de_todos|de_todos_exemplos
|
35
54
|
suite: suite
|
36
55
|
matchers:
|
37
|
-
|
56
|
+
be: ser|estar
|
57
|
+
be_a_kind_of: ser_do_tipo
|
58
|
+
be_close: estar_perto|estar_proximo
|
59
|
+
be_an_instance_of: ser_instancia_de
|
60
|
+
eql: igl
|
61
|
+
equal: igual|igual_a
|
62
|
+
exist: existir
|
63
|
+
have: ter
|
64
|
+
have_exactly: ter_exatamente
|
65
|
+
have_at_least: ter_no_minimo
|
66
|
+
have_at_most: ter_no_maximo
|
67
|
+
include: incluir
|
68
|
+
match: corresponder
|
69
|
+
raise_error: mostrar_erro|mostrar_excessao
|
70
|
+
satisfy: satisfazer
|
38
71
|
|
39
72
|
# Please put the right words for this language! =D
|
40
73
|
"es":
|
@@ -42,6 +75,8 @@
|
|
42
75
|
native: español
|
43
76
|
describe: describir
|
44
77
|
it: ejemplo
|
78
|
+
its: ejemplo_asunto # I don't know about this word
|
79
|
+
subject: asunto|tema
|
45
80
|
should: deberia
|
46
81
|
should_not: no_debe
|
47
82
|
before: antes
|
@@ -51,4 +86,6 @@
|
|
51
86
|
all: de_todos_ejemplo
|
52
87
|
suite: suite
|
53
88
|
matchers:
|
54
|
-
|
89
|
+
be:
|
90
|
+
eql:
|
91
|
+
equal:
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spec
|
2
|
+
module Matchers
|
3
|
+
class Be #:nodoc:
|
4
|
+
class << self
|
5
|
+
def register_be_matcher
|
6
|
+
language = SpecI18n.natural_language
|
7
|
+
be_matcher = language.keywords['matchers']['be']
|
8
|
+
|
9
|
+
# TODO: working with warnings
|
10
|
+
return unless be_matcher
|
11
|
+
|
12
|
+
be_matcher.split('|').map do |be_value|
|
13
|
+
alias_method be_value, :be
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Spec
|
2
|
+
module Matchers
|
3
|
+
def method_missing(sym, *args, &block) # :nodoc:
|
4
|
+
|
5
|
+
begin
|
6
|
+
language = SpecI18n.natural_language
|
7
|
+
be_word = language.keywords['matchers']['be']
|
8
|
+
sym = be_to_english(sym, be_word)
|
9
|
+
end
|
10
|
+
|
11
|
+
return Matchers::BePredicate.new(sym, *args, &block) if sym.to_s =~ /^be_/
|
12
|
+
return Matchers::Has.new(sym, *args, &block) if sym.to_s =~ /^have_/
|
13
|
+
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
# :ser_matcher == :be_matcher
|
18
|
+
# :be_true == :be_true
|
19
|
+
def be_to_english(sym, be_word)
|
20
|
+
be_word = be_word || 'be'
|
21
|
+
|
22
|
+
sym.to_s.gsub(/#{be_word}/, 'be').to_sym
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Spec
|
2
|
+
module Matchers
|
3
|
+
class << self
|
4
|
+
|
5
|
+
RSPEC_MATCHERS = [ :be_close, :be_an_instance_of, :be_a_kind_of,
|
6
|
+
:eql, :equal, :exist, :have, :have_at_least,
|
7
|
+
:have_at_most, :have_exactly, :include, :match,
|
8
|
+
:raise_error, :satisfy ]
|
9
|
+
|
10
|
+
MATCHERS_WITH_QUESTIONS = [ :eql, :equal ]
|
11
|
+
|
12
|
+
def translate_basic_matchers
|
13
|
+
language = SpecI18n.natural_language
|
14
|
+
RSPEC_MATCHERS.each do |rspec_matcher|
|
15
|
+
matcher = language.keywords['matchers'][rspec_matcher.to_s]
|
16
|
+
|
17
|
+
# TODO: Generating warnings for the incomplete languages
|
18
|
+
next unless matcher
|
19
|
+
|
20
|
+
matcher.split('|').map do |matcher_value|
|
21
|
+
alias_method "#{matcher_value}?", "#{rspec_matcher}?" if MATCHERS_WITH_QUESTIONS.include?(rspec_matcher)
|
22
|
+
alias_method matcher_value, rspec_matcher
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,44 +1,28 @@
|
|
1
1
|
module SpecI18n
|
2
2
|
module Parser
|
3
3
|
class NaturalLanguage
|
4
|
-
|
5
|
-
|
4
|
+
BASIC_KEYWORDS = %w{ name native describe before after it
|
5
|
+
subject its should should_not}
|
6
|
+
|
7
|
+
ADVANCED_KEYWORDS = %w{ hooks matchers}
|
8
|
+
|
6
9
|
class << self
|
7
10
|
def get(language)
|
8
11
|
new(language)
|
9
|
-
end
|
10
|
-
|
11
|
-
def list_languages
|
12
|
-
SpecI18n::SPEC_LANGUAGES.keys.sort.map do |lang|
|
13
|
-
[
|
14
|
-
lang,
|
15
|
-
SpecI18n::SPEC_LANGUAGES[lang]['name'],
|
16
|
-
SpecI18n::SPEC_LANGUAGES[lang]['native']
|
17
|
-
]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def list_keywords(language)
|
22
|
-
language = NaturalLanguage.get(language)
|
23
|
-
|
24
|
-
NaturalLanguage::KEYWORDS_LANGUAGE.map do |key|
|
25
|
-
[key, language.spec_keywords(key)[key].join(" / ")]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
12
|
+
end
|
29
13
|
end
|
30
14
|
|
31
15
|
attr_reader :keywords
|
32
16
|
|
33
17
|
def initialize(language)
|
34
18
|
@keywords = SpecI18n::SPEC_LANGUAGES[language]
|
35
|
-
raise(LanguageNotFound, "Language #{language} Not Supported") if @keywords.nil?
|
19
|
+
raise(LanguageNotFound, "Language #{language.to_s} Not Supported") if @keywords.nil?
|
36
20
|
end
|
37
21
|
|
38
22
|
def incomplete?
|
39
|
-
language_words =
|
40
|
-
return
|
41
|
-
|
23
|
+
language_words = BASIC_KEYWORDS.collect { |key| keywords[key].nil? }
|
24
|
+
return true if language_words.include?(true)
|
25
|
+
false
|
42
26
|
end
|
43
27
|
|
44
28
|
def dsl_keywords
|
@@ -68,6 +52,14 @@ module SpecI18n
|
|
68
52
|
spec_keywords("it")
|
69
53
|
end
|
70
54
|
|
55
|
+
def subject_keywords
|
56
|
+
adverbs = spec_keywords('subject')
|
57
|
+
end
|
58
|
+
|
59
|
+
def its_keywords
|
60
|
+
spec_keywords("its")
|
61
|
+
end
|
62
|
+
|
71
63
|
def spec_keywords(key, space=false)
|
72
64
|
raise "No #{key} in #{@keywords.inspect}" if @keywords[key].nil?
|
73
65
|
values = keywords[key].split('|')
|
@@ -80,4 +72,4 @@ module SpecI18n
|
|
80
72
|
end
|
81
73
|
|
82
74
|
end
|
83
|
-
end
|
75
|
+
end
|
@@ -17,6 +17,9 @@ module Spec
|
|
17
17
|
Kernel.register_expectations_keywords
|
18
18
|
Spec::Example::ExampleGroupMethods.register_example_adverbs
|
19
19
|
Spec::Example::BeforeAndAfterHooks.register_hooks
|
20
|
+
Spec::Matchers.register_all_matchers
|
21
|
+
Spec::Example::Subject::ExampleGroupMethods.register_subjects
|
22
|
+
Spec::Example::Subject::ExampleMethods.register_subjects
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
data/lib/spec-i18n.rb
CHANGED
@@ -3,8 +3,9 @@ require 'yaml'
|
|
3
3
|
require 'spec'
|
4
4
|
require 'spec-i18n/platform'
|
5
5
|
require 'spec-i18n/runner'
|
6
|
-
require 'spec-i18n/spec_language'
|
7
6
|
require 'spec-i18n/parser'
|
7
|
+
require 'spec-i18n/spec_language'
|
8
|
+
require 'spec-i18n/matchers'
|
8
9
|
require 'spec-i18n/example'
|
9
10
|
require 'spec-i18n/expectations'
|
10
11
|
require 'spec-i18n/dsl'
|
data/rspec-i18n.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-i18n}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tomas D'Stefano"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-19}
|
13
13
|
s.default_executable = %q{rspec-i18n}
|
14
14
|
s.description = %q{A internacionalization tool written in Ruby for the Rspec Framework}
|
15
15
|
s.email = %q{tomasdestefi@gmail.com}
|
@@ -18,7 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
"README.rdoc"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
|
-
"
|
21
|
+
".gitignore",
|
22
|
+
"History.rdoc",
|
22
23
|
"License.txt",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
@@ -35,18 +36,22 @@ Gem::Specification.new do |s|
|
|
35
36
|
"lib/spec-i18n/example.rb",
|
36
37
|
"lib/spec-i18n/example/before_and_after_hooks.rb",
|
37
38
|
"lib/spec-i18n/example/example_group_methods.rb",
|
39
|
+
"lib/spec-i18n/example/subject.rb",
|
38
40
|
"lib/spec-i18n/expectations.rb",
|
39
41
|
"lib/spec-i18n/expectations/extensions.rb",
|
40
42
|
"lib/spec-i18n/expectations/extensions/kernel.rb",
|
41
43
|
"lib/spec-i18n/languages.yml",
|
44
|
+
"lib/spec-i18n/matchers.rb",
|
45
|
+
"lib/spec-i18n/matchers/be.rb",
|
46
|
+
"lib/spec-i18n/matchers/method_missing.rb",
|
47
|
+
"lib/spec-i18n/matchers/register_all_matchers.rb",
|
48
|
+
"lib/spec-i18n/matchers/translate_basic_matchers.rb",
|
42
49
|
"lib/spec-i18n/parser.rb",
|
43
50
|
"lib/spec-i18n/parser/natural_language.rb",
|
44
51
|
"lib/spec-i18n/platform.rb",
|
45
52
|
"lib/spec-i18n/runner.rb",
|
46
53
|
"lib/spec-i18n/runner/configuration.rb",
|
47
54
|
"lib/spec-i18n/spec_language.rb",
|
48
|
-
"pkg/rspec-i18n-0.1.0.gem",
|
49
|
-
"pkg/rspec-i18n-0.2.0.gem",
|
50
55
|
"rspec-i18n.gemspec",
|
51
56
|
"spec/spec-i18n/command_line/language_help_formatter_spec.rb",
|
52
57
|
"spec/spec-i18n/command_line/main_spec.rb",
|
@@ -54,11 +59,25 @@ Gem::Specification.new do |s|
|
|
54
59
|
"spec/spec-i18n/dsl/main_spec.rb",
|
55
60
|
"spec/spec-i18n/example/before_and_after_hooks_spec.rb",
|
56
61
|
"spec/spec-i18n/example/example_group_methods_spec.rb",
|
57
|
-
"spec/spec-i18n/
|
62
|
+
"spec/spec-i18n/example/subject_spec.rb",
|
58
63
|
"spec/spec-i18n/expectations/kernel_spec.rb",
|
64
|
+
"spec/spec-i18n/matchers/be_close_spec.rb",
|
65
|
+
"spec/spec-i18n/matchers/be_instance_of_spec.rb",
|
66
|
+
"spec/spec-i18n/matchers/be_kind_of_spec.rb",
|
67
|
+
"spec/spec-i18n/matchers/be_spec.rb",
|
68
|
+
"spec/spec-i18n/matchers/eql_spec.rb",
|
69
|
+
"spec/spec-i18n/matchers/equal_spec.rb",
|
70
|
+
"spec/spec-i18n/matchers/exist_spec.rb",
|
71
|
+
"spec/spec-i18n/matchers/have_spec.rb",
|
72
|
+
"spec/spec-i18n/matchers/include_spec.rb",
|
73
|
+
"spec/spec-i18n/matchers/match_spec.rb",
|
74
|
+
"spec/spec-i18n/matchers/raise_error_spec.rb",
|
75
|
+
"spec/spec-i18n/matchers/register_all_matchers_spec.rb",
|
76
|
+
"spec/spec-i18n/matchers/satisfy_spec.rb",
|
59
77
|
"spec/spec-i18n/parser/natural_language_spec.rb",
|
60
78
|
"spec/spec-i18n/runner/configuration_spec.rb",
|
61
79
|
"spec/spec-i18n/runner/runner_spec.rb",
|
80
|
+
"spec/spec-i18n/spec_examples/pt/pessoa_spec.rb",
|
62
81
|
"spec/spec-i18n/spec_language_spec.rb",
|
63
82
|
"spec/spec.opts",
|
64
83
|
"spec/spec_helper.rb"
|
@@ -68,9 +87,9 @@ Gem::Specification.new do |s|
|
|
68
87
|
--------------------------------------------------------------------------------
|
69
88
|
U P G R A D I N G
|
70
89
|
|
71
|
-
Thank you for installing rspec-i18n-0.
|
90
|
+
Thank you for installing rspec-i18n-1.0.0
|
72
91
|
Please be sure to read http://wiki.github.com/tomas-stefano/rspec-i18n/upgrading
|
73
|
-
for
|
92
|
+
for information about this release.
|
74
93
|
|
75
94
|
Remember: 'TDD is a muscle. You have to exercise it.' =) (Brian Liles)
|
76
95
|
|
@@ -87,11 +106,25 @@ Remember: 'TDD is a muscle. You have to exercise it.' =) (Brian Liles)
|
|
87
106
|
"spec/spec-i18n/dsl/main_spec.rb",
|
88
107
|
"spec/spec-i18n/example/before_and_after_hooks_spec.rb",
|
89
108
|
"spec/spec-i18n/example/example_group_methods_spec.rb",
|
90
|
-
"spec/spec-i18n/
|
109
|
+
"spec/spec-i18n/example/subject_spec.rb",
|
91
110
|
"spec/spec-i18n/expectations/kernel_spec.rb",
|
111
|
+
"spec/spec-i18n/matchers/be_close_spec.rb",
|
112
|
+
"spec/spec-i18n/matchers/be_instance_of_spec.rb",
|
113
|
+
"spec/spec-i18n/matchers/be_kind_of_spec.rb",
|
114
|
+
"spec/spec-i18n/matchers/be_spec.rb",
|
115
|
+
"spec/spec-i18n/matchers/eql_spec.rb",
|
116
|
+
"spec/spec-i18n/matchers/equal_spec.rb",
|
117
|
+
"spec/spec-i18n/matchers/exist_spec.rb",
|
118
|
+
"spec/spec-i18n/matchers/have_spec.rb",
|
119
|
+
"spec/spec-i18n/matchers/include_spec.rb",
|
120
|
+
"spec/spec-i18n/matchers/match_spec.rb",
|
121
|
+
"spec/spec-i18n/matchers/raise_error_spec.rb",
|
122
|
+
"spec/spec-i18n/matchers/register_all_matchers_spec.rb",
|
123
|
+
"spec/spec-i18n/matchers/satisfy_spec.rb",
|
92
124
|
"spec/spec-i18n/parser/natural_language_spec.rb",
|
93
125
|
"spec/spec-i18n/runner/configuration_spec.rb",
|
94
126
|
"spec/spec-i18n/runner/runner_spec.rb",
|
127
|
+
"spec/spec-i18n/spec_examples/pt/pessoa_spec.rb",
|
95
128
|
"spec/spec-i18n/spec_language_spec.rb",
|
96
129
|
"spec/spec_helper.rb",
|
97
130
|
"examples/i18n/pt/person_spec.rb"
|
@@ -102,21 +135,27 @@ Remember: 'TDD is a muscle. You have to exercise it.' =) (Brian Liles)
|
|
102
135
|
s.specification_version = 3
|
103
136
|
|
104
137
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
105
|
-
s.add_runtime_dependency(%q<rspec>, [">= 1.
|
106
|
-
s.add_runtime_dependency(%q<
|
138
|
+
s.add_runtime_dependency(%q<rspec>, [">= 1.3.0"])
|
139
|
+
s.add_runtime_dependency(%q<terminal-table>, [">= 1.4.2"])
|
140
|
+
s.add_runtime_dependency(%q<term-ansicolor>, ["= 1.0.4"])
|
107
141
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
108
|
-
s.add_development_dependency(%q<
|
142
|
+
s.add_development_dependency(%q<terminal-table>, [">= 1.4.2"])
|
143
|
+
s.add_development_dependency(%q<term-ansicolor>, ["= 1.0.4"])
|
109
144
|
else
|
145
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
146
|
+
s.add_dependency(%q<terminal-table>, [">= 1.4.2"])
|
147
|
+
s.add_dependency(%q<term-ansicolor>, ["= 1.0.4"])
|
110
148
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
111
|
-
s.add_dependency(%q<
|
112
|
-
s.add_dependency(%q<
|
113
|
-
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
149
|
+
s.add_dependency(%q<terminal-table>, [">= 1.4.2"])
|
150
|
+
s.add_dependency(%q<term-ansicolor>, ["= 1.0.4"])
|
114
151
|
end
|
115
152
|
else
|
153
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
154
|
+
s.add_dependency(%q<terminal-table>, [">= 1.4.2"])
|
155
|
+
s.add_dependency(%q<term-ansicolor>, ["= 1.0.4"])
|
116
156
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
117
|
-
s.add_dependency(%q<
|
118
|
-
s.add_dependency(%q<
|
119
|
-
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
157
|
+
s.add_dependency(%q<terminal-table>, [">= 1.4.2"])
|
158
|
+
s.add_dependency(%q<term-ansicolor>, ["= 1.0.4"])
|
120
159
|
end
|
121
160
|
end
|
122
161
|
|
@@ -5,22 +5,91 @@ module SpecI18n
|
|
5
5
|
describe LanguageHelpFormatter do
|
6
6
|
|
7
7
|
before(:all) do
|
8
|
-
@
|
9
|
-
@
|
8
|
+
@pt = SpecI18n::Parser::NaturalLanguage.get('pt')
|
9
|
+
@languages = LanguageHelpFormatter.list_languages
|
10
|
+
@portuguese = LanguageHelpFormatter.list_basic_keywords(@pt)
|
10
11
|
@io_stream = StringIO.new
|
11
12
|
end
|
12
13
|
|
13
14
|
it "should list languages" do
|
14
|
-
|
15
|
+
LanguageHelpFormatter.should_receive(:list_languages).and_return(@languages)
|
15
16
|
Kernel.should_receive(:exit)
|
16
17
|
LanguageHelpFormatter.list_languages_and_exit(StringIO.new)
|
17
18
|
end
|
18
19
|
|
19
20
|
it "should list keywords" do
|
20
|
-
|
21
|
+
LanguageHelpFormatter.should_receive(:list_basic_keywords).and_return(@portuguese)
|
21
22
|
Kernel.should_receive(:exit)
|
22
23
|
LanguageHelpFormatter.list_keywords_and_exit(@io_stream, 'pt')
|
23
24
|
end
|
25
|
+
|
26
|
+
context "list languages" do
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
@portuguese = ["pt", "Portuguese", "português"]
|
30
|
+
@spanish = ["es", "Spanish", "español"]
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return the three keywords language for portuguese" do
|
34
|
+
SpecI18n::SPEC_LANGUAGES.should_receive(:keys).and_return("pt")
|
35
|
+
LanguageHelpFormatter.list_languages.should == [@portuguese]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return the three keywords for spanish" do
|
39
|
+
SpecI18n::SPEC_LANGUAGES.should_receive(:keys).and_return("es")
|
40
|
+
LanguageHelpFormatter.list_languages.should == [@spanish]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return the three keywords for spanish and portuguese" do
|
44
|
+
SpecI18n::SPEC_LANGUAGES.should_receive(:keys).and_return(["pt", "es"])
|
45
|
+
LanguageHelpFormatter.list_languages.should == [@portuguese, @spanish].sort
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "list all keywords" do
|
50
|
+
|
51
|
+
before(:each) do
|
52
|
+
@language_keywords = LanguageHelpFormatter.list_basic_keywords(@pt)
|
53
|
+
end
|
54
|
+
|
55
|
+
# TODO: It's 3 a.m in the morning ... Ugly Specs ... #FIXME
|
56
|
+
|
57
|
+
it "should return all basic keywords for a language" do
|
58
|
+
words = %w(name native describe before after it should should_not)
|
59
|
+
words.each do |word|
|
60
|
+
@language_keywords.flatten.should include(word)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return the example keyword for the portuguese language" do
|
65
|
+
example = @language_keywords.map { |array| array if array.include?("it") }.compact.flatten
|
66
|
+
example.should == ["it", "exemplo / especificar"]
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'the advanced keywords' do
|
70
|
+
|
71
|
+
before(:each) do
|
72
|
+
@out = StringIO.new
|
73
|
+
@keywords = LanguageHelpFormatter.list_advanced_keywords(@out, @pt)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return the matchers keywords for language" do
|
77
|
+
@keywords.last.headings.should include('matchers')
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return the hooks keywords for language" do
|
81
|
+
@keywords.first.headings.should include('hooks')
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return some keywords for a empty language" do
|
85
|
+
@es = SpecI18n::Parser::NaturalLanguage.get('es')
|
86
|
+
@keywords = LanguageHelpFormatter.list_advanced_keywords(@out, @es)
|
87
|
+
@keywords.first.headings.should include('hooks')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
24
93
|
end
|
25
94
|
end
|
26
95
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Example
|
5
|
+
describe "implicit subject" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@pt = portuguese_language({'subject' => 'assunto', 'should' => 'deve',
|
9
|
+
'should_not' => 'nao_deve','matchers' => {}})
|
10
|
+
Subject::ExampleMethods.register_subjects
|
11
|
+
@es = spanish_language({'subject' => 'asunto', 'should' => 'deve',
|
12
|
+
'should_not' => 'nao_deve', 'matchers' => {}})
|
13
|
+
Subject::ExampleMethods.register_subjects
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have the subject translated' do
|
17
|
+
values = @pt['subject'].split('|')
|
18
|
+
values << @es['subject'].split('|')
|
19
|
+
values.flatten.each do |value_method|
|
20
|
+
Subject::ExampleMethods.instance_methods.should be_include(value_method)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have the should and should_not method trasnlated" do
|
25
|
+
values = @pt['should'].split('|')
|
26
|
+
other_values = @pt['should_not'].split('|')
|
27
|
+
values << other_values
|
28
|
+
values.flatten.each do |value_method|
|
29
|
+
Subject::ExampleMethods.instance_methods.should be_include(value_method)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "with a class" do
|
34
|
+
it "returns an instance of the class" do
|
35
|
+
group = Class.new(ExampleGroupDouble).describe(Array)
|
36
|
+
example = group.new(ExampleProxy.new)
|
37
|
+
example.assunto.should == []
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "with a Module" do
|
42
|
+
it "returns the Module" do
|
43
|
+
group = Class.new(ExampleGroupDouble).describe(Enumerable)
|
44
|
+
example = group.new(ExampleProxy.new)
|
45
|
+
example.assunto.should == Enumerable
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "explicit subject" do
|
51
|
+
describe "defined in a top level group" do
|
52
|
+
it "replaces the implicit subject in that group" do
|
53
|
+
group = Class.new(ExampleGroupDouble).describe(Array)
|
54
|
+
group.subject { [1,2,3] }
|
55
|
+
example = group.new(ExampleProxy.new)
|
56
|
+
example.asunto.should == [1,2,3]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'defined in a top level group' do
|
62
|
+
|
63
|
+
before(:each) do
|
64
|
+
@group = Class.new do
|
65
|
+
extend Spec::Example::Subject::ExampleGroupMethods
|
66
|
+
include Spec::Example::Subject::ExampleMethods
|
67
|
+
class << self
|
68
|
+
def described_class
|
69
|
+
Array
|
70
|
+
end
|
71
|
+
end
|
72
|
+
def described_class
|
73
|
+
self.class.described_class
|
74
|
+
end
|
75
|
+
|
76
|
+
subject {
|
77
|
+
[1,2,3]
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "is available in a nested group (subclass)" do
|
83
|
+
nested_group = Class.new(@group)
|
84
|
+
|
85
|
+
example = nested_group.new
|
86
|
+
example.assunto.should == [1,2,3]
|
87
|
+
end
|
88
|
+
|
89
|
+
it "is available in a doubly nested group (subclass)" do
|
90
|
+
nested_group = Class.new(@group)
|
91
|
+
doubly_nested_group = Class.new(nested_group)
|
92
|
+
|
93
|
+
example = doubly_nested_group.new
|
94
|
+
example.subject.should == [1,2,3]
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
describe ".its (to access subject's attributes)" do
|
100
|
+
|
101
|
+
before(:each) do
|
102
|
+
@its_examples = {'subject' => 'assunto', 'its' => 'exemplos', 'matchers' => {}}
|
103
|
+
@pt = portuguese_language(@its_examples)
|
104
|
+
Subject::ExampleGroupMethods.register_subjects
|
105
|
+
@es = spanish_language({'subject' => 'assunto', 'its' => 'ejemplos', 'matchers' => {}})
|
106
|
+
Subject::ExampleGroupMethods.register_subjects
|
107
|
+
end
|
108
|
+
|
109
|
+
with_sandboxed_options do
|
110
|
+
it "passes when expectation should pass" do
|
111
|
+
group = Class.new(ExampleGroupDouble).describe(Array)
|
112
|
+
child = group.exemplos(:length) { should == 0 }
|
113
|
+
child.run(options).should == true
|
114
|
+
end
|
115
|
+
|
116
|
+
it "fails when expectation should fail" do
|
117
|
+
group = Class.new(ExampleGroupDouble).describe(Array)
|
118
|
+
child = group.ejemplos(:length) { should == 1 }
|
119
|
+
child.run(options).should == false
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
@@ -10,6 +10,7 @@ describe Object, "#should and #should_not" do
|
|
10
10
|
@languages.each do |language|
|
11
11
|
Spec::Runner.configuration.spec_language(language)
|
12
12
|
language = SpecI18n::Parser::NaturalLanguage.get(language)
|
13
|
+
|
13
14
|
language.expectation_keywords.values.flatten.each do |keyword|
|
14
15
|
Kernel.methods.should be_include(keyword)
|
15
16
|
end
|