quiz_dsl 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/Gemfile +7 -0
- data/Gemfile~ +4 -0
- data/Guardfile +39 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +5 -0
- data/Rakefile~ +2 -0
- data/lib/quiz_dsl/version.rb +3 -0
- data/lib/quiz_dsl.rb +111 -0
- data/lib/quiz_dsl.rb~ +110 -0
- data/quiz_dsl.gemspec +24 -0
- data/quiz_dsl.gemspec~ +24 -0
- data/spec/quiz_dsl_spec.rb +28 -0
- data/spec/quiz_dsl_spec.rb~ +27 -0
- data/spec/spec_helper.rb +17 -0
- metadata +106 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e501d80534b3ad84ab1f10fe4d053342648b2888
|
|
4
|
+
data.tar.gz: ff0f08ae32c4aab93e276931b39e1c291aa537fe
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8d1b18d1f30155b678f8394841e39891cd9a705f3b268d3e338c082245c903cdb14a6554e42fc6445e7546ad23589f733d5e721b385a7161e7f1b19389f2b66f
|
|
7
|
+
data.tar.gz: e23bba52a3e6cc933a09e5e548f41c3d58de0295b6320b4114e1cb2243b110d08e1beb274f5fc4b496cfebd3bdcf251ace625475593fe234426e571cc80634e9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile~
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
guard :bundler do
|
|
5
|
+
watch('Gemfile')
|
|
6
|
+
# Uncomment next line if your Gemfile contains the `gemspec' command.
|
|
7
|
+
# watch(/^.+\.gemspec/)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
|
11
|
+
# rspec may be run, below are examples of the most common uses.
|
|
12
|
+
# * bundler: 'bundle exec rspec'
|
|
13
|
+
# * bundler binstubs: 'bin/rspec'
|
|
14
|
+
# * spring: 'bin/rsspec' (This will use spring if running and you have
|
|
15
|
+
# installed the spring binstubs per the docs)
|
|
16
|
+
# * zeus: 'zeus rspec' (requires the server to be started separetly)
|
|
17
|
+
# * 'just' rspec: 'rspec'
|
|
18
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
|
19
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
20
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
21
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
22
|
+
|
|
23
|
+
# Rails example
|
|
24
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
25
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
|
26
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
|
27
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
|
28
|
+
watch('config/routes.rb') { "spec/routing" }
|
|
29
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
|
30
|
+
watch('spec/rails_helper.rb') { "spec" }
|
|
31
|
+
|
|
32
|
+
# Capybara features specs
|
|
33
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
|
34
|
+
|
|
35
|
+
# Turnip features and steps
|
|
36
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
37
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
|
38
|
+
end
|
|
39
|
+
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Juan Jose Gregorio Diaz Marrero
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# QuizDsl
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'quiz_dsl'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install quiz_dsl
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
TODO: Write usage instructions here
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/quiz_dsl/fork )
|
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/Rakefile~
ADDED
data/lib/quiz_dsl.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
require "quiz_dsl/version"
|
|
2
|
+
|
|
3
|
+
module QuizDsl
|
|
4
|
+
|
|
5
|
+
WRONG = false
|
|
6
|
+
RIGHT = true
|
|
7
|
+
# Clase Quiz DSL
|
|
8
|
+
class Quiz
|
|
9
|
+
attr_accessor :name, :questions
|
|
10
|
+
# Recibe el nombre del test y un bloque con las preguntas y sus respuestas
|
|
11
|
+
#
|
|
12
|
+
# Ejemplo de uso:
|
|
13
|
+
# quiz = Quiz.new("Test 1"){ |e|
|
|
14
|
+
# e.question "Pregunta 1",
|
|
15
|
+
# e.wrong => "Respuesta incorrecta 1",
|
|
16
|
+
# e.wrong => "Respuesta incorrecta 2",
|
|
17
|
+
# e.wrong => "Respuesta incorrecta 3",
|
|
18
|
+
# e.wrong => "Respuesta correcta"
|
|
19
|
+
# }
|
|
20
|
+
def initialize(name)
|
|
21
|
+
raise ArgumentError, "El nombre del cuestionario tiene que ser una cadena" unless name.is_a? String
|
|
22
|
+
@count = 0
|
|
23
|
+
@aciertos = 0
|
|
24
|
+
@name = name
|
|
25
|
+
@questions = []
|
|
26
|
+
yield self
|
|
27
|
+
end
|
|
28
|
+
# Preguntas incorrectas
|
|
29
|
+
def wrong
|
|
30
|
+
@count += 1
|
|
31
|
+
[@count, WRONG]
|
|
32
|
+
end
|
|
33
|
+
# Preguntas correctas
|
|
34
|
+
def right
|
|
35
|
+
:right
|
|
36
|
+
end
|
|
37
|
+
# Método que recibe el título de la pregunta y una serie de parámetros como respuestas
|
|
38
|
+
def question(title, anss)
|
|
39
|
+
raise ArgumentError, "El título tiene que ser una cadena" unless title.is_a? String
|
|
40
|
+
answers = []
|
|
41
|
+
anss.each do |ans|
|
|
42
|
+
a = Answer.new(ans)
|
|
43
|
+
answers << a
|
|
44
|
+
end
|
|
45
|
+
q = Question.new(title, answers)
|
|
46
|
+
questions << q
|
|
47
|
+
end
|
|
48
|
+
# Ejecuta el test por consola
|
|
49
|
+
def run
|
|
50
|
+
puts name
|
|
51
|
+
questions.each do |q|
|
|
52
|
+
puts q
|
|
53
|
+
print "Su respuesta: "
|
|
54
|
+
resp = gets.chomp.to_i
|
|
55
|
+
raise IndexError, "La respuesta debe estar entre 1 y #{q.answers.size}." unless resp <= q.answers.size and resp > 0
|
|
56
|
+
if q.answers[resp-1].state
|
|
57
|
+
puts "Correcto!"
|
|
58
|
+
@aciertos += 1
|
|
59
|
+
else
|
|
60
|
+
correcta = q.answers.select { |ans| ans.state }.first
|
|
61
|
+
puts "Fallo, la respuesta correcta era #{correcta}"
|
|
62
|
+
end
|
|
63
|
+
puts
|
|
64
|
+
end
|
|
65
|
+
puts "Has acertado el #{(@aciertos/questions.size.to_f)*100}% de las preguntas [#{@aciertos} de #{questions.size}]."
|
|
66
|
+
end
|
|
67
|
+
# Representación visual de un Test en forma de String.
|
|
68
|
+
def to_s
|
|
69
|
+
out = name + "\n"
|
|
70
|
+
questions.each do |q|
|
|
71
|
+
out << "#{q}\n"
|
|
72
|
+
end
|
|
73
|
+
out
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Clase que representa una de pregunta a un test.
|
|
78
|
+
class Question
|
|
79
|
+
attr_accessor :answers, :title
|
|
80
|
+
|
|
81
|
+
def initialize(title, anss)
|
|
82
|
+
raise ArgumentError, "El título tiene que ser una cadena" unless title.is_a? String
|
|
83
|
+
@title = title
|
|
84
|
+
@answers = anss
|
|
85
|
+
end
|
|
86
|
+
def to_s
|
|
87
|
+
out = " #{@title}" + "\n"
|
|
88
|
+
i = 1
|
|
89
|
+
answers.each do |a|
|
|
90
|
+
out << " [#{i}] #{a}\n"
|
|
91
|
+
i += 1
|
|
92
|
+
end
|
|
93
|
+
out
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
# Clase que representa las respuestas a preguntas de un test.
|
|
97
|
+
class Answer
|
|
98
|
+
attr_reader :state, :value
|
|
99
|
+
def initialize(ans)
|
|
100
|
+
raise ArgumentError, "Se esperaba un dato del tipo Array" unless ans.is_a? Array
|
|
101
|
+
raise IndexError, 'Debe contener dos argumentos ' unless ans.size == 2
|
|
102
|
+
state = ans[0]
|
|
103
|
+
value = ans[1]
|
|
104
|
+
state == :right ? @state = RIGHT : @state = WRONG
|
|
105
|
+
@value = value
|
|
106
|
+
end
|
|
107
|
+
def to_s
|
|
108
|
+
"#{@value}"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
data/lib/quiz_dsl.rb~
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require "quiz_dsl/version"
|
|
2
|
+
|
|
3
|
+
module QuizDsl
|
|
4
|
+
WRONG = false
|
|
5
|
+
RIGHT = true
|
|
6
|
+
# Clase Quiz DSL
|
|
7
|
+
class Quiz
|
|
8
|
+
attr_accessor :name, :questions
|
|
9
|
+
# Recibe el nombre del test y un bloque con las preguntas y sus respuestas
|
|
10
|
+
#
|
|
11
|
+
# Ejemplo de uso:
|
|
12
|
+
# quiz = Quiz.new("Test 1"){ |e|
|
|
13
|
+
# e.question "Pregunta 1",
|
|
14
|
+
# e.wrong => "Respuesta incorrecta 1",
|
|
15
|
+
# e.wrong => "Respuesta incorrecta 2",
|
|
16
|
+
# e.wrong => "Respuesta incorrecta 3",
|
|
17
|
+
# e.wrong => "Respuesta correcta"
|
|
18
|
+
# }
|
|
19
|
+
def initialize(name)
|
|
20
|
+
raise ArgumentError, "El nombre del cuestionario tiene que ser una cadena" unless name.is_a? String
|
|
21
|
+
@count = 0
|
|
22
|
+
@aciertos = 0
|
|
23
|
+
@name = name
|
|
24
|
+
@questions = []
|
|
25
|
+
yield self
|
|
26
|
+
end
|
|
27
|
+
# Preguntas incorrectas
|
|
28
|
+
def wrong
|
|
29
|
+
@count += 1
|
|
30
|
+
[@count, WRONG]
|
|
31
|
+
end
|
|
32
|
+
# Preguntas correctas
|
|
33
|
+
def right
|
|
34
|
+
:right
|
|
35
|
+
end
|
|
36
|
+
# Método que recibe el título de la pregunta y una serie de parámetros como respuestas
|
|
37
|
+
def question(title, anss)
|
|
38
|
+
raise ArgumentError, "El título tiene que ser una cadena" unless title.is_a? String
|
|
39
|
+
answers = []
|
|
40
|
+
anss.each do |ans|
|
|
41
|
+
a = Answer.new(ans)
|
|
42
|
+
answers << a
|
|
43
|
+
end
|
|
44
|
+
q = Question.new(title, answers)
|
|
45
|
+
questions << q
|
|
46
|
+
end
|
|
47
|
+
# Ejecuta el test por consola
|
|
48
|
+
def run
|
|
49
|
+
puts name
|
|
50
|
+
questions.each do |q|
|
|
51
|
+
puts q
|
|
52
|
+
print "Su respuesta: "
|
|
53
|
+
resp = gets.chomp.to_i
|
|
54
|
+
raise IndexError, "La respuesta debe estar entre 1 y #{q.answers.size}." unless resp <= q.answers.size and resp > 0
|
|
55
|
+
if q.answers[resp-1].state
|
|
56
|
+
puts "Correcto!"
|
|
57
|
+
@aciertos += 1
|
|
58
|
+
else
|
|
59
|
+
correcta = q.answers.select { |ans| ans.state }.first
|
|
60
|
+
puts "Fallo, la respuesta correcta era #{correcta}"
|
|
61
|
+
end
|
|
62
|
+
puts
|
|
63
|
+
end
|
|
64
|
+
puts "Has acertado el #{(@aciertos/questions.size.to_f)*100}% de las preguntas [#{@aciertos} de #{questions.size}]."
|
|
65
|
+
end
|
|
66
|
+
# Representación visual de un Test en forma de String.
|
|
67
|
+
def to_s
|
|
68
|
+
out = name + "\n"
|
|
69
|
+
questions.each do |q|
|
|
70
|
+
out << "#{q}\n"
|
|
71
|
+
end
|
|
72
|
+
out
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Clase que representa una de pregunta a un test.
|
|
77
|
+
class Question
|
|
78
|
+
attr_accessor :answers, :title
|
|
79
|
+
|
|
80
|
+
def initialize(title, anss)
|
|
81
|
+
raise ArgumentError, "El título tiene que ser una cadena" unless title.is_a? String
|
|
82
|
+
@title = title
|
|
83
|
+
@answers = anss
|
|
84
|
+
end
|
|
85
|
+
def to_s
|
|
86
|
+
out = " #{@title}" + "\n"
|
|
87
|
+
i = 1
|
|
88
|
+
answers.each do |a|
|
|
89
|
+
out << " [#{i}] #{a}\n"
|
|
90
|
+
i += 1
|
|
91
|
+
end
|
|
92
|
+
out
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
# Clase que representa las respuestas a preguntas de un test.
|
|
96
|
+
class Answer
|
|
97
|
+
attr_reader :state, :value
|
|
98
|
+
def initialize(ans)
|
|
99
|
+
raise ArgumentError, "Se esperaba un dato del tipo Array" unless ans.is_a? Array
|
|
100
|
+
raise IndexError, 'Debe contener dos argumentos ' unless ans.size == 2
|
|
101
|
+
state = ans[0]
|
|
102
|
+
value = ans[1]
|
|
103
|
+
state == :right ? @state = RIGHT : @state = WRONG
|
|
104
|
+
@value = value
|
|
105
|
+
end
|
|
106
|
+
def to_s
|
|
107
|
+
"#{@value}"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
data/quiz_dsl.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'quiz_dsl/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "quiz_dsl"
|
|
8
|
+
spec.version = QuizDsl::VERSION
|
|
9
|
+
spec.authors = ["Juan Jose Gregorio Diaz Marrero, Miguel Aurelio García González"]
|
|
10
|
+
spec.email = ["alu0100721805@ull.edu.es"]
|
|
11
|
+
spec.summary = %q{Clase para escribir un examen en un DSL bajo ruby}
|
|
12
|
+
spec.description = %q{Práctica 11 LPP}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
spec.add_development_dependency "rspec", "~>2.11"
|
|
24
|
+
end
|
data/quiz_dsl.gemspec~
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'quiz_dsl/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "quiz_dsl"
|
|
8
|
+
spec.version = QuizDsl::VERSION
|
|
9
|
+
spec.authors = ["Juan Jose Gregorio Diaz Marrero"]
|
|
10
|
+
spec.email = ["alu0100721805@ull.edu.es"]
|
|
11
|
+
spec.summary = %q{TODO: Write a short summary. Required.}
|
|
12
|
+
spec.description = %q{TODO: Write a longer description. Optional.}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
spec.add_development_dependency "rspec", "~>2.11"
|
|
24
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'quiz_dsl.rb'
|
|
2
|
+
require 'spec_helper.rb'
|
|
3
|
+
include QuizDsl
|
|
4
|
+
|
|
5
|
+
describe Quiz do
|
|
6
|
+
before :all do
|
|
7
|
+
@quiz = Quiz.new("test"){ |e|
|
|
8
|
+
e.question "Pregunta 1",
|
|
9
|
+
e.right => "Answer 1" ,
|
|
10
|
+
e.wrong => "Answer2"
|
|
11
|
+
}
|
|
12
|
+
end
|
|
13
|
+
it "Debe tener un método 'question' para declarar preguntas" do
|
|
14
|
+
(@quiz.respond_to? :question).should == true
|
|
15
|
+
end
|
|
16
|
+
it "Debe tener un método 'wrong' para declarar respuestas erróneas" do
|
|
17
|
+
(@quiz.respond_to? :wrong).should == true
|
|
18
|
+
end
|
|
19
|
+
it "Debe tener un método 'right' para declarar la respuesta correcta" do
|
|
20
|
+
(@quiz.respond_to? :right).should == true
|
|
21
|
+
end
|
|
22
|
+
it "Debe tener un método 'run' que ejecuta el test" do
|
|
23
|
+
(@quiz.respond_to? :run).should == true
|
|
24
|
+
end
|
|
25
|
+
it "Debe tener un método 'to_s'" do
|
|
26
|
+
(@quiz.respond_to? :to_s).should == true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'quiz_dsl.rb'
|
|
2
|
+
include QuizDsl
|
|
3
|
+
|
|
4
|
+
describe Quiz do
|
|
5
|
+
before :all do
|
|
6
|
+
@quiz = Quiz.new("test"){ |e|
|
|
7
|
+
e.question "Pregunta 1",
|
|
8
|
+
e.right => "Answer 1" ,
|
|
9
|
+
e.wrong => "Answer2"
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
it "Debe tener un método 'question' para declarar preguntas" do
|
|
13
|
+
(@quiz.respond_to? :question).should == true
|
|
14
|
+
end
|
|
15
|
+
it "Debe tener un método 'wrong' para declarar respuestas erróneas" do
|
|
16
|
+
(@quiz.respond_to? :wrong).should == true
|
|
17
|
+
end
|
|
18
|
+
it "Debe tener un método 'right' para declarar la respuesta correcta" do
|
|
19
|
+
(@quiz.respond_to? :right).should == true
|
|
20
|
+
end
|
|
21
|
+
it "Debe tener un método 'run' que ejecuta el test" do
|
|
22
|
+
(@quiz.respond_to? :run).should == true
|
|
23
|
+
end
|
|
24
|
+
it "Debe tener un método 'to_s'" do
|
|
25
|
+
(@quiz.respond_to? :to_s).should == true
|
|
26
|
+
end
|
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
|
4
|
+
# loaded once.
|
|
5
|
+
#
|
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
7
|
+
RSpec.configure do |config|
|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
9
|
+
config.run_all_when_everything_filtered = true
|
|
10
|
+
config.filter_run :focus
|
|
11
|
+
|
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
14
|
+
# the seed, which is printed after each run.
|
|
15
|
+
# --seed 1234
|
|
16
|
+
config.order = 'random'
|
|
17
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: quiz_dsl
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Juan Jose Gregorio Diaz Marrero, Miguel Aurelio García González
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.7'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.11'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.11'
|
|
55
|
+
description: Práctica 11 LPP
|
|
56
|
+
email:
|
|
57
|
+
- alu0100721805@ull.edu.es
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- Gemfile
|
|
65
|
+
- Gemfile~
|
|
66
|
+
- Guardfile
|
|
67
|
+
- LICENSE.txt
|
|
68
|
+
- README.md
|
|
69
|
+
- Rakefile
|
|
70
|
+
- Rakefile~
|
|
71
|
+
- lib/quiz_dsl.rb
|
|
72
|
+
- lib/quiz_dsl.rb~
|
|
73
|
+
- lib/quiz_dsl/version.rb
|
|
74
|
+
- quiz_dsl.gemspec
|
|
75
|
+
- quiz_dsl.gemspec~
|
|
76
|
+
- spec/quiz_dsl_spec.rb
|
|
77
|
+
- spec/quiz_dsl_spec.rb~
|
|
78
|
+
- spec/spec_helper.rb
|
|
79
|
+
homepage: ''
|
|
80
|
+
licenses:
|
|
81
|
+
- MIT
|
|
82
|
+
metadata: {}
|
|
83
|
+
post_install_message:
|
|
84
|
+
rdoc_options: []
|
|
85
|
+
require_paths:
|
|
86
|
+
- lib
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
requirements: []
|
|
98
|
+
rubyforge_project:
|
|
99
|
+
rubygems_version: 2.2.2
|
|
100
|
+
signing_key:
|
|
101
|
+
specification_version: 4
|
|
102
|
+
summary: Clase para escribir un examen en un DSL bajo ruby
|
|
103
|
+
test_files:
|
|
104
|
+
- spec/quiz_dsl_spec.rb
|
|
105
|
+
- spec/quiz_dsl_spec.rb~
|
|
106
|
+
- spec/spec_helper.rb
|