surveyor 0.8.0 → 0.9.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.
Files changed (45) hide show
  1. data/README.md +22 -5
  2. data/VERSION +1 -1
  3. data/app/models/dependency.rb +16 -32
  4. data/app/models/question.rb +1 -1
  5. data/app/models/question_group.rb +1 -1
  6. data/app/models/response.rb +1 -4
  7. data/app/models/response_set.rb +4 -3
  8. data/app/models/survey.rb +0 -1
  9. data/app/models/validation.rb +20 -0
  10. data/app/models/validation_condition.rb +19 -17
  11. data/generators/surveyor/surveyor_generator.rb +9 -5
  12. data/generators/surveyor/templates/migrate/add_display_order_to_surveys.rb +9 -0
  13. data/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +15 -4
  14. data/lib/surveyor.rb +16 -0
  15. data/script/surveyor/answer.rb +32 -55
  16. data/script/surveyor/base.rb +61 -0
  17. data/script/surveyor/dependency.rb +4 -41
  18. data/script/surveyor/dependency_condition.rb +13 -38
  19. data/script/surveyor/question.rb +16 -50
  20. data/script/surveyor/question_group.rb +7 -19
  21. data/script/surveyor/specs/answer_spec.rb +15 -52
  22. data/script/surveyor/specs/question_spec.rb +37 -85
  23. data/script/surveyor/specs/spec_helper.rb +6 -0
  24. data/script/surveyor/specs/survey_section_spec.rb +23 -0
  25. data/script/surveyor/specs/validation_condition_spec.rb +20 -0
  26. data/script/surveyor/specs/validation_spec.rb +20 -0
  27. data/script/surveyor/survey.rb +10 -85
  28. data/script/surveyor/survey_parser.rb +160 -38
  29. data/script/surveyor/survey_section.rb +6 -130
  30. data/script/surveyor/validation.rb +19 -0
  31. data/script/surveyor/validation_condition.rb +19 -0
  32. data/spec/lib/surveyor_spec.rb +44 -0
  33. data/spec/models/dependency_spec.rb +9 -16
  34. data/spec/models/question_group_spec.rb +3 -3
  35. data/spec/models/question_spec.rb +1 -1
  36. data/spec/models/validation_condition_spec.rb +29 -0
  37. data/spec/models/validation_spec.rb +27 -0
  38. data/spec/spec_helper.rb +0 -2
  39. data/surveyor.gemspec +12 -7
  40. metadata +12 -7
  41. data/lib/tiny_code.rb +0 -58
  42. data/script/surveyor/columnizer.rb +0 -36
  43. data/script/surveyor/specs/question_dependency_spec.rb +0 -46
  44. data/script/surveyor/specs/question_group_spec.rb +0 -9
  45. data/script/surveyor/specs/section_spec.rb +0 -58
@@ -1,46 +0,0 @@
1
- require File.dirname(__FILE__) + '/../question_dependency'
2
-
3
- describe QuestionDependency, " when first created" do
4
-
5
- ID = 1
6
- QUESTION_ID = 2
7
- DEPENDENT_QUESTION_ID = 3
8
- DEPENDENT_GROUP_ID = nil
9
- DEPENDENCY_TYPE_1 = {:dependency_type => :response_count, :conditional => :one_or_more }
10
- DEPENDENCY_TYPE_2 = {:dependency_type => :response_answer, :conditional => :selected, :answer_id => 1}
11
- DEPENDENCY_TYPE_3 = {:dependency_type => :response_value, :condition => :not_zero}
12
-
13
- before do
14
- @dependent_1 = QuestionDependency.new(ID, QUESTION_ID, DEPENDENT_QUESTION_ID, DEPENDENT_GROUP_ID, DEPENDENCY_TYPE_1)
15
- @dependent_2 = QuestionDependency.new(ID, QUESTION_ID, DEPENDENT_QUESTION_ID, DEPENDENT_GROUP_ID, DEPENDENCY_TYPE_2)
16
- @dependent_3 = QuestionDependency.new(ID, QUESTION_ID, DEPENDENT_QUESTION_ID, DEPENDENT_GROUP_ID, DEPENDENCY_TYPE_3)
17
-
18
- end
19
-
20
- it "should set initialization paramerters properly" do
21
- # Checking both type1 and type2 dependencies
22
- @dependent_1.id.should == ID
23
- @dependent_1.question_id.should == QUESTION_ID
24
- @dependent_1.dependent_question_id.should == DEPENDENT_QUESTION_ID
25
- @dependent_1.dependency_type.should == DEPENDENCY_TYPE_1[:dependency_type]
26
- @dependent_1.conditional.should == DEPENDENCY_TYPE_1[:conditional]
27
-
28
- @dependent_2.id.should == ID
29
- @dependent_2.question_id.should == QUESTION_ID
30
- @dependent_2.dependent_question_id.should == DEPENDENT_QUESTION_ID
31
- @dependent_2.dependency_type.should == DEPENDENCY_TYPE_2[:dependency_type]
32
- @dependent_2.conditional.should == DEPENDENCY_TYPE_2[:conditional]
33
- @dependent_2.answer_id.should == DEPENDENCY_TYPE_2[:answer_id]
34
-
35
- @dependent_3.id.should == ID
36
- @dependent_3.question_id.should == QUESTION_ID
37
- @dependent_3.dependent_question_id.should == DEPENDENT_QUESTION_ID
38
- @dependent_3.dependency_type.should == DEPENDENCY_TYPE_3[:dependency_type]
39
- @dependent_3.conditional.should == DEPENDENCY_TYPE_3[:conditional]
40
- end
41
-
42
- it "should output current state to yml" do
43
- @ans.should.respond_to?(:to_yml)
44
- end
45
-
46
- end
@@ -1,9 +0,0 @@
1
- require File.dirname(__FILE__) + '/../question_group'
2
-
3
- describe QuestionGroup, " when first created" do
4
-
5
- it "should do stuff" do
6
- pending
7
- end
8
-
9
- end
@@ -1,58 +0,0 @@
1
- require File.dirname(__FILE__) + '/../section'
2
-
3
- describe Section, " when first created" do
4
-
5
- TEST_TITLE = "Demographics"
6
- TEST_SECTION = :B
7
-
8
- before do
9
- @section = Section.new(1,TEST_SECTION,TEST_TITLE)
10
- end
11
-
12
- it "should accept questions" do
13
- mock_question = mock("question")
14
- @section.questions.size.should eql(0)
15
- @section.add_question(mock_question)
16
- @section.questions.size.should eql(1)
17
- end
18
-
19
- it "should output current state to code" do
20
- @section.should.respond_to?(:to_code)
21
- end
22
-
23
- end
24
-
25
- describe Section, " when it contains data" do
26
-
27
- before do # Mocking up some questions
28
- @section = Section.new(1,TEST_SECTION,TEST_TITLE)
29
- mq1 = mock("question")
30
- mq1.stub!(:context_id).and_return("B1")
31
- @section.add_question(mq1)
32
-
33
- mq2 = mock("question")
34
- mq2.stub!(:context_id).and_return("B2")
35
- @section.add_question(mq2)
36
-
37
- mq3 = mock("question")
38
- mq3.stub!(:context_id).and_return("B3")
39
- @section.add_question(mq3)
40
-
41
- end
42
-
43
- it "should have added the test questions correctly" do
44
- @section.questions.length.should eql(3)
45
- end
46
-
47
- it "should have a title" do
48
- @section.title.should eql(TEST_TITLE)
49
- end
50
-
51
- it "should find a question by context_id" do
52
- pending # yoon: commented out during dsl refactoring
53
- q_to_find = @section.find_question_by_context_id("B2")
54
- q_to_find.should_not eql(nil)
55
- q_to_find.context_id.should eql("B2")
56
- end
57
-
58
- end