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
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Matchers
|
5
|
+
describe "[actual.should] be_close(expected, delta)" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@expected_matcher = {'matchers' => { 'be_close' => 'estar_perto'} }
|
9
|
+
portuguese_language(@expected_matcher)
|
10
|
+
Spec::Matchers.register_all_matchers
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should register the be_close matcher" do
|
14
|
+
values = @expected_matcher['matchers']['be_close'].split('|')
|
15
|
+
values.each do |value_method|
|
16
|
+
Object.instance_methods.should be_include(value_method)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "matches when actual == expected" do
|
21
|
+
estar_perto(5.0, 0.5).matches?(5.0).should be_true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "matches when actual < (expected + delta)" do
|
25
|
+
estar_perto(5.0, 0.5).matches?(5.49).should be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "does not match when actual == (expected - delta)" do
|
29
|
+
estar_perto(5.0, 0.5).matches?(4.5).should be_false
|
30
|
+
end
|
31
|
+
it "does not match when actual < (expected - delta)" do
|
32
|
+
estar_perto(5.0, 0.5).matches?(4.49).should be_false
|
33
|
+
end
|
34
|
+
it "does not match when actual == (expected + delta)" do
|
35
|
+
estar_perto(5.0, 0.5).matches?(5.5).should be_false
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Matchers
|
5
|
+
describe 'the be_instance_of method' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@expected_matcher = { 'matchers' => { 'be_an_instance_of' => 'ser_instancia_de'} }
|
9
|
+
portuguese_language(@expected_matcher)
|
10
|
+
Spec::Matchers.register_all_matchers
|
11
|
+
end
|
12
|
+
|
13
|
+
it "register the be_an_instance_of method" do
|
14
|
+
values = @expected_matcher['matchers']['be_an_instance_of'].split('|')
|
15
|
+
values.each do |value_method|
|
16
|
+
Object.instance_methods.should be_include(value_method)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "passes if actual is instance of expected class" do
|
21
|
+
5.should send(:ser_instancia_de, Fixnum)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "fails if actual is instance of subclass of expected class" do
|
25
|
+
lambda {
|
26
|
+
5.should send(:ser_instancia_de, Numeric)
|
27
|
+
}.should raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Matchers
|
5
|
+
describe 'the be_kind_of method' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@expected_matcher = { 'matchers' => { 'be_a_kind_of' => 'ser_do_tipo'} }
|
9
|
+
portuguese_language(@expected_matcher)
|
10
|
+
Spec::Matchers.register_all_matchers
|
11
|
+
end
|
12
|
+
|
13
|
+
it "register the be_an_instance_of method" do
|
14
|
+
values = @expected_matcher['matchers']['be_a_kind_of'].split('|')
|
15
|
+
values.each do |value_method|
|
16
|
+
Object.instance_methods.should be_include(value_method)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "passes if actual is instance of expected class" do
|
21
|
+
5.should send(:ser_do_tipo, Fixnum)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "passes if actual is instance of subclass of expected class" do
|
25
|
+
5.should send(:ser_do_tipo, Numeric)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "fails with failure message for should unless actual is kind of expected class" do
|
29
|
+
lambda {
|
30
|
+
"foo".should send(:ser_do_tipo, Array)
|
31
|
+
}.should raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "should be_predicate" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
portuguese_language({"matchers" => {"be" => "ser"}})
|
7
|
+
Spec::Matchers.register_all_matchers
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should pass with be language translated" do
|
11
|
+
atual = stub("atual", :feliz? => true)
|
12
|
+
atual.should ser_feliz
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should fail when actual returns false for :predicate?" do
|
16
|
+
|
17
|
+
|
18
|
+
pending('verify rspec 1.3')
|
19
|
+
|
20
|
+
atual = stub("atual", :feliz? => false)
|
21
|
+
lambda {
|
22
|
+
atual.should be_feliz
|
23
|
+
}.should fail_with("expected feliz? to return true, got false")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should fail when actual returns false for :predicate?" do
|
27
|
+
|
28
|
+
pending('verify rspec 1.3')
|
29
|
+
|
30
|
+
atual = stub("atual", :feliz? => nil)
|
31
|
+
lambda {
|
32
|
+
atual.should be_feliz
|
33
|
+
}.should fail_with("expected feliz? to return true, got nil")
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should be true for the new :predicate' do
|
37
|
+
atual = true
|
38
|
+
pending("SHOULD translate true, false, nil, empty for the default MATCHERS")
|
39
|
+
atual.should ser_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should convert be word to english with two parameters' do
|
43
|
+
be_to_english(:ser_feliz, 'ser|estar').should == :be_feliz
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should convert be word to english" do
|
47
|
+
be_to_english(:ser_feliz, :ser).should == :be_feliz
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should keep the same word in english(don't break the rspec defaults)" do
|
51
|
+
be_to_english(:be_include, :be).should == :be_include
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should keep the same word for the non existing word" do
|
55
|
+
be_to_english(:be_include, :ser).should == :be_include
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should keep the same word for the nil be word" do
|
59
|
+
be_to_english(:be_include, nil).should == :be_include
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Matchers
|
5
|
+
describe "eql" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@expected_matcher = {'matchers' => {'eql' => 'igl'}}
|
9
|
+
portuguese_language(@expected_matcher)
|
10
|
+
Spec::Matchers.register_all_matchers
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have eql matchers translated" do
|
14
|
+
eql_word = @expected_matcher['matchers']['eql']
|
15
|
+
1.methods.should be_include(eql_word)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have eql? matchers translated" do
|
19
|
+
eql_word = @expected_matcher['matchers']['eql'] + '?'
|
20
|
+
1.methods.should be_include(eql_word)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should match when actual.eql?(expected)" do
|
24
|
+
1.should igl(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not match when !actual.eql?(expected)" do
|
28
|
+
1.should_not igl(2)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Matchers
|
5
|
+
describe 'equal' do
|
6
|
+
before(:each) do
|
7
|
+
@expected_matcher = {'matchers' => {'equal' => 'igual|igual_a'}}
|
8
|
+
portuguese_language(@expected_matcher)
|
9
|
+
Spec::Matchers.register_all_matchers
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should register the methods for the value equal matcher' do
|
13
|
+
values = @expected_matcher['matchers']['equal'].split('|')
|
14
|
+
values.each { |method_name| Object.instance_methods.should be_include(method_name) }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should match when actual.equal?(expected)" do
|
18
|
+
1.should igual(1)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not match when !actual.equal?(expected)" do
|
22
|
+
1.should_not igual_a("1")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# The same class in rspec specs file
|
4
|
+
class Substance
|
5
|
+
def initialize exists, description
|
6
|
+
@exists = exists
|
7
|
+
@description = description
|
8
|
+
end
|
9
|
+
def exist?(arg=nil)
|
10
|
+
@exists
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Spec
|
15
|
+
module Matchers
|
16
|
+
|
17
|
+
describe "exist matcher" do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@expected_matcher = {'matchers' => {'exist' => 'existir'}}
|
21
|
+
portuguese_language(@expected_matcher)
|
22
|
+
Spec::Matchers.register_all_matchers
|
23
|
+
@real = Substance.new true, 'something real'
|
24
|
+
@imaginary = Substance.new false, 'something imaginary'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should register the exist method translated' do
|
28
|
+
values = @expected_matcher['matchers']['exist'].split('|')
|
29
|
+
values.each do |value_method|
|
30
|
+
Object.instance_methods.should be_include(value_method)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "passes if target exists" do
|
35
|
+
@real.should existir
|
36
|
+
end
|
37
|
+
|
38
|
+
it "fails if target does not exist" do
|
39
|
+
lambda { @imaginary.should exist }.should raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'have, have_exactly, have_at_least and have_at_most matcher' do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
matchers = {'have' => 'ter', 'have_at_least' => 'ter_no_minimo',
|
7
|
+
'have_exactly' => 'ter_exatamente',
|
8
|
+
'have_at_most' => 'ter_no_maximo'}
|
9
|
+
@expected_matcher = {'matchers' => matchers}
|
10
|
+
portuguese_language(@expected_matcher)
|
11
|
+
Spec::Matchers.register_all_matchers
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'should have(n).items' do
|
15
|
+
|
16
|
+
it 'should pass if target has a collection of items with n members' do
|
17
|
+
[1, 2, 3].should ter(3).items
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should pass if target has a collection of items with < n members" do
|
21
|
+
[1, 2, 3].should_not ter(4).items
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'should have_exactly(n).items' do
|
27
|
+
|
28
|
+
it "should pass if target has a collection of items with n members" do
|
29
|
+
[1,2,3].should ter_exatamente(3).items
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should fail if target has a collection of items with < n members' do
|
33
|
+
[1,2,3].should_not ter_exatamente(4).items
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "should have_at_least(n).items" do
|
39
|
+
|
40
|
+
it "should pass if target has a collection of items with n members" do
|
41
|
+
[1, 2, 3].should ter_no_minimo(3).items
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should fail if target has a collection of items with < n members" do
|
45
|
+
[1, 2, 3].should_not ter_no_minimo(4).items
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "should have_at_most(n).items" do
|
51
|
+
|
52
|
+
it "should pass if target has a collection of items with n members" do
|
53
|
+
[1, 2, 3].should ter_no_maximo(3).items
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should fail if target has a collection of items with > n members" do
|
57
|
+
[1, 2, 3].should_not ter_no_maximo(2).items
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "should include(expected)" do
|
4
|
+
before(:each) do
|
5
|
+
@expected_matcher = {'matchers' => { 'include' => 'incluir'} }
|
6
|
+
portuguese_language(@expected_matcher)
|
7
|
+
Spec::Matchers.register_all_matchers
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should translated the include matcher" do
|
11
|
+
values = @expected_matcher['matchers']['include'].split('|')
|
12
|
+
|
13
|
+
values.each do |value_method|
|
14
|
+
Object.instance_methods.should be_include(value_method)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should pass if target includes expected" do
|
20
|
+
[1,2,3].should incluir(3)
|
21
|
+
"abc".should incluir("a")
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should pass if target is a Hash and has the expected as a key' do
|
25
|
+
{:key => 'value'}.should incluir(:key)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should fail if target does not include expected" do
|
29
|
+
lambda {
|
30
|
+
[1,2,3].should incluir(4)
|
31
|
+
}.should raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "should match(expected)" do
|
4
|
+
before(:each) do
|
5
|
+
@expected_matcher = {'matchers' => { 'match' => 'corresponder'} }
|
6
|
+
portuguese_language(@expected_matcher)
|
7
|
+
Spec::Matchers.register_all_matchers
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should translated the include matcher" do
|
11
|
+
values = @expected_matcher['matchers']['match'].split('|')
|
12
|
+
values.each do |value_method|
|
13
|
+
Object.instance_methods.should be_include(value_method)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should pass when target (String) matches expected (Regexp)" do
|
18
|
+
"string".should corresponder(/tri/)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should pass when target (String) matches expected (String)" do
|
22
|
+
"string".should corresponder("tri")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should fail when target (String) does not match expected (Regexp)" do
|
26
|
+
lambda {
|
27
|
+
"string".should corresponder(/rings/)
|
28
|
+
}.should raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should fail when target (String) does not match expected (String)" do
|
32
|
+
lambda {
|
33
|
+
"string".should corresponder("rings")
|
34
|
+
}.should raise_error
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "should raise_error" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@expected_matcher = {'matchers' => {'raise_error' => 'mostrar_erro'}}
|
7
|
+
portuguese_language(@expected_matcher)
|
8
|
+
Spec::Matchers.register_all_matchers
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should register the methods for the value equal matcher' do
|
12
|
+
values = @expected_matcher['matchers']['raise_error'].split('|')
|
13
|
+
values.each { |method_name| Object.instance_methods.should be_include(method_name) }
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should pass if anything is raised" do
|
17
|
+
lambda {raise}.should mostrar_erro
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should fail if nothing is raised" do
|
21
|
+
lambda {
|
22
|
+
lambda {}.should mostrar_erro
|
23
|
+
}.should mostrar_erro
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module SpecI18n
|
4
|
+
module Matchers
|
5
|
+
describe 'register all matcher' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
Spec::Runner.configuration.spec_language('pt')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should not raise error for register all the words for i18n' do
|
12
|
+
lambda { Spec::Matchers.register_all_matchers }.should_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "should satisfy { block }" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@expected_matcher = { 'matchers' => { 'satisfy' => 'satisfazer'} }
|
7
|
+
portuguese_language(@expected_matcher)
|
8
|
+
Spec::Matchers.register_all_matchers
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should trasnlate the satisfy matcher' do
|
12
|
+
values = @expected_matcher['matchers']['satisfy'].split('|')
|
13
|
+
values.each do |value_method|
|
14
|
+
Object.instance_methods.should be_include(value_method)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should pass if block returns true" do
|
19
|
+
true.should satisfazer { |val| val }
|
20
|
+
true.should satisfazer do |val|
|
21
|
+
val
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should fail if block returns false" do
|
26
|
+
false.should_not satisfazer { |val| val }
|
27
|
+
end
|
28
|
+
end
|
@@ -25,71 +25,23 @@ module SpecI18n
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
-
context "
|
28
|
+
context "incomplete languages" do
|
29
29
|
|
30
|
-
it "should return
|
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 => []})
|
30
|
+
it "should return false for the complete language" do
|
36
31
|
@pt.incomplete?.should be_false
|
37
32
|
end
|
38
33
|
|
39
|
-
|
40
|
-
|
41
|
-
|
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]
|
34
|
+
it "should return true for the incomplete language" do
|
35
|
+
@pt.stub!(:keywords).and_return({ :name => []})
|
36
|
+
@pt.incomplete?.should be_true
|
56
37
|
end
|
57
38
|
|
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
39
|
end
|
63
40
|
|
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
|
89
|
-
|
90
41
|
%w(describe before after it should name native).each do |keyword|
|
91
42
|
it "should have the #{keyword} keyword" do
|
92
|
-
@pt.keywords.keys
|
43
|
+
portuguese_keys = @pt.keywords.keys
|
44
|
+
portuguese_keys.should include(keyword)
|
93
45
|
end
|
94
46
|
end
|
95
47
|
|
@@ -163,20 +115,52 @@ module SpecI18n
|
|
163
115
|
end
|
164
116
|
end
|
165
117
|
|
166
|
-
context
|
167
|
-
|
118
|
+
context 'of example subject keywords' do
|
119
|
+
|
120
|
+
before(:each) do
|
121
|
+
@keywords = { "subject" => "assunto|tema" }
|
122
|
+
@spanish_keywords = { 'subject' => 'asunto|tema'}
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should return the subject keywords' do
|
126
|
+
@pt.stub!(:keywords).and_return(@keywords)
|
127
|
+
@pt.subject_keywords.should == {'subject' => ["assunto", "tema"]}
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should return the subject keywords for spanish language' do
|
131
|
+
@spanish_keywords.stub!(:keywords).and_return(@spanish_keywords)
|
132
|
+
@es.subject_keywords.should == { 'subject' => ['asunto', 'tema']}
|
133
|
+
end
|
168
134
|
end
|
169
135
|
|
136
|
+
context 'of example its keywords' do
|
137
|
+
|
138
|
+
before(:each) do
|
139
|
+
@keywords = { "its" => "exemplos" }
|
140
|
+
@spanish_keywords = { 'its' => 'ejemplos'}
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should return the its keywords' do
|
144
|
+
@pt.stub!(:keywords).and_return(@keywords)
|
145
|
+
@pt.its_keywords.should == {'its' => ["exemplos"]}
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should return the its keywords for spanish language' do
|
149
|
+
@es.stub!(:keywords).and_return(@spanish_keywords)
|
150
|
+
@es.its_keywords.should == { 'its' => ['ejemplos']}
|
151
|
+
end
|
152
|
+
end
|
170
153
|
context "splitting the keys" do
|
171
154
|
it "should raise no found key" do
|
172
155
|
lambda {
|
173
156
|
@pt.spec_keywords("no_found")
|
157
|
+
@pt.spec_keywords("Oh_MY_this_words_is_not_found!")
|
174
158
|
}.should raise_error(RuntimeError)
|
175
159
|
end
|
176
160
|
|
177
161
|
it "should split correctly the keys" do
|
178
162
|
lang = { "describe" => "descreva|contexto" }
|
179
|
-
|
163
|
+
@pt.stub!(:keywords).and_return(lang)
|
180
164
|
@pt.spec_keywords("describe").should == { "describe" => ["descreva", "contexto"] }
|
181
165
|
end
|
182
166
|
end
|