nerd_quiz 0.0.5 → 0.1.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/.gitmodules +3 -0
- data/Rakefile +6 -1
- data/lib/nerd_quiz/color.rb +55 -0
- data/lib/nerd_quiz/question.rb +47 -9
- data/lib/nerd_quiz/questions.rb +32 -0
- data/lib/nerd_quiz/quiz.rb +18 -7
- data/lib/nerd_quiz/version.rb +1 -1
- data/lib/nerd_quiz.rb +3 -0
- data/nerd_quiz.gemspec +2 -1
- data/spec/nerd_quiz/question_spec.rb +20 -1
- data/spec/nerd_quiz/questions_spec.rb +37 -0
- data/spec/nerd_quiz/quiz_spec.rb +18 -6
- metadata +27 -22
- data/features/nerd_quiz_asks_questions.feature +0 -11
- data/features/nerd_quiz_ends_quiz.feature +0 -23
- data/features/nerd_quizer_answers_questions.feature +0 -15
- data/features/nerd_quizer_starts_quiz.feature +0 -11
- data/features/step_definitions/nerd_quiz_steps.rb +0 -75
- data/features/support/env.rb +0 -1
- data/features/support/output.rb +0 -13
data/.gitmodules
ADDED
data/Rakefile
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
module NerdQuiz
|
2
|
+
# Thanks to @wycats for Color class!
|
3
|
+
# https://github.com/wycats/thor
|
4
|
+
module Color
|
5
|
+
# Embed in a String to clear all previous ANSI sequences.
|
6
|
+
CLEAR = "\e[0m"
|
7
|
+
# The start of an ANSI bold sequence.
|
8
|
+
BOLD = "\e[1m"
|
9
|
+
|
10
|
+
# Set the terminal's foreground ANSI color to black.
|
11
|
+
BLACK = "\e[30m"
|
12
|
+
# Set the terminal's foreground ANSI color to red.
|
13
|
+
RED = "\e[31m"
|
14
|
+
# Set the terminal's foreground ANSI color to green.
|
15
|
+
GREEN = "\e[32m"
|
16
|
+
# Set the terminal's foreground ANSI color to yellow.
|
17
|
+
YELLOW = "\e[33m"
|
18
|
+
# Set the terminal's foreground ANSI color to blue.
|
19
|
+
BLUE = "\e[34m"
|
20
|
+
# Set the terminal's foreground ANSI color to magenta.
|
21
|
+
MAGENTA = "\e[35m"
|
22
|
+
# Set the terminal's foreground ANSI color to cyan.
|
23
|
+
CYAN = "\e[36m"
|
24
|
+
# Set the terminal's foreground ANSI color to white.
|
25
|
+
WHITE = "\e[37m"
|
26
|
+
|
27
|
+
# Set the terminal's background ANSI color to black.
|
28
|
+
ON_BLACK = "\e[40m"
|
29
|
+
# Set the terminal's background ANSI color to red.
|
30
|
+
ON_RED = "\e[41m"
|
31
|
+
# Set the terminal's background ANSI color to green.
|
32
|
+
ON_GREEN = "\e[42m"
|
33
|
+
# Set the terminal's background ANSI color to yellow.
|
34
|
+
ON_YELLOW = "\e[43m"
|
35
|
+
# Set the terminal's background ANSI color to blue.
|
36
|
+
ON_BLUE = "\e[44m"
|
37
|
+
# Set the terminal's background ANSI color to magenta.
|
38
|
+
ON_MAGENTA = "\e[45m"
|
39
|
+
# Set the terminal's background ANSI color to cyan.
|
40
|
+
ON_CYAN = "\e[46m"
|
41
|
+
# Set the terminal's background ANSI color to white.
|
42
|
+
ON_WHITE = "\e[47m"
|
43
|
+
|
44
|
+
# Set color by using a string or one of the defined constants. If a third
|
45
|
+
# option is set to true, it also adds bold to the string. This is based
|
46
|
+
# on Highline implementation and it automatically appends CLEAR to the end
|
47
|
+
# of the returned String.
|
48
|
+
#
|
49
|
+
def set_color(string, color, bold=false)
|
50
|
+
color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
51
|
+
bold = bold ? BOLD : ""
|
52
|
+
"#{bold}#{color}#{string}#{CLEAR}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/nerd_quiz/question.rb
CHANGED
@@ -1,28 +1,66 @@
|
|
1
1
|
module NerdQuiz
|
2
2
|
class Question
|
3
3
|
class << self
|
4
|
-
def get
|
5
|
-
self.new
|
4
|
+
def get(path)
|
5
|
+
self.new path
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
def initialize
|
10
|
-
@
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
@question = {}
|
12
|
+
@parsed = {}
|
11
13
|
end
|
12
14
|
|
13
15
|
def text
|
14
|
-
|
16
|
+
set
|
17
|
+
@question[:text]
|
15
18
|
end
|
16
19
|
|
17
20
|
def answer
|
21
|
+
set
|
18
22
|
@question[:answer]
|
19
23
|
end
|
20
24
|
|
25
|
+
def label
|
26
|
+
set
|
27
|
+
@question[:label]
|
28
|
+
end
|
29
|
+
|
21
30
|
private
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
31
|
+
|
32
|
+
def set
|
33
|
+
if @question.empty?
|
34
|
+
parse
|
35
|
+
extract_text
|
36
|
+
extract_answer
|
37
|
+
extract_label
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse
|
42
|
+
@parsed = Yajl::Parser.new.parse(File.new(@path, 'r'))["question"]
|
43
|
+
end
|
44
|
+
|
45
|
+
def extract_text
|
46
|
+
text = []
|
47
|
+
text << @parsed["text"]
|
48
|
+
(1..4).each do |i|
|
49
|
+
key = "a#{i}"
|
50
|
+
text << "#{key}) #{@parsed[key]}"
|
51
|
+
end
|
52
|
+
@question[:text] = text.join("\n")
|
53
|
+
end
|
54
|
+
|
55
|
+
def extract_answer
|
56
|
+
@question[:answer] = @parsed["right_answer"]
|
57
|
+
end
|
58
|
+
|
59
|
+
def extract_label
|
60
|
+
label = []
|
61
|
+
label << @parsed["category"]
|
62
|
+
label << @parsed["sub_category"] unless @parsed["category"] == @parsed["sub_category"]
|
63
|
+
@question[:label] = "(#{label.join(" - ")})"
|
26
64
|
end
|
27
65
|
end
|
28
66
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module NerdQuiz
|
2
|
+
class Questions
|
3
|
+
class << self
|
4
|
+
def get
|
5
|
+
self.new
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
PATTERN = File.expand_path('../../../NerdPursuit/questions/*.json', __FILE__)
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@questions = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def pop
|
16
|
+
questions.pop
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def questions
|
22
|
+
find if @questions.empty?
|
23
|
+
@questions
|
24
|
+
end
|
25
|
+
|
26
|
+
def find
|
27
|
+
Dir.glob(PATTERN).sample(NerdQuiz::DEFAULT_NUMBER_OF_QUESTIONS).each do |q|
|
28
|
+
@questions << NerdQuiz::Question.get(q)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/nerd_quiz/quiz.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module NerdQuiz
|
2
2
|
class Quiz
|
3
|
+
include NerdQuiz::Color
|
3
4
|
|
4
5
|
def initialize(input, output, scorecard)
|
5
6
|
@input = input
|
@@ -8,6 +9,7 @@ module NerdQuiz
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def run
|
12
|
+
questions
|
11
13
|
start
|
12
14
|
while @scorecard.incomplete?
|
13
15
|
ask
|
@@ -18,16 +20,17 @@ module NerdQuiz
|
|
18
20
|
|
19
21
|
private
|
20
22
|
def ask
|
21
|
-
@output.puts "Question #{@scorecard.next_question + 1}:"
|
23
|
+
@output.puts set_color("Question #{@scorecard.next_question + 1} #{label}:", :blue)
|
22
24
|
@output.puts question
|
23
25
|
end
|
24
26
|
|
25
27
|
def listen
|
26
28
|
if reply == answer
|
27
|
-
@output.puts 'Right!'
|
29
|
+
@output.puts set_color('Right!', :green, true)
|
28
30
|
@scorecard.right_answer!
|
29
31
|
else
|
30
|
-
@output.puts 'Wrong!'
|
32
|
+
@output.puts set_color('Wrong!', :red, true)
|
33
|
+
@output.puts set_color('You should have answered ', :red) + set_color(answer, :red, true)
|
31
34
|
@scorecard.wrong_answer!
|
32
35
|
end
|
33
36
|
end
|
@@ -37,16 +40,24 @@ module NerdQuiz
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def start
|
40
|
-
@output.puts 'Welcome to Nerd Quiz'
|
43
|
+
@output.puts set_color('Welcome to Nerd Quiz', :blue)
|
41
44
|
end
|
42
45
|
|
43
46
|
def over
|
44
|
-
@output.puts 'Thanks For Playing!'
|
45
|
-
@output.puts @scorecard.score
|
47
|
+
@output.puts set_color('Thanks For Playing!', :blue)
|
48
|
+
@output.puts set_color("Final Score #{@scorecard.score}", :yellow)
|
49
|
+
end
|
50
|
+
|
51
|
+
def questions
|
52
|
+
@questions = NerdQuiz::Questions.get
|
53
|
+
end
|
54
|
+
|
55
|
+
def label
|
56
|
+
@question = @questions.pop
|
57
|
+
@question.label
|
46
58
|
end
|
47
59
|
|
48
60
|
def question
|
49
|
-
@question = NerdQuiz::Question.get
|
50
61
|
@question.text
|
51
62
|
end
|
52
63
|
|
data/lib/nerd_quiz/version.rb
CHANGED
data/lib/nerd_quiz.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__)) if ARGV[0] == 'dev'
|
2
|
+
require 'yajl'
|
2
3
|
require 'nerd_quiz/version'
|
4
|
+
require 'nerd_quiz/color'
|
3
5
|
require 'nerd_quiz/quiz'
|
4
6
|
require 'nerd_quiz/question'
|
7
|
+
require 'nerd_quiz/questions'
|
5
8
|
require 'nerd_quiz/scorecard'
|
6
9
|
|
7
10
|
module NerdQuiz
|
data/nerd_quiz.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.license = 'MIT'
|
23
23
|
|
24
24
|
# specify any dependencies here; for example:
|
25
|
+
s.add_dependency 'yajl-ruby'
|
26
|
+
s.add_development_dependency 'rake'
|
25
27
|
s.add_development_dependency 'rspec'
|
26
|
-
s.add_development_dependency 'cucumber'
|
27
28
|
end
|
@@ -3,7 +3,18 @@ require 'spec_helper'
|
|
3
3
|
module NerdQuiz
|
4
4
|
describe Question do
|
5
5
|
describe '.get' do
|
6
|
-
|
6
|
+
let(:path) { "/Users/simeon/Projects/nerd_quiz/NerdPursuit/questions/yo_dawg.json" }
|
7
|
+
let(:text) do
|
8
|
+
"Yo dawg, I herd you like ...\n" +
|
9
|
+
"a1) music, so I put a tape in your pants so you can listen while you sleep!\n" +
|
10
|
+
"a2) cars, so I put a car in your car so you can drive while you drive!\n" +
|
11
|
+
"a3) cheating, so I put a bread in your bag so you can run while you eat!\n" +
|
12
|
+
"a4) drinking, so I put a hat in your pocket so you can listen while you dance!"
|
13
|
+
end
|
14
|
+
let(:answer) { "a2" }
|
15
|
+
let(:label) { "(culture)" }
|
16
|
+
|
17
|
+
subject { Question.get(path) }
|
7
18
|
|
8
19
|
it 'gets a new question' do
|
9
20
|
subject.should be_a Question
|
@@ -12,11 +23,19 @@ module NerdQuiz
|
|
12
23
|
it 'which includes the question text' do
|
13
24
|
subject.should respond_to :text
|
14
25
|
subject.text.should be_a String
|
26
|
+
subject.text.should eq(text)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'and the the label text' do
|
30
|
+
subject.should respond_to :label
|
31
|
+
subject.label.should be_a String
|
32
|
+
subject.label.should eq(label)
|
15
33
|
end
|
16
34
|
|
17
35
|
it 'and the the answer text' do
|
18
36
|
subject.should respond_to :answer
|
19
37
|
subject.answer.should be_a String
|
38
|
+
subject.answer.should eq(answer)
|
20
39
|
end
|
21
40
|
end
|
22
41
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module NerdQuiz
|
4
|
+
describe Questions do
|
5
|
+
subject { Questions.get }
|
6
|
+
|
7
|
+
describe '.get' do
|
8
|
+
it 'gets a new question' do
|
9
|
+
subject.should be_a Questions
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#pop' do
|
14
|
+
it 'returns a Question' do
|
15
|
+
subject.pop.should be_a Question
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'and it decreases the number of questions by one' do
|
19
|
+
expect {
|
20
|
+
subject.pop
|
21
|
+
}.to change { subject.send(:questions).size }.by(-1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#find' do
|
26
|
+
it 'finds questions from NerdPursuit' do
|
27
|
+
Dir.should_receive(:glob).with(Questions::PATTERN).once.and_return([])
|
28
|
+
subject.pop
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'loads found questions' do
|
32
|
+
questions = Questions.get
|
33
|
+
questions.send(:questions).size.should eq(NerdQuiz::DEFAULT_NUMBER_OF_QUESTIONS)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/nerd_quiz/quiz_spec.rb
CHANGED
@@ -4,12 +4,16 @@ module NerdQuiz
|
|
4
4
|
describe Quiz do
|
5
5
|
let(:question) { 'What is the answer to life, the universe and everything?' }
|
6
6
|
let(:answer) { '42' }
|
7
|
+
let(:label) { '(culture)' }
|
7
8
|
let(:output) { double('output').as_null_object }
|
8
9
|
let(:input) { double('input').as_null_object }
|
9
10
|
let(:scorecard) { NerdQuiz::Scorecard.new }
|
10
11
|
subject { Quiz.new(input, output, scorecard) }
|
11
12
|
|
12
13
|
before(:each) do
|
14
|
+
subject.stub(:questions).and_return(nil)
|
15
|
+
subject.stub(:label).and_return(label)
|
16
|
+
subject.stub(:question).and_return(question)
|
13
17
|
subject.stub(:answer).and_return(answer)
|
14
18
|
end
|
15
19
|
|
@@ -19,8 +23,12 @@ module NerdQuiz
|
|
19
23
|
end
|
20
24
|
|
21
25
|
describe '#run' do
|
26
|
+
it 'loads all the questions' do
|
27
|
+
subject.should_receive(:questions).once
|
28
|
+
end
|
29
|
+
|
22
30
|
it 'sends a welcome message' do
|
23
|
-
output.should_receive(:puts).with(
|
31
|
+
output.should_receive(:puts).with("\e[34mWelcome to Nerd Quiz\e[0m")
|
24
32
|
end
|
25
33
|
|
26
34
|
it 'asks all the questions' do
|
@@ -29,7 +37,7 @@ module NerdQuiz
|
|
29
37
|
|
30
38
|
it 'labels each question' do
|
31
39
|
(1..10).each do |i|
|
32
|
-
output.should_receive(:puts).with("
|
40
|
+
output.should_receive(:puts).with("\e[34mQuestion #{i} (culture):\e[0m").once
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
@@ -48,7 +56,7 @@ module NerdQuiz
|
|
48
56
|
end
|
49
57
|
|
50
58
|
it 'notifies it received the right answer' do
|
51
|
-
output.should_receive(:puts).with(
|
59
|
+
output.should_receive(:puts).with("\e[1m\e[32mRight!\e[0m").exactly(10).times
|
52
60
|
end
|
53
61
|
|
54
62
|
it 'tallies the right answer' do
|
@@ -62,7 +70,11 @@ module NerdQuiz
|
|
62
70
|
end
|
63
71
|
|
64
72
|
it 'notifies it received the wrong answer' do
|
65
|
-
output.should_receive(:puts).with(
|
73
|
+
output.should_receive(:puts).with("\e[1m\e[31mWrong!\e[0m").exactly(10).times
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'and displays the right answer' do
|
77
|
+
output.should_receive(:puts).with("\e[31mYou should have answered \e[0m\e[1m\e[31m#{answer}\e[0m").exactly(10).times
|
66
78
|
end
|
67
79
|
|
68
80
|
it 'tallies the wrong answer' do
|
@@ -72,12 +84,12 @@ module NerdQuiz
|
|
72
84
|
end
|
73
85
|
|
74
86
|
it 'proclaims the quiz over' do
|
75
|
-
output.should_receive(:puts).with(
|
87
|
+
output.should_receive(:puts).with("\e[34mThanks For Playing!\e[0m")
|
76
88
|
end
|
77
89
|
|
78
90
|
it 'displays the final score' do
|
79
91
|
scorecard.stub(:score).and_return('10/10')
|
80
|
-
output.should_receive(:puts).with(
|
92
|
+
output.should_receive(:puts).with("\e[33mFinal Score 10/10\e[0m")
|
81
93
|
end
|
82
94
|
end
|
83
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nerd_quiz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: yajl-ruby
|
16
|
+
requirement: &70253598082120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70253598082120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70253598080540 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
@@ -21,10 +32,10 @@ dependencies:
|
|
21
32
|
version: '0'
|
22
33
|
type: :development
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *70253598080540
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
37
|
+
name: rspec
|
38
|
+
requirement: &70253598095040 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,7 +43,7 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70253598095040
|
36
47
|
description: Test your nerd skills by answering NerdPursuit questions!
|
37
48
|
email:
|
38
49
|
- sfw@simeonfosterwillbanks.com
|
@@ -42,6 +53,7 @@ extensions: []
|
|
42
53
|
extra_rdoc_files: []
|
43
54
|
files:
|
44
55
|
- .gitignore
|
56
|
+
- .gitmodules
|
45
57
|
- .rspec
|
46
58
|
- Gemfile
|
47
59
|
- LICENSE
|
@@ -49,20 +61,16 @@ files:
|
|
49
61
|
- Rakefile
|
50
62
|
- STORIES.md
|
51
63
|
- bin/nquiz
|
52
|
-
- features/nerd_quiz_asks_questions.feature
|
53
|
-
- features/nerd_quiz_ends_quiz.feature
|
54
|
-
- features/nerd_quizer_answers_questions.feature
|
55
|
-
- features/nerd_quizer_starts_quiz.feature
|
56
|
-
- features/step_definitions/nerd_quiz_steps.rb
|
57
|
-
- features/support/env.rb
|
58
|
-
- features/support/output.rb
|
59
64
|
- lib/nerd_quiz.rb
|
65
|
+
- lib/nerd_quiz/color.rb
|
60
66
|
- lib/nerd_quiz/question.rb
|
67
|
+
- lib/nerd_quiz/questions.rb
|
61
68
|
- lib/nerd_quiz/quiz.rb
|
62
69
|
- lib/nerd_quiz/scorecard.rb
|
63
70
|
- lib/nerd_quiz/version.rb
|
64
71
|
- nerd_quiz.gemspec
|
65
72
|
- spec/nerd_quiz/question_spec.rb
|
73
|
+
- spec/nerd_quiz/questions_spec.rb
|
66
74
|
- spec/nerd_quiz/quiz_spec.rb
|
67
75
|
- spec/nerd_quiz/scorecard_spec.rb
|
68
76
|
- spec/spec_helper.rb
|
@@ -85,6 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
93
|
- - ! '>='
|
86
94
|
- !ruby/object:Gem::Version
|
87
95
|
version: '0'
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
hash: 513410798132664069
|
88
99
|
requirements: []
|
89
100
|
rubyforge_project: nerd_quiz
|
90
101
|
rubygems_version: 1.8.11
|
@@ -92,14 +103,8 @@ signing_key:
|
|
92
103
|
specification_version: 3
|
93
104
|
summary: A ruby gem which implements a command line interface to NerdPursuit questions
|
94
105
|
test_files:
|
95
|
-
- features/nerd_quiz_asks_questions.feature
|
96
|
-
- features/nerd_quiz_ends_quiz.feature
|
97
|
-
- features/nerd_quizer_answers_questions.feature
|
98
|
-
- features/nerd_quizer_starts_quiz.feature
|
99
|
-
- features/step_definitions/nerd_quiz_steps.rb
|
100
|
-
- features/support/env.rb
|
101
|
-
- features/support/output.rb
|
102
106
|
- spec/nerd_quiz/question_spec.rb
|
107
|
+
- spec/nerd_quiz/questions_spec.rb
|
103
108
|
- spec/nerd_quiz/quiz_spec.rb
|
104
109
|
- spec/nerd_quiz/scorecard_spec.rb
|
105
110
|
- spec/spec_helper.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
Feature: Nerd quiz asks questions
|
2
|
-
|
3
|
-
As a Nerd Quiz
|
4
|
-
I want to ask questions
|
5
|
-
So that I can accept answers
|
6
|
-
|
7
|
-
Scenario: ask question
|
8
|
-
Given I am conducting a quiz
|
9
|
-
When I ask the question "What is the acronym JSON an abbreviation for?"
|
10
|
-
And A quizer answers "JavaScript Object Notation"
|
11
|
-
Then I should mark the answer as "JavaScript Object Notation"
|
@@ -1,23 +0,0 @@
|
|
1
|
-
Feature: Nerd quiz ends a quiz after 10 questions
|
2
|
-
|
3
|
-
As a Nerd Quiz
|
4
|
-
I want to end the quiz after 10 questions
|
5
|
-
So that I may tally the final score
|
6
|
-
And either exit or start a new quiz
|
7
|
-
|
8
|
-
Scenario: 10th question answered
|
9
|
-
Given I receive an answered question
|
10
|
-
And the question is the 10th
|
11
|
-
When I score the question
|
12
|
-
Then I complete the quiz
|
13
|
-
And I ask the quizer, "Would you like to take another quiz?"
|
14
|
-
|
15
|
-
Scenario: 10 questions answered correctly
|
16
|
-
Given I receive 10 correct answers
|
17
|
-
When I complete the quiz
|
18
|
-
Then I display "100% correct"
|
19
|
-
|
20
|
-
Scenario: 8 questions answered correctly
|
21
|
-
Given I receive 8 correct answers
|
22
|
-
When I complete the quiz
|
23
|
-
Then I display "80% correct"
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Feature: Nerd quizer answers questions
|
2
|
-
|
3
|
-
As a Nerd Quizer
|
4
|
-
I want to answer questions
|
5
|
-
So that I can increase my final score
|
6
|
-
|
7
|
-
Scenario: answer question correctly
|
8
|
-
Given I am asked the question "What is the acronym JSON an abbreviation for?"
|
9
|
-
When I answer "JavaScript Object Notation"
|
10
|
-
Then I should see my score increase by 1
|
11
|
-
|
12
|
-
Scenario: answer question incorrectly
|
13
|
-
Given I am asked the question "What is the acronym HTTP an abbreviation for?"
|
14
|
-
When I answer "High Tea Today Please"
|
15
|
-
Then I do not see my score change
|
@@ -1,11 +0,0 @@
|
|
1
|
-
Feature: Nerd quizer starts a quiz
|
2
|
-
|
3
|
-
As a nerd quizer
|
4
|
-
I want to start a quiz
|
5
|
-
So that I can test my nerd cred
|
6
|
-
|
7
|
-
Scenario: start quiz
|
8
|
-
Given I am not yet taking a quiz
|
9
|
-
When I start a new quiz
|
10
|
-
Then I should see "Welcome to Nerd Quiz"
|
11
|
-
And I should see "Question 1:"
|
@@ -1,75 +0,0 @@
|
|
1
|
-
Given /^I am not yet taking a quiz$/ do
|
2
|
-
end
|
3
|
-
|
4
|
-
When /^I start a new quiz$/ do
|
5
|
-
NerdQuiz::Quiz.new(output).start
|
6
|
-
end
|
7
|
-
|
8
|
-
Then /^I should see "([^"]*)"$/ do |message|
|
9
|
-
output.messages.should include message
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
Given /^I am conducting a quiz$/ do
|
14
|
-
pending # express the regexp above with the code you wish you had
|
15
|
-
end
|
16
|
-
|
17
|
-
When /^I ask the question "([^"]*)"$/ do |arg1|
|
18
|
-
pending # express the regexp above with the code you wish you had
|
19
|
-
end
|
20
|
-
|
21
|
-
When /^A quizer answers "([^"]*)"$/ do |arg1|
|
22
|
-
pending # express the regexp above with the code you wish you had
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^I should mark the answer as "([^"]*)"$/ do |arg1|
|
26
|
-
pending # express the regexp above with the code you wish you had
|
27
|
-
end
|
28
|
-
|
29
|
-
Given /^I receive an answered question$/ do
|
30
|
-
pending # express the regexp above with the code you wish you had
|
31
|
-
end
|
32
|
-
|
33
|
-
Given /^the question is the (\d+)th$/ do |arg1|
|
34
|
-
pending # express the regexp above with the code you wish you had
|
35
|
-
end
|
36
|
-
|
37
|
-
When /^I score the question$/ do
|
38
|
-
pending # express the regexp above with the code you wish you had
|
39
|
-
end
|
40
|
-
|
41
|
-
Then /^I complete the quiz$/ do
|
42
|
-
pending # express the regexp above with the code you wish you had
|
43
|
-
end
|
44
|
-
|
45
|
-
Then /^I ask the quizer, "([^"]*)"$/ do |arg1|
|
46
|
-
pending # express the regexp above with the code you wish you had
|
47
|
-
end
|
48
|
-
|
49
|
-
Given /^I receive (\d+) correct answers$/ do |arg1|
|
50
|
-
pending # express the regexp above with the code you wish you had
|
51
|
-
end
|
52
|
-
|
53
|
-
When /^I complete the quiz$/ do
|
54
|
-
pending # express the regexp above with the code you wish you had
|
55
|
-
end
|
56
|
-
|
57
|
-
Then /^I display "([^"]*)"$/ do |arg1|
|
58
|
-
pending # express the regexp above with the code you wish you had
|
59
|
-
end
|
60
|
-
|
61
|
-
Given /^I am asked the question "([^"]*)"$/ do |arg1|
|
62
|
-
pending # express the regexp above with the code you wish you had
|
63
|
-
end
|
64
|
-
|
65
|
-
When /^I answer "([^"]*)"$/ do |arg1|
|
66
|
-
pending # express the regexp above with the code you wish you had
|
67
|
-
end
|
68
|
-
|
69
|
-
Then /^I should see my score increase by (\d+)$/ do |arg1|
|
70
|
-
pending # express the regexp above with the code you wish you had
|
71
|
-
end
|
72
|
-
|
73
|
-
Then /^I do not see my score change$/ do
|
74
|
-
pending # express the regexp above with the code you wish you had
|
75
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative '../../lib/nerd_quiz'
|