Skip to content

Commit

Permalink
Añadiendo corrección de hash wrong con key
Browse files Browse the repository at this point in the history
  • Loading branch information
alu4421 committed Dec 11, 2014
1 parent dabd18e commit bfc520d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ gem 'guard'
gem 'guard-rspec'
gem 'guard-bundler'
gem 'guard-gitpusher'
#gem 'quizHanielMaria', '~> 0.0.1'
# Specify your gem's dependencies in question_examen.gemspec
gemspec
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ desc "Prueba las pruebas"
task :spec do
sh "rspec -I. -Ilib -Ispec spec/quiz_spec.rb"
end

desc "Instalar Gema"
task :install do
sh "gem install quizHanielMaria-0.0.1.gem"
end
12 changes: 6 additions & 6 deletions lib/quiz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def to_s
n = 1
out << "\n\t #{n}.- #{answers[:right]}\n"
n+=1
answers[:wrong].each do |op|
answers.each_with_index do |op|
out<<"\t #{n}.- #{op}\n"
n+=1
end
Expand All @@ -25,15 +25,13 @@ def to_s
end #fin clase Question
class P_Quiz
attr_accessor :name, :questions
def initialize(name, &block)
self.name = name
self.questions = []
@count =0
instance_eval &block
end
Expand All @@ -54,8 +52,10 @@ def question(text, answers = {})
questions << question
end
def wrong (option)
self.questions[-1].answers[:wrong] << option
def wrong ()
#self.questions[-1].answers[:wrong] << option
@count +=1
"Key#{@count}"
end
end #fin clase P_Quiz
Expand Down
30 changes: 8 additions & 22 deletions spec/quiz_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,13 @@ module Quiz
@v_quiz=P_Quiz.new("Cuestionario de LPP 05/12/2014") {
question 'Cuantos argumentos de tipo bloque puede recibir un metodo?',
:right => '1',
:wrong => []
wrong '2'
wrong 'muchos'
wrong 'los que defina el usuario'
wrong => '2',
wrong => 'muchos',
wrong => 'los que defina el usuario'

question 'En Ruby los bloque son objetos que continen codigo',
:right=>'Falso',
:wrong => []
wrong 'Cierto'

question '¿En que año Cristobal Colón descubrió América?',
:right => '1492',
:wrong =>[]
wrong '1942'
wrong '1808'
wrong '1914'

a = rand(10)
b = rand(10)
question "#{a}+#{b} = ",
:right => "#{a + b}",
:wrong => []
wrong "44"
wrong "#{a + b + 2}"
wrong "#{a + b - 2}"
wrong => 'Cierto'
}
puts @v_quiz.to_s
end
Expand All @@ -39,6 +21,10 @@ module Quiz
expect(@v_quiz.class).to eq(P_Quiz)
end

#it "Comprobar que existe funcion question" do
# expect(@v_quiz).to respond_to :question
#end


end #fin describe
end #fin module

0 comments on commit bfc520d

Please sign in to comment.