rspec-i18n 0.1.0 → 0.2.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/Rakefile +20 -1
- data/TODO.txt +9 -7
- data/VERSION.yml +2 -2
- data/bin/rspec-i18n +15 -1
- data/examples/{person_spec.rb → i18n/pt/person_spec.rb} +2 -0
- data/lib/spec-i18n/command_line/language_help_formatter.rb +36 -0
- data/lib/spec-i18n/command_line/main.rb +27 -0
- data/lib/spec-i18n/command_line/options.rb +46 -0
- data/lib/spec-i18n/languages.yml +2 -2
- data/lib/spec-i18n/parser/natural_language.rb +25 -5
- data/lib/spec-i18n/platform.rb +5 -3
- data/lib/spec-i18n.rb +1 -0
- data/pkg/rspec-i18n-0.1.0.gem +0 -0
- data/rspec-i18n.gemspec +121 -0
- data/spec/spec-i18n/command_line/language_help_formatter_spec.rb +26 -0
- data/spec/spec-i18n/command_line/main_spec.rb +19 -0
- data/spec/spec-i18n/command_line/options_spec.rb +49 -0
- data/spec/spec-i18n/parser/natural_language_spec.rb +63 -1
- metadata +49 -6
data/Rakefile
CHANGED
@@ -1,22 +1,41 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'rubygems'
|
3
3
|
require 'rake'
|
4
|
+
require File.join("lib", "spec-i18n", "platform")
|
4
5
|
|
5
6
|
$:.unshift(File.dirname(__FILE__) + '/lib')
|
6
7
|
|
8
|
+
POST_MESSAGE = <<-POST_INSTALL_MESSAGE
|
9
|
+
|
10
|
+
#{ '-' * 80}
|
11
|
+
U P G R A D I N G
|
12
|
+
|
13
|
+
Thank you for installing rspec-i18n-#{SpecI18n::VERSION}
|
14
|
+
Please be sure to read http://wiki.github.com/tomas-stefano/rspec-i18n/upgrading
|
15
|
+
for important information about this release.
|
16
|
+
|
17
|
+
Remember: 'TDD is a muscle. You have to exercise it.' =) (Brian Liles)
|
18
|
+
|
19
|
+
#{ '-' * 80}
|
20
|
+
POST_INSTALL_MESSAGE
|
21
|
+
|
7
22
|
begin
|
8
23
|
require 'jeweler'
|
9
24
|
Jeweler::Tasks.new do |gemspec|
|
10
25
|
gemspec.name = "rspec-i18n"
|
11
26
|
gemspec.summary = "The internacionalization gem for Rspec"
|
12
|
-
gemspec.description = "A internacionalization tool written in Ruby"
|
27
|
+
gemspec.description = "A internacionalization tool written in Ruby for the Rspec Framework"
|
13
28
|
gemspec.email = "tomasdestefi@gmail.com"
|
14
29
|
gemspec.homepage = "http://github.com/tomas-stefano/rspec-i18n"
|
15
30
|
gemspec.authors = ["Tomas D'Stefano"]
|
16
31
|
|
17
32
|
gemspec.add_dependency('rspec', '>= 1.2.9')
|
33
|
+
gemspec.add_dependency('cucumber', '>= 0.5.3')
|
18
34
|
|
19
35
|
gemspec.add_development_dependency('rspec', '>= 1.2.9')
|
36
|
+
gemspec.add_development_dependency('cucumber', '>= 0.5.3')
|
37
|
+
|
38
|
+
gemspec.post_install_message = POST_MESSAGE
|
20
39
|
end
|
21
40
|
Jeweler::GemcutterTasks.new
|
22
41
|
rescue LoadError
|
data/TODO.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
== Refactoring
|
2
2
|
|
3
3
|
* The SpecI18n::Parser::NaturalLanguage.get(SpecI18n.spec_language) is duplicated in
|
4
|
-
some places - check a better way to implement this
|
4
|
+
some places - check a better way to implement this
|
5
5
|
* Simplified more and more tests!
|
6
6
|
* Find the right module for the example group specs(it/example) (I think =>
|
7
7
|
Spec::Example::ExampleGroupMethods but I think I was wrong)
|
@@ -9,6 +9,7 @@ some places - check a better way to implement this
|
|
9
9
|
== Future
|
10
10
|
|
11
11
|
* Translate all matchers
|
12
|
+
* * Making the spec-i18n executable(to see languages and other stuff)
|
12
13
|
* Translate subjects
|
13
14
|
* Translate shared examples
|
14
15
|
* Put a #language header in the spec_helper file (Cucumber Style) instead load from config(maintain the two options)
|
@@ -16,16 +17,17 @@ some places - check a better way to implement this
|
|
16
17
|
* Make the describe/it i18n available from a class
|
17
18
|
|
18
19
|
Example:
|
19
|
-
# class
|
20
|
-
#
|
20
|
+
# class PilhaSpec < Spec::ExampleGroup
|
21
|
+
# descreva Pilha, "sem nenhum elemento"
|
21
22
|
#
|
22
|
-
#
|
23
|
-
# @
|
23
|
+
# antes
|
24
|
+
# @pilha = Pilha.new
|
24
25
|
# end
|
25
26
|
#
|
26
|
-
#
|
27
|
-
# lambda{ @
|
27
|
+
# exemplo "deve lançar um erro no momento do pop" do
|
28
|
+
# lambda { @pilha.pop }.deve mostrar_erro
|
28
29
|
# end
|
30
|
+
#
|
29
31
|
# end
|
30
32
|
|
31
33
|
* Check a better way to manipulating the mocks and stubs for i18n (What do you think?)
|
data/VERSION.yml
CHANGED
data/bin/rspec-i18n
CHANGED
@@ -1,2 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
rspec_i18n_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
rspec_i18n_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
$:.unshift(rspec_i18n_dir) unless $:.include?(rspec_i18n_dir)
|
5
|
+
|
6
|
+
# The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
|
7
|
+
|
8
|
+
begin
|
9
|
+
SpecI18n::CommandLine::Main.execute(ARGV.dup)
|
10
|
+
rescue SystemExit => e
|
11
|
+
Kernel.exit(e.status)
|
12
|
+
rescue Exception => e
|
13
|
+
STDERR.puts("#{e.message} (#{e.class})")
|
14
|
+
STDERR.puts(e.backtrace.join("\n"))
|
15
|
+
Kernel.exit(1)
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'cucumber'
|
2
|
+
require 'cucumber/formatter/pretty'
|
3
|
+
require 'cucumber/formatter/unicode'
|
4
|
+
require 'cucumber/cli/language_help_formatter'
|
5
|
+
|
6
|
+
module SpecI18n
|
7
|
+
module CommandLine
|
8
|
+
class LanguageHelpFormatter
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Cucumber print table is loading
|
13
|
+
# because I don't want reiventing the wheel
|
14
|
+
#
|
15
|
+
def list_languages_and_exit(io)
|
16
|
+
raw = Parser::NaturalLanguage.list_languages
|
17
|
+
print_table io, raw, :check_lang => false
|
18
|
+
end
|
19
|
+
|
20
|
+
def list_keywords_and_exit(io, lang)
|
21
|
+
language = Parser::NaturalLanguage.get(lang)
|
22
|
+
raw = Parser::NaturalLanguage.list_keywords(lang)
|
23
|
+
print_table io, raw, :incomplete => language.incomplete?
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_table(io, raw, options)
|
27
|
+
table = Cucumber::Ast::Table.new(raw)
|
28
|
+
formatter = Cucumber::Cli::LanguageHelpFormatter.new(nil, io, options)
|
29
|
+
Cucumber::Ast::TreeWalker.new(nil, [formatter]).visit_multiline_arg(table)
|
30
|
+
Kernel.exit(0)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'cucumber/formatter/color_io'
|
2
|
+
require 'spec-i18n/command_line/options'
|
3
|
+
|
4
|
+
module SpecI18n
|
5
|
+
module CommandLine
|
6
|
+
class Main
|
7
|
+
def self.execute(args)
|
8
|
+
new(args).execute!
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(args, out_stream = STDOUT, error_stream = STDERR)
|
12
|
+
@args = args
|
13
|
+
if SpecI18n::WINDOWS
|
14
|
+
@out_stream = out_stream == STDOUT ? Formatter::ColorIO.new(Kernel, STDOUT) : out_stream
|
15
|
+
else
|
16
|
+
@out_stream = out_stream
|
17
|
+
end
|
18
|
+
@error_stream = error_stream
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute!
|
22
|
+
options = Options.new(@out_stream, @error_stream, @args)
|
23
|
+
options.parse!(@args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec-i18n/command_line/language_help_formatter'
|
2
|
+
|
3
|
+
module SpecI18n
|
4
|
+
module CommandLine
|
5
|
+
class Options
|
6
|
+
|
7
|
+
def initialize(output_stream = STDOUT, error_stream = STDERR, options = {})
|
8
|
+
@output_stream = output_stream
|
9
|
+
@error_stream = error_stream
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse!(args)
|
14
|
+
@args = args
|
15
|
+
@args.extend(::OptionParser::Arguable)
|
16
|
+
|
17
|
+
@args.options do |opts|
|
18
|
+
opts.banner = [ "Usage: rspec-i18n [options] [LANGUAGE]", "",
|
19
|
+
"Examples:",
|
20
|
+
"rspec-i18n --language help",
|
21
|
+
"rspec-i18n --language pt"].join("\n")
|
22
|
+
|
23
|
+
opts.on("-l LANGUAGE", "--language LANGUAGE",
|
24
|
+
"List keywords for a particular language",
|
25
|
+
%{Run with "--language help" to see all languages}) do |language|
|
26
|
+
if language == 'help'
|
27
|
+
LanguageHelpFormatter.list_languages_and_exit(@output_stream)
|
28
|
+
else
|
29
|
+
LanguageHelpFormatter.list_keywords_and_exit(language)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
opts.on_tail("-v", "--version", "Show version.") do
|
33
|
+
@output_stream.puts SpecI18n::VERSION
|
34
|
+
Kernel.exit(0)
|
35
|
+
end
|
36
|
+
opts.on_tail("-h", "--help", "You're looking at it.") do
|
37
|
+
@output_stream.puts opts.help
|
38
|
+
Kernel.exit(0)
|
39
|
+
end
|
40
|
+
end.parse!
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/spec-i18n/languages.yml
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
"en":
|
8
8
|
name: English
|
9
|
-
|
9
|
+
native: English
|
10
10
|
describe: describe
|
11
11
|
it: it|specify
|
12
12
|
should: should
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
"pt":
|
24
24
|
name: Portuguese
|
25
|
-
|
25
|
+
native: português
|
26
26
|
describe: descreva|contexto
|
27
27
|
it: exemplo|especificar
|
28
28
|
should: deve
|
@@ -1,16 +1,31 @@
|
|
1
1
|
module SpecI18n
|
2
2
|
module Parser
|
3
3
|
class NaturalLanguage
|
4
|
-
KEYWORDS_LANGUAGE = %w{ name native describe before after it should}
|
4
|
+
KEYWORDS_LANGUAGE = %w{ name native describe before after it should should_not}
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def get(language)
|
8
8
|
new(language)
|
9
9
|
end
|
10
|
-
|
11
|
-
def
|
12
|
-
SpecI18n::SPEC_LANGUAGES.keys.sort.map
|
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
|
13
27
|
end
|
28
|
+
|
14
29
|
end
|
15
30
|
|
16
31
|
attr_reader :keywords
|
@@ -18,7 +33,12 @@ module SpecI18n
|
|
18
33
|
def initialize(language)
|
19
34
|
@keywords = SpecI18n::SPEC_LANGUAGES[language]
|
20
35
|
raise(LanguageNotFound, "Language #{language} Not Supported") if @keywords.nil?
|
21
|
-
|
36
|
+
end
|
37
|
+
|
38
|
+
def incomplete?
|
39
|
+
language_words = KEYWORDS_LANGUAGE.collect { |key| keywords[key].nil? }
|
40
|
+
return false if language_words.include?(true)
|
41
|
+
true
|
22
42
|
end
|
23
43
|
|
24
44
|
def dsl_keywords
|
data/lib/spec-i18n/platform.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'rbconfig'
|
1
2
|
require 'yaml'
|
2
3
|
|
3
4
|
module SpecI18n
|
4
|
-
version
|
5
|
-
|
5
|
+
version = YAML.load_file(File.dirname(__FILE__) + '/../../VERSION.yml')
|
6
|
+
VERSION = [version[:major], version[:minor], version[:patch]].compact.join(".")
|
6
7
|
SPEC_LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/languages.yml')
|
7
|
-
SPEC_LANGUAGES
|
8
|
+
SPEC_LANGUAGES = YAML.load_file(SPEC_LANGUAGE_FILE)
|
9
|
+
WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
|
8
10
|
end
|
data/lib/spec-i18n.rb
CHANGED
Binary file
|
data/rspec-i18n.gemspec
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rspec-i18n}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tomas D'Stefano"]
|
12
|
+
s.date = %q{2010-01-05}
|
13
|
+
s.default_executable = %q{rspec-i18n}
|
14
|
+
s.description = %q{A internacionalization tool written in Ruby for the Rspec Framework}
|
15
|
+
s.email = %q{tomasdestefi@gmail.com}
|
16
|
+
s.executables = ["rspec-i18n"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"History.rdoc",
|
22
|
+
"License.txt",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"TODO.txt",
|
26
|
+
"VERSION.yml",
|
27
|
+
"bin/rspec-i18n",
|
28
|
+
"examples/i18n/pt/person_spec.rb",
|
29
|
+
"lib/spec-i18n.rb",
|
30
|
+
"lib/spec-i18n/command_line/language_help_formatter.rb",
|
31
|
+
"lib/spec-i18n/command_line/main.rb",
|
32
|
+
"lib/spec-i18n/command_line/options.rb",
|
33
|
+
"lib/spec-i18n/dsl.rb",
|
34
|
+
"lib/spec-i18n/dsl/main.rb",
|
35
|
+
"lib/spec-i18n/example.rb",
|
36
|
+
"lib/spec-i18n/example/before_and_after_hooks.rb",
|
37
|
+
"lib/spec-i18n/example/example_group_methods.rb",
|
38
|
+
"lib/spec-i18n/expectations.rb",
|
39
|
+
"lib/spec-i18n/expectations/extensions.rb",
|
40
|
+
"lib/spec-i18n/expectations/extensions/kernel.rb",
|
41
|
+
"lib/spec-i18n/languages.yml",
|
42
|
+
"lib/spec-i18n/parser.rb",
|
43
|
+
"lib/spec-i18n/parser/natural_language.rb",
|
44
|
+
"lib/spec-i18n/platform.rb",
|
45
|
+
"lib/spec-i18n/runner.rb",
|
46
|
+
"lib/spec-i18n/runner/configuration.rb",
|
47
|
+
"lib/spec-i18n/spec_language.rb",
|
48
|
+
"pkg/rspec-i18n-0.1.0.gem",
|
49
|
+
"rspec-i18n.gemspec",
|
50
|
+
"spec/spec-i18n/command_line/language_help_formatter_spec.rb",
|
51
|
+
"spec/spec-i18n/command_line/main_spec.rb",
|
52
|
+
"spec/spec-i18n/command_line/options_spec.rb",
|
53
|
+
"spec/spec-i18n/dsl/main_spec.rb",
|
54
|
+
"spec/spec-i18n/example/before_and_after_hooks_spec.rb",
|
55
|
+
"spec/spec-i18n/example/example_group_methods_spec.rb",
|
56
|
+
"spec/spec-i18n/example_spec.rb",
|
57
|
+
"spec/spec-i18n/expectations/kernel_spec.rb",
|
58
|
+
"spec/spec-i18n/parser/natural_language_spec.rb",
|
59
|
+
"spec/spec-i18n/runner/configuration_spec.rb",
|
60
|
+
"spec/spec-i18n/runner/runner_spec.rb",
|
61
|
+
"spec/spec-i18n/spec_language_spec.rb",
|
62
|
+
"spec/spec.opts",
|
63
|
+
"spec/spec_helper.rb"
|
64
|
+
]
|
65
|
+
s.homepage = %q{http://github.com/tomas-stefano/rspec-i18n}
|
66
|
+
s.post_install_message = %q{
|
67
|
+
--------------------------------------------------------------------------------
|
68
|
+
U P G R A D I N G
|
69
|
+
|
70
|
+
Thank you for installing rspec-i18n-0.2.0
|
71
|
+
Please be sure to read http://wiki.github.com/tomas-stefano/rspec-i18n/upgrading
|
72
|
+
for important information about this release.
|
73
|
+
|
74
|
+
Remember: 'TDD is a muscle. You have to exercise it.' =) (Brian Liles)
|
75
|
+
|
76
|
+
--------------------------------------------------------------------------------
|
77
|
+
}
|
78
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
79
|
+
s.require_paths = ["lib"]
|
80
|
+
s.rubygems_version = %q{1.3.5}
|
81
|
+
s.summary = %q{The internacionalization gem for Rspec}
|
82
|
+
s.test_files = [
|
83
|
+
"spec/spec-i18n/command_line/language_help_formatter_spec.rb",
|
84
|
+
"spec/spec-i18n/command_line/main_spec.rb",
|
85
|
+
"spec/spec-i18n/command_line/options_spec.rb",
|
86
|
+
"spec/spec-i18n/dsl/main_spec.rb",
|
87
|
+
"spec/spec-i18n/example/before_and_after_hooks_spec.rb",
|
88
|
+
"spec/spec-i18n/example/example_group_methods_spec.rb",
|
89
|
+
"spec/spec-i18n/example_spec.rb",
|
90
|
+
"spec/spec-i18n/expectations/kernel_spec.rb",
|
91
|
+
"spec/spec-i18n/parser/natural_language_spec.rb",
|
92
|
+
"spec/spec-i18n/runner/configuration_spec.rb",
|
93
|
+
"spec/spec-i18n/runner/runner_spec.rb",
|
94
|
+
"spec/spec-i18n/spec_language_spec.rb",
|
95
|
+
"spec/spec_helper.rb",
|
96
|
+
"examples/i18n/pt/person_spec.rb"
|
97
|
+
]
|
98
|
+
|
99
|
+
if s.respond_to? :specification_version then
|
100
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
101
|
+
s.specification_version = 3
|
102
|
+
|
103
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
104
|
+
s.add_runtime_dependency(%q<rspec>, [">= 1.2.9"])
|
105
|
+
s.add_runtime_dependency(%q<cucumber>, [">= 0.5.3"])
|
106
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
107
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
|
108
|
+
else
|
109
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
110
|
+
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
111
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
112
|
+
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
113
|
+
end
|
114
|
+
else
|
115
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
116
|
+
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
117
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
118
|
+
s.add_dependency(%q<cucumber>, [">= 0.5.3"])
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module SpecI18n
|
4
|
+
module CommandLine
|
5
|
+
describe LanguageHelpFormatter do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@languages = SpecI18n::Parser::NaturalLanguage.list_languages
|
9
|
+
@portuguese = SpecI18n::Parser::NaturalLanguage.list_keywords("pt")
|
10
|
+
@io_stream = StringIO.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should list languages" do
|
14
|
+
SpecI18n::Parser::NaturalLanguage.should_receive(:list_languages).and_return(@languages)
|
15
|
+
Kernel.should_receive(:exit)
|
16
|
+
LanguageHelpFormatter.list_languages_and_exit(StringIO.new)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should list keywords" do
|
20
|
+
SpecI18n::Parser::NaturalLanguage.should_receive(:list_keywords).and_return(@portuguese)
|
21
|
+
Kernel.should_receive(:exit)
|
22
|
+
LanguageHelpFormatter.list_keywords_and_exit(@io_stream, 'pt')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module SpecI18n
|
4
|
+
module CommandLine
|
5
|
+
describe Main do
|
6
|
+
|
7
|
+
it "should load the options" do
|
8
|
+
options = %w{--version}
|
9
|
+
|
10
|
+
Kernel.should_receive(:exit)
|
11
|
+
|
12
|
+
STDOUT.should_receive(:puts).and_return(nil)
|
13
|
+
|
14
|
+
Main.execute(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module SpecI18n
|
4
|
+
module CommandLine
|
5
|
+
describe Options do
|
6
|
+
describe 'parsing' do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@output_stream ||= StringIO.new
|
10
|
+
@error_stream ||= StringIO.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def options
|
14
|
+
@options ||= Options.new(@output_stream, @error_stream)
|
15
|
+
end
|
16
|
+
|
17
|
+
def when_parsing(args)
|
18
|
+
yield
|
19
|
+
options.parse!(args.is_a?(Array) ? args : args.split(' '))
|
20
|
+
end
|
21
|
+
|
22
|
+
context "--language" do
|
23
|
+
context "with LANG especified as help" do
|
24
|
+
|
25
|
+
it "should list all know languages" do
|
26
|
+
when_parsing "--language help" do
|
27
|
+
require 'spec-i18n/command_line/language_help_formatter'
|
28
|
+
LanguageHelpFormatter.should_receive(:list_languages_and_exit).with(@output_stream)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should list all know keywords for the language" do
|
33
|
+
when_parsing "--language pt" do
|
34
|
+
require 'spec-i18n/command_line/language_help_formatter'
|
35
|
+
LanguageHelpFormatter.should_receive(:list_keywords_and_exit).with("pt")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "exits the program" do
|
40
|
+
when_parsing('--language help') { Kernel.should_receive(:exit) }
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -24,8 +24,70 @@ module SpecI18n
|
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
27
|
+
|
28
|
+
context "imcomplete languages" do
|
29
|
+
|
30
|
+
it "should return true for the complete language" do
|
31
|
+
@pt.incomplete?.should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return false for the imcomplete language" do
|
35
|
+
@pt.stub!(:keywords).and_return({ :name => []})
|
36
|
+
@pt.incomplete?.should be_false
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context "list languages" do
|
42
|
+
|
43
|
+
before(:each) do
|
44
|
+
@portuguese = ["pt", "Portuguese", "português"]
|
45
|
+
@spanish = ["es", "Spanish", "español"]
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return the three keywords language for portuguese" do
|
49
|
+
SpecI18n::SPEC_LANGUAGES.should_receive(:keys).and_return("pt")
|
50
|
+
NaturalLanguage.list_languages.should == [@portuguese]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should return the three keywords for spanish" do
|
54
|
+
SpecI18n::SPEC_LANGUAGES.should_receive(:keys).and_return("es")
|
55
|
+
NaturalLanguage.list_languages.should == [@spanish]
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return the three keywords for spanish and portuguese" do
|
59
|
+
SpecI18n::SPEC_LANGUAGES.should_receive(:keys).and_return(["pt", "es"])
|
60
|
+
NaturalLanguage.list_languages.should == [@portuguese, @spanish].sort
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "list all keywords" do
|
65
|
+
|
66
|
+
before(:each) do
|
67
|
+
@portuguese = NaturalLanguage.get("pt")
|
68
|
+
end
|
69
|
+
|
70
|
+
# TODO: It's 3 a.m in the morning ... Ugly Specs ... #FIXME
|
71
|
+
|
72
|
+
it "should return the name keyword for the portuguese language" do
|
73
|
+
name = ["name", "Portuguese"]
|
74
|
+
NaturalLanguage.list_keywords("pt").first.should == name
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should return the example keyword for the portuguese language" do
|
78
|
+
keywords = NaturalLanguage.list_keywords('pt')
|
79
|
+
example = keywords.map { |array| array if array.include?("it") }.compact.flatten
|
80
|
+
example.should == ["it", "exemplo / especificar"]
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return all the keywords for the spanish language" do
|
84
|
+
native = ["native", "español"]
|
85
|
+
NaturalLanguage.list_keywords('es')[1].should == native
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
27
89
|
|
28
|
-
%w(describe before after it should).each do |keyword|
|
90
|
+
%w(describe before after it should name native).each do |keyword|
|
29
91
|
it "should have the #{keyword} keyword" do
|
30
92
|
@pt.keywords.keys.should be_include(keyword)
|
31
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas D'Stefano
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-05 00:00:00 -02:00
|
13
13
|
default_executable: rspec-i18n
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.2.9
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cucumber
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.3
|
34
|
+
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: rspec
|
27
37
|
type: :development
|
@@ -32,7 +42,17 @@ dependencies:
|
|
32
42
|
- !ruby/object:Gem::Version
|
33
43
|
version: 1.2.9
|
34
44
|
version:
|
35
|
-
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: cucumber
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.5.3
|
54
|
+
version:
|
55
|
+
description: A internacionalization tool written in Ruby for the Rspec Framework
|
36
56
|
email: tomasdestefi@gmail.com
|
37
57
|
executables:
|
38
58
|
- rspec-i18n
|
@@ -48,8 +68,11 @@ files:
|
|
48
68
|
- TODO.txt
|
49
69
|
- VERSION.yml
|
50
70
|
- bin/rspec-i18n
|
51
|
-
- examples/person_spec.rb
|
71
|
+
- examples/i18n/pt/person_spec.rb
|
52
72
|
- lib/spec-i18n.rb
|
73
|
+
- lib/spec-i18n/command_line/language_help_formatter.rb
|
74
|
+
- lib/spec-i18n/command_line/main.rb
|
75
|
+
- lib/spec-i18n/command_line/options.rb
|
53
76
|
- lib/spec-i18n/dsl.rb
|
54
77
|
- lib/spec-i18n/dsl/main.rb
|
55
78
|
- lib/spec-i18n/example.rb
|
@@ -65,6 +88,11 @@ files:
|
|
65
88
|
- lib/spec-i18n/runner.rb
|
66
89
|
- lib/spec-i18n/runner/configuration.rb
|
67
90
|
- lib/spec-i18n/spec_language.rb
|
91
|
+
- pkg/rspec-i18n-0.1.0.gem
|
92
|
+
- rspec-i18n.gemspec
|
93
|
+
- spec/spec-i18n/command_line/language_help_formatter_spec.rb
|
94
|
+
- spec/spec-i18n/command_line/main_spec.rb
|
95
|
+
- spec/spec-i18n/command_line/options_spec.rb
|
68
96
|
- spec/spec-i18n/dsl/main_spec.rb
|
69
97
|
- spec/spec-i18n/example/before_and_after_hooks_spec.rb
|
70
98
|
- spec/spec-i18n/example/example_group_methods_spec.rb
|
@@ -80,7 +108,19 @@ has_rdoc: true
|
|
80
108
|
homepage: http://github.com/tomas-stefano/rspec-i18n
|
81
109
|
licenses: []
|
82
110
|
|
83
|
-
post_install_message:
|
111
|
+
post_install_message: |
|
112
|
+
|
113
|
+
--------------------------------------------------------------------------------
|
114
|
+
U P G R A D I N G
|
115
|
+
|
116
|
+
Thank you for installing rspec-i18n-0.2.0
|
117
|
+
Please be sure to read http://wiki.github.com/tomas-stefano/rspec-i18n/upgrading
|
118
|
+
for important information about this release.
|
119
|
+
|
120
|
+
Remember: 'TDD is a muscle. You have to exercise it.' =) (Brian Liles)
|
121
|
+
|
122
|
+
--------------------------------------------------------------------------------
|
123
|
+
|
84
124
|
rdoc_options:
|
85
125
|
- --charset=UTF-8
|
86
126
|
require_paths:
|
@@ -105,6 +145,9 @@ signing_key:
|
|
105
145
|
specification_version: 3
|
106
146
|
summary: The internacionalization gem for Rspec
|
107
147
|
test_files:
|
148
|
+
- spec/spec-i18n/command_line/language_help_formatter_spec.rb
|
149
|
+
- spec/spec-i18n/command_line/main_spec.rb
|
150
|
+
- spec/spec-i18n/command_line/options_spec.rb
|
108
151
|
- spec/spec-i18n/dsl/main_spec.rb
|
109
152
|
- spec/spec-i18n/example/before_and_after_hooks_spec.rb
|
110
153
|
- spec/spec-i18n/example/example_group_methods_spec.rb
|
@@ -115,4 +158,4 @@ test_files:
|
|
115
158
|
- spec/spec-i18n/runner/runner_spec.rb
|
116
159
|
- spec/spec-i18n/spec_language_spec.rb
|
117
160
|
- spec/spec_helper.rb
|
118
|
-
- examples/person_spec.rb
|
161
|
+
- examples/i18n/pt/person_spec.rb
|