spec/spec-i18n/example/subject_spec.rb in rspec-i18n-1.1.0 vs spec/spec-i18n/example/subject_spec.rb in rspec-i18n-1.2.0
- old
+ new
@@ -3,33 +3,34 @@
module Spec
module Example
describe "implicit subject" do
before(:each) do
- @pt = portuguese_language({'subject' => 'assunto', 'should' => 'deve',
- 'should_not' => 'nao_deve','matchers' => {}})
+ @keywords = {'subject' => 'assunto|asunto',
+ 'should' => 'deve|deveria',
+ 'should_not' => 'nao_deve|nao_deveria','matchers' => {}}
+ stub_language!("pt", @keywords)
Subject::ExampleMethods.register_subjects
- @es = spanish_language({'subject' => 'asunto', 'should' => 'deve',
- 'should_not' => 'nao_deve', 'matchers' => {}})
- Subject::ExampleMethods.register_subjects
+ @name_methods = Subject::ExampleMethods.instance_methods.to_symbols
end
it 'should have the subject translated' do
- values = @pt['subject'].split('|')
- values << @es['subject'].split('|')
- values.flatten.each do |value_method|
- Subject::ExampleMethods.instance_methods.should be_include(value_method)
+ [:assunto, :asunto].each do |translated_subject|
+ @name_methods.should include(translated_subject)
end
end
+
+ it "should have the 'should' method translated in subject" do
+ [:deve, :deveria].each do |should_method|
+ @name_methods.should include(should_method)
+ end
+ end
it "should have the should and should_not method trasnlated" do
- values = @pt['should'].split('|')
- other_values = @pt['should_not'].split('|')
- values << other_values
- values.flatten.each do |value_method|
- Subject::ExampleMethods.instance_methods.should be_include(value_method)
- end
+ [:nao_deve, :nao_deveria].each do |should_not_method|
+ @name_methods.should include(should_not_method)
+ end
end
describe "with a class" do
it "returns an instance of the class" do
group = Class.new(ExampleGroupDouble).describe(Array)
@@ -62,19 +63,11 @@
before(:each) do
@group = Class.new do
extend Spec::Example::Subject::ExampleGroupMethods
include Spec::Example::Subject::ExampleMethods
- class << self
- def described_class
- Array
- end
- end
- def described_class
- self.class.described_class
- end
-
+
subject {
[1,2,3]
}
end
end
@@ -89,37 +82,30 @@
it "is available in a doubly nested group (subclass)" do
nested_group = Class.new(@group)
doubly_nested_group = Class.new(nested_group)
example = doubly_nested_group.new
- example.subject.should == [1,2,3]
+ example.asunto.should == [1,2,3]
end
end
describe ".its (to access subject's attributes)" do
before(:each) do
- @its_examples = {'subject' => 'assunto', 'its' => 'exemplos', 'matchers' => {}}
- @pt = portuguese_language(@its_examples)
+ @keywords = {'subject' => 'assunto', 'its' => 'exemplos', 'matchers' => {}}
+ stub_language!("pt", @keywords)
Subject::ExampleGroupMethods.register_subjects
- @es = spanish_language({'subject' => 'assunto', 'its' => 'ejemplos', 'matchers' => {}})
- Subject::ExampleGroupMethods.register_subjects
end
- with_sandboxed_options do
- it "passes when expectation should pass" do
- group = Class.new(ExampleGroupDouble).describe(Array)
- child = group.exemplos(:length) { should == 0 }
- child.run(options).should == true
- end
-
- it "fails when expectation should fail" do
- group = Class.new(ExampleGroupDouble).describe(Array)
- child = group.ejemplos(:length) { should == 1 }
- child.run(options).should == false
- end
+ with_sandboxed_options do
+ it "passes when expectation should pass" do
+ group = Class.new(ExampleGroupDouble).describe(Array)
+ child = group.exemplos(:length) { should == 0 }
+ child.run(options).should == true
+ end
end
+
end
end
end