blob: fce07622965dab072ad43ed122821669cb44298a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
Given /^a question "([^\"]*)"$/ do |title|
@question = Question.find_by_title(title)
if @question.nil?
@question = Question.create!( :title => title)
end
if @question.content.nil?
QuestionContentText.create! :question => @question, :content => "fake"
@question.reload
end
end
Given /^a question "([^\"]*)" in category "([^\"]*)"$/ do |title, category|
Given "a question \"#{title}\""
Given "a question category \"#{category}\""
@question.question_category = @question_category
@question.save!
end
Given /^a question "([^\"]*)" in group "([^\"]*)"$/ do |title, group|
Given "a question \"#{title}\""
Given "question group \"#{group}\""
@question.question_group = @question_group
@question.save!
end
Given /^following questions:$/ do |table|
for question in table.raw
if question.size == 1
Given "a question \"#{question[0]}\""
elsif question.size == 2
Given "a question \"#{question[0]}\" in category \"#{question[1]}\""
elsif question.size == 3
Given "a question \"#{question[0]}\" in category \"#{question[1]}\""
Given "a question \"#{question[0]}\" in group \"#{question[2]}\""
else
fail "Each row of table should have one or two columns"
end
end
end
Then /^I should see following:$/ do |table|
for txt in table.raw.flatten
Then "I should see \"#{txt}\""
end
end
Then /^I should not see following:$/ do |table|
for txt in table.raw.flatten
Then "I should not see \"#{txt}\""
end
end
Given /^question "([^"]*)" has no content$/ do |title|
Given "a question \"#{title}\""
@question.content._?.destroy
end
|