spec/lib/uni_spec.rb in uni-0.0.7 vs spec/lib/uni_spec.rb in uni-0.0.8

- old
+ new

@@ -1,79 +1,146 @@ # encoding: utf-8 require 'spec_helper' describe 'Uni' do - - describe '#codigo_Uni' do - it "returns a String" do - Uni::codigo_uni(20072531).should be_an_instance_of String + + context 'parameters' do + it 'has correct orce''s url' do + Uni::URL.should eql 'http://www.orce.uni.edu.pe/' end - it "returns 20072531G for 20072531" do - Uni::codigo_uni(20072531).should eql "20072531G" + it 'has a collection of all posible situacion' do + Uni::SITUACION.should be_an_instance_of Array end - it "returns 19100003B for 19100003" do - Uni::codigo_uni(19100003).should eql "19100003B" + end + + describe '#valid?' do + specify { Uni.valid?(20072531).should be_true } + specify { Uni.valid?('20072531g').should be_true } + specify { Uni.valid?('20072531a').should_not be_true } + end + + describe '#codigo_Uni' do + context 'param is String' do + it 'returns a String' do + Uni::codigo_uni('20072531').should be_an_instance_of String + end + it 'returns "20072531G" for 20072531' do + Uni::codigo_uni('20072531').should eql '20072531G' + end + it 'returns "19100003B" for 19100003' do + Uni::codigo_uni('19100003').should eql '19100003B' + end + it 'returns "20090435F" for 20090435' do + Uni::codigo_uni('20090435').should eql '20090435F' + end end - it "returns 20090435F for 20090435" do - Uni::codigo_uni(20090435).should eql "20090435F" + + context 'param is Fixnum' do + it 'returns a String' do + Uni::codigo_uni(20072531).should be_an_instance_of String + end + it 'returns "20072531G" for 20072531' do + Uni::codigo_uni(20072531).should eql '20072531G' + end + it 'returns "19100003B" for 19100003' do + Uni::codigo_uni(19100003).should eql '19100003B' + end + it 'returns "20090435F" for 20090435' do + Uni::codigo_uni(20090435).should eql '20090435F' + end end + end describe '#fast_Uni' do - before(:all) do - Uni.initialize + before(:all) { Uni.initialize } + + it 'initialize memory' do + Uni.initialize.should eql 'memoria inicializada' end - it "returns a String" do - Uni::fast_uni(20072531).should be_an_instance_of String + context 'param is String' do + it 'returns a String' do + Uni::fast_uni('20072531').should be_an_instance_of String + end + it 'returns "20072531G" for 20072531' do + Uni::fast_uni('20072531').should eql '20072531G' + end + it 'returns "19100003B" for 19100003' do + Uni::fast_uni('19100003').should eql '19100003B' + end + it 'returns "20090435F" for 20090435' do + Uni::fast_uni('20090435').should eql '20090435F' + end end - it "returns 20072531G for 20072531" do - Uni::fast_uni(20072531).should eql "20072531G" + + context 'param is Fixnum' do + it 'returns a String' do + Uni::fast_uni(20072531).should be_an_instance_of String + end + it 'returns "20072531G" for 20072531' do + Uni::fast_uni(20072531).should eql '20072531G' + end + it 'returns "19100003B" for 19100003' do + Uni::fast_uni(19100003).should eql '19100003B' + end + it 'returns "20090435F" for 20090435' do + Uni::fast_uni(20090435).should eql '20090435F' + end end - it "returns 19100003B for 19100003" do - Uni::fast_uni(19100003).should eql "19100003B" - end - it "returns 20090435F for 20090435" do - Uni::fast_uni(20090435).should eql "20090435F" - end + end describe '#data' do - before(:all) do - @Uni = Uni::data "20072531G" - @titulado = Uni::data "19100003B" - @egreso = Uni::data "19780540K" - @invalid = Uni::data "20072531A" - end + let(:regular) { Uni::data '20072531G' } + let(:titulado) { Uni::data '19100003B' } + let(:egresado) { Uni::data '19780540K' } + let(:invalido) { Uni::data '20072531a' } + let(:fixnum) { Uni.data 20072531 } + let(:inv_fixnum) { Uni.data 2007253 } - it "returns a Hash if codigo valid" do - @Uni.should be_an_instance_of Hash + it 'returns a Hash' do + regular.should be_an_instance_of Hash end - it "returns an empty Hash if codigo invalid" do - @invalid.should eql Hash.new + it 'returns an empty Hash if codigo is invalid' do + invalido.should eql Hash.new + inv_fixnum.should eql Hash.new end - it "returns 'PANDO MORALES CARLOS ENRIQUE' for :nombre of 20072531G" do - @Uni[:nombre].should eql "PANDO MORALES CARLOS ENRIQUE" + it 'works with param as Fixnum' do + fixnum[:nombre].should eql 'PANDO MORALES CARLOS ENRIQUE' + fixnum[:situacion].should eql 'ALUMNO REGULAR' + fixnum[:medida_disciplinaria].should eql 'NO TIENE' end - it "returns 'ALUMNO REGULAR' for :situacion of 20072531G" do - @Uni[:situacion].should eql "ALUMNO REGULAR" + it 'returns data for "20072531G"' do + regular[:nombre].should eql 'PANDO MORALES CARLOS ENRIQUE' + regular[:situacion].should eql 'ALUMNO REGULAR' + regular[:medida_disciplinaria].should eql 'NO TIENE' end - it "returns 'NO TIENE' for :medida_disciplinaria of 20072531G" do - @Uni[:medida_disciplinaria].should eql "NO TIENE" + it 'returns data for "19100003B"' do + titulado[:nombre].should eql 'ARIZOLA FRANCISCO P' + titulado[:situacion].should eql 'TITULADO' + titulado[:especialidad].should eql 'INGENIERÍA CIVIL' end - - it "returns 'ARIZOLA FRANCISCO P' for :nombre of 19100003B" do - @titulado[:nombre].should eql "ARIZOLA FRANCISCO P" + it 'returns "1993 - 1" for :egreso of "19780540K"' do + egresado[:egreso].should eql '1993 - 1' end - it "returns 'TITULADO' for :situacion of 19100003B" do - @titulado[:situacion].should eql "TITULADO" - end - it "returns 'INGENIERÍA CIVIL' for :especialidad of 19100003B" do - @titulado[:especialidad].should eql "INGENIERÍA CIVIL" - end - it "returns 1993 - 1 for :egreso of 19780540K" do - @egreso[:egreso].should eql "1993 - 1" - end end describe '#notas' do - it 'returns hash of grades' do - true.should eql true + xit 'returns an instance of Array' do + [].should be_an_instance_of Array end + xit 'returns an empty Array for invalid codigo and/or password' + xit 'works with codigo as Fixnum or String' + + context 'every element of Array' do + xit 'should be an instance of Hash' + xit 'should have the keys :curso, :codigo, :seccion, :notas' + xit 'should have an instance of String as value for :curso, :codigo, :seccion' + xit 'should have an instance of Hash as value for :notas' + context ':notas' do + xit 'contains :practicas and :examenes' + context ':practicas and :examenes' do + xit 'contains an instance of Array' + xit 'contains Strings as elements' + end + end + end + end end \ No newline at end of file