jakewendt-surveyor 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +285 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/app/controllers/surveyor_controller.rb +142 -0
- data/app/helpers/survey_form_builder.rb +37 -0
- data/app/helpers/surveyor_helper.rb +67 -0
- data/app/models/answer.rb +23 -0
- data/app/models/dependency.rb +50 -0
- data/app/models/dependency_condition.rb +47 -0
- data/app/models/question.rb +54 -0
- data/app/models/question_group.rb +33 -0
- data/app/models/response.rb +94 -0
- data/app/models/response_set.rb +316 -0
- data/app/models/survey.rb +172 -0
- data/app/models/survey_section.rb +18 -0
- data/app/models/validation.rb +38 -0
- data/app/models/validation_condition.rb +47 -0
- data/app/views/layouts/surveyor_default.html.erb +13 -0
- data/app/views/partials/_answer.html.haml +58 -0
- data/app/views/partials/_question.html.haml +80 -0
- data/app/views/partials/_question_group.html.haml +39 -0
- data/app/views/surveyor/edit.html.haml +38 -0
- data/app/views/surveyor/new.html.haml +16 -0
- data/app/views/surveyor/show.html.haml +12 -0
- data/config/routes.rb +11 -0
- data/features/step_definitions/surveyor_steps.rb +7 -0
- data/features/step_definitions/web_steps.rb +273 -0
- data/features/support/env.rb +57 -0
- data/features/support/paths.rb +25 -0
- data/features/surveyor.feature +11 -0
- data/generators/extend_surveyor/extend_surveyor_generator.rb +22 -0
- data/generators/extend_surveyor/templates/EXTENDING_SURVEYOR +17 -0
- data/generators/extend_surveyor/templates/extensions/survey_extensions.rb +24 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_controller_extensions.rb +28 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_custom.html.erb +13 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_helper_extensions.rb +17 -0
- data/generators/surveyor/surveyor_generator.rb +67 -0
- data/generators/surveyor/templates/README +10 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png +0 -0
- data/generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js +201 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js +3549 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js +7616 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.form.js +637 -0
- data/generators/surveyor/templates/assets/javascripts/surveyor.js +47 -0
- data/generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css +71 -0
- data/generators/surveyor/templates/assets/stylesheets/reset.css +50 -0
- data/generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass +243 -0
- data/generators/surveyor/templates/assets/stylesheets/surveyor.css +235 -0
- data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +851 -0
- data/generators/surveyor/templates/initializers/haml.rb +8 -0
- data/generators/surveyor/templates/initializers/surveyor.rb +10 -0
- data/generators/surveyor/templates/migrate/add_correct_answer_id_to_questions.rb +9 -0
- data/generators/surveyor/templates/migrate/add_display_order_to_surveys.rb +9 -0
- data/generators/surveyor/templates/migrate/add_index_to_response_sets.rb +9 -0
- data/generators/surveyor/templates/migrate/add_index_to_surveys.rb +9 -0
- data/generators/surveyor/templates/migrate/add_manual_numbering.rb +11 -0
- data/generators/surveyor/templates/migrate/add_unique_indicies.rb +17 -0
- data/generators/surveyor/templates/migrate/create_answers.rb +37 -0
- data/generators/surveyor/templates/migrate/create_dependencies.rb +22 -0
- data/generators/surveyor/templates/migrate/create_dependency_conditions.rb +29 -0
- data/generators/surveyor/templates/migrate/create_question_groups.rb +27 -0
- data/generators/surveyor/templates/migrate/create_questions.rb +36 -0
- data/generators/surveyor/templates/migrate/create_response_sets.rb +22 -0
- data/generators/surveyor/templates/migrate/create_responses.rb +33 -0
- data/generators/surveyor/templates/migrate/create_survey_sections.rb +29 -0
- data/generators/surveyor/templates/migrate/create_surveys.rb +31 -0
- data/generators/surveyor/templates/migrate/create_validation_conditions.rb +32 -0
- data/generators/surveyor/templates/migrate/create_validations.rb +20 -0
- data/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +218 -0
- data/generators/surveyor/templates/tasks/surveyor.rb +4 -0
- data/generators/test_surveyor/templates/TESTING_SURVEYOR +0 -0
- data/generators/test_surveyor/templates/environments/cucumber.rb +21 -0
- data/generators/test_surveyor/test_surveyor_generator.rb +15 -0
- data/jakewendt-surveyor.gemspec +212 -0
- data/lib/fixtures_extensions.rb +6 -0
- data/lib/jakewendt-surveyor.rb +1 -0
- data/lib/surveyor.rb +44 -0
- data/lib/surveyor/acts_as_response.rb +33 -0
- data/lib/surveyor/config.rb +45 -0
- data/lib/tasks/surveyor_tasks.rake +33 -0
- data/lib/xml_formatter.rb +12 -0
- data/rails/init.rb +1 -0
- data/script/surveyor/answer.rb +54 -0
- data/script/surveyor/base.rb +77 -0
- data/script/surveyor/dependency.rb +13 -0
- data/script/surveyor/dependency_condition.rb +40 -0
- data/script/surveyor/parser.rb +207 -0
- data/script/surveyor/question.rb +37 -0
- data/script/surveyor/question_group.rb +26 -0
- data/script/surveyor/specs/answer_spec.rb +29 -0
- data/script/surveyor/specs/question_spec.rb +63 -0
- data/script/surveyor/specs/spec_helper.rb +7 -0
- data/script/surveyor/specs/survey_section_spec.rb +23 -0
- data/script/surveyor/specs/validation_condition_spec.rb +20 -0
- data/script/surveyor/specs/validation_spec.rb +20 -0
- data/script/surveyor/survey.rb +35 -0
- data/script/surveyor/survey_section.rb +21 -0
- data/script/surveyor/validation.rb +21 -0
- data/script/surveyor/validation_condition.rb +21 -0
- data/script/surveyor/whr_dsl.tmproj +244 -0
- data/spec/controllers/surveyor_controller_spec.rb +193 -0
- data/spec/factories.rb +145 -0
- data/spec/lib/surveyor_spec.rb +44 -0
- data/spec/models/answer_spec.rb +29 -0
- data/spec/models/dependency_condition_spec.rb +321 -0
- data/spec/models/dependency_spec.rb +81 -0
- data/spec/models/question_group_spec.rb +35 -0
- data/spec/models/question_spec.rb +75 -0
- data/spec/models/response_set_spec.rb +245 -0
- data/spec/models/response_spec.rb +76 -0
- data/spec/models/survey_section_spec.rb +32 -0
- data/spec/models/survey_spec.rb +71 -0
- data/spec/models/validation_condition_spec.rb +105 -0
- data/spec/models/validation_spec.rb +59 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +12 -0
- metadata +254 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe SurveySection, "when saving a survey_section" do
|
4
|
+
before(:each) do
|
5
|
+
@valid_attributes={:title => "foo", :survey_id => 2, :display_order => 4}
|
6
|
+
@survey_section = SurveySection.new(@valid_attributes)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be invalid without title" do
|
10
|
+
@survey_section.title = nil
|
11
|
+
@survey_section.should have(1).error_on(:title)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a parent survey" do
|
15
|
+
@survey_section.survey_id = nil
|
16
|
+
@survey_section.should have(1).error_on(:survey)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe SurveySection, "with questions" do
|
21
|
+
before(:each) do
|
22
|
+
@survey_section = Factory(:survey_section, :title => "Rhymes", :display_order => 4)
|
23
|
+
@q1 = @survey_section.questions.create(:text => "Peep", :display_order => 3)
|
24
|
+
@q2 = @survey_section.questions.create(:text => "Little", :display_order => 1)
|
25
|
+
@q3 = @survey_section.questions.create(:text => "Bo", :display_order => 2)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return questions sorted in display order" do
|
29
|
+
@survey_section.questions.should have(3).questions
|
30
|
+
@survey_section.questions.should == [@q2,@q3,@q1]
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
# Validations
|
4
|
+
describe Survey, "when saving a new one" do
|
5
|
+
before(:each) do
|
6
|
+
@survey = Factory(:survey, :title => "Foo")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be invalid without a title" do
|
10
|
+
@survey.title = nil
|
11
|
+
@survey.should have(1).error_on(:title)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Associations
|
16
|
+
describe Survey, "that has sections" do
|
17
|
+
before(:each) do
|
18
|
+
@survey = Factory(:survey, :title => "Foo")
|
19
|
+
@s1 = Factory(:survey_section, :survey => @survey, :title => "wise", :display_order => 2)
|
20
|
+
@s2 = Factory(:survey_section, :survey => @survey, :title => "er", :display_order => 3)
|
21
|
+
@s3 = Factory(:survey_section, :survey => @survey, :title => "bud", :display_order => 1)
|
22
|
+
@q1 = Factory(:question, :survey_section => @s1, :text => "what is wise?", :display_order => 2)
|
23
|
+
@q2 = Factory(:question, :survey_section => @s2, :text => "what is er?", :display_order => 4)
|
24
|
+
@q3 = Factory(:question, :survey_section => @s2, :text => "what is mill?", :display_order => 3)
|
25
|
+
@q4 = Factory(:question, :survey_section => @s3, :text => "what is bud?", :display_order => 1)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return survey_sections in display order" do
|
29
|
+
@survey.sections.should have(3).sections
|
30
|
+
@survey.sections.should == [@s3, @s1, @s2]
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return survey_sections_with_questions in display order" do
|
34
|
+
@survey.sections_with_questions.map(&:questions).flatten.should have(4).questions
|
35
|
+
@survey.sections_with_questions.map(&:questions).flatten.should == [@q4,@q1,@q3,@q2]
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# Methods
|
41
|
+
describe Survey do
|
42
|
+
before(:each) do
|
43
|
+
@survey = Survey.new
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be inactive by default" do
|
47
|
+
@survey.active?.should == false
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be active or active as of a certain date/time" do
|
51
|
+
@survey.inactive_at = 3.days.ago
|
52
|
+
@survey.active_at = 2.days.ago
|
53
|
+
@survey.active?.should be_true
|
54
|
+
@survey.inactive_at.should be_nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should be able to deactivate as of a certain date/time" do
|
58
|
+
@survey.active_at = 2.days.ago
|
59
|
+
@survey.inactive_at = 3.days.ago
|
60
|
+
@survey.active?.should be_false
|
61
|
+
@survey.active_at.should be_nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should activate and deactivate" do
|
65
|
+
@survey.activate!
|
66
|
+
@survey.active?.should be_true
|
67
|
+
@survey.deactivate!
|
68
|
+
@survey.active?.should be_false
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe ValidationCondition, "Class methods" do
|
4
|
+
it "should have a list of operators" do
|
5
|
+
%w(== != < > <= >= =~).each{|operator| ValidationCondition.operators.include?(operator).should be_true }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ValidationCondition do
|
10
|
+
before(:each) do
|
11
|
+
@validation_condition = Factory(:validation_condition)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be valid" do
|
15
|
+
@validation_condition.should be_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be invalid without a parent validation_id" do
|
19
|
+
@validation_condition.validation_id = nil
|
20
|
+
@validation_condition.should have(1).errors_on(:validation_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be invalid without an operator" do
|
24
|
+
@validation_condition.operator = nil
|
25
|
+
@validation_condition.should have(2).errors_on(:operator)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be invalid without a rule_key" do
|
29
|
+
@validation_condition.should be_valid
|
30
|
+
@validation_condition.rule_key = nil
|
31
|
+
@validation_condition.should_not be_valid
|
32
|
+
@validation_condition.should have(1).errors_on(:rule_key)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have unique rule_key within the context of a validation" do
|
36
|
+
@validation_condition.should be_valid
|
37
|
+
Factory(:validation_condition, :validation_id => 2, :rule_key => "2")
|
38
|
+
@validation_condition.rule_key = "2" #rule key uniquness is scoped by validation_id
|
39
|
+
@validation_condition.validation_id = 2
|
40
|
+
@validation_condition.should_not be_valid
|
41
|
+
@validation_condition.should have(1).errors_on(:rule_key)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should have an operator in ValidationCondition.operators" do
|
45
|
+
ValidationCondition.operators.each do |o|
|
46
|
+
@validation_condition.operator = o
|
47
|
+
@validation_condition.should have(0).errors_on(:operator)
|
48
|
+
end
|
49
|
+
@validation_condition.operator = "#"
|
50
|
+
@validation_condition.should have(1).error_on(:operator)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ValidationCondition, "validating responses" do
|
56
|
+
def test_var(vhash, ahash, rhash)
|
57
|
+
v = Factory(:validation_condition, vhash)
|
58
|
+
a = Factory(:answer, ahash)
|
59
|
+
r = Factory(:response, {:answer => a, :question => a.question}.merge(rhash))
|
60
|
+
return v.is_valid?(r)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should validate a response by regexp" do
|
64
|
+
test_var({:operator => "=~", :regexp => /^[a-z]{1,6}$/}, {:response_class => "string"}, {:string_value => "clear"}).should be_true
|
65
|
+
test_var({:operator => "=~", :regexp => /^[a-z]{1,6}$/}, {:response_class => "string"}, {:string_value => "foobarbaz"}).should be_false
|
66
|
+
end
|
67
|
+
it "should validate a response by integer comparison" do
|
68
|
+
test_var({:operator => ">", :integer_value => 3}, {:response_class => "integer"}, {:integer_value => 4}).should be_true
|
69
|
+
test_var({:operator => "<=", :integer_value => 256}, {:response_class => "integer"}, {:integer_value => 512}).should be_false
|
70
|
+
end
|
71
|
+
it "should validate a response by (in)equality" do
|
72
|
+
test_var({:operator => "!=", :datetime_value => Date.today + 1}, {:response_class => "date"}, {:datetime_value => Date.today}).should be_true
|
73
|
+
test_var({:operator => "==", :string_value => "foo"}, {:response_class => "string"}, {:string_value => "foo"}).should be_true
|
74
|
+
end
|
75
|
+
it "should represent itself as a hash" do
|
76
|
+
@v = Factory(:validation_condition, :rule_key => "A")
|
77
|
+
@v.stub!(:is_valid?).and_return(true)
|
78
|
+
@v.to_hash("foo").should == {:A => true}
|
79
|
+
@v.stub!(:is_valid?).and_return(false)
|
80
|
+
@v.to_hash("foo").should == {:A => false}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe ValidationCondition, "validating responses by other responses" do
|
85
|
+
def test_var(v_hash, a_hash, r_hash, ca_hash, cr_hash)
|
86
|
+
ca = Factory(:answer, ca_hash)
|
87
|
+
cr = Factory(:response, cr_hash.merge(:answer => ca, :question => ca.question))
|
88
|
+
v = Factory(:validation_condition, v_hash.merge({:question_id => ca.question.id, :answer_id => ca.id}))
|
89
|
+
a = Factory(:answer, a_hash)
|
90
|
+
r = Factory(:response, r_hash.merge(:answer => a, :question => a.question))
|
91
|
+
return v.is_valid?(r)
|
92
|
+
end
|
93
|
+
it "should validate a response by integer comparison" do
|
94
|
+
test_var({:operator => ">"}, {:response_class => "integer"}, {:integer_value => 4}, {:response_class => "integer"}, {:integer_value => 3}).should be_true
|
95
|
+
test_var({:operator => "<="}, {:response_class => "integer"}, {:integer_value => 512}, {:response_class => "integer"}, {:integer_value => 4}).should be_false
|
96
|
+
end
|
97
|
+
it "should validate a response by (in)equality" do
|
98
|
+
test_var({:operator => "!="}, {:response_class => "date"}, {:datetime_value => Date.today}, {:response_class => "date"}, {:datetime_value => Date.today + 1}).should be_true
|
99
|
+
test_var({:operator => "=="}, {:response_class => "string"}, {:string_value => "donuts"}, {:response_class => "string"}, {:string_value => "donuts"}).should be_true
|
100
|
+
end
|
101
|
+
it "should not validate a response by regexp" do
|
102
|
+
test_var({:operator => "=~"}, {:response_class => "date"}, {:datetime_value => Date.today}, {:response_class => "date"}, {:datetime_value => Date.today + 1}).should be_false
|
103
|
+
test_var({:operator => "=~"}, {:response_class => "string"}, {:string_value => "donuts"}, {:response_class => "string"}, {:string_value => "donuts"}).should be_false
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Validation do
|
4
|
+
before(:each) do
|
5
|
+
@validation = Factory(:validation)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be valid" do
|
9
|
+
@validation.should be_valid
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be invalid without a rule" do
|
13
|
+
@validation.rule = nil
|
14
|
+
@validation.should have(2).errors_on(:rule)
|
15
|
+
@validation.rule = " "
|
16
|
+
@validation.should have(1).errors_on(:rule)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be invalid without a answer_id" do
|
20
|
+
@validation.answer_id = nil
|
21
|
+
@validation.should have(1).error_on(:answer_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be invalid unless rule composed of only references and operators" do
|
25
|
+
@validation.rule = "foo"
|
26
|
+
@validation.should have(1).error_on(:rule)
|
27
|
+
@validation.rule = "1 to 2"
|
28
|
+
@validation.should have(1).error_on(:rule)
|
29
|
+
@validation.rule = "a and b"
|
30
|
+
@validation.should have(1).error_on(:rule)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
describe Validation, "reporting its status" do
|
34
|
+
def test_var(vhash, vchashes, ahash, rhash)
|
35
|
+
a = Factory(:answer, ahash)
|
36
|
+
v = Factory(:validation, {:answer => a, :rule => "A"}.merge(vhash))
|
37
|
+
vchashes.each do |vchash|
|
38
|
+
Factory(:validation_condition, {:validation => v, :rule_key => "A"}.merge(vchash))
|
39
|
+
end
|
40
|
+
rs = Factory(:response_set)
|
41
|
+
r = Factory(:response, {:answer => a, :question => a.question}.merge(rhash))
|
42
|
+
rs.responses << r
|
43
|
+
return v.is_valid?(rs)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should validate a response by integer comparison" do
|
47
|
+
test_var({:rule => "A and B"}, [{:operator => ">=", :integer_value => 0}, {:rule_key => "B", :operator => "<=", :integer_value => 120}], {:response_class => "integer"}, {:integer_value => 48}).should be_true
|
48
|
+
end
|
49
|
+
it "should validate a response by regexp" do
|
50
|
+
test_var({}, [{:operator => "=~", :regexp => /^[a-z]{1,6}$/}], {:response_class => "string"}, {:string_value => ""}).should be_false
|
51
|
+
end
|
52
|
+
it "should validate a response by (in)equality" do
|
53
|
+
# test_var({:operator => "!=", :datetime_value => Date.today + 1}, {:response_class => "date"}, {:datetime_value => Date.today}).should be_true
|
54
|
+
# test_var({:operator => "==", :answer_id => 2}, {:response_class => "answer"}, {:answer_id => 2}).should be_false
|
55
|
+
end
|
56
|
+
it "should validate a response by lookup" do
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
data/spec/rcov.opts
ADDED
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
|
3
|
+
require 'spec/autorun'
|
4
|
+
require 'spec/rails'
|
5
|
+
|
6
|
+
require File.dirname(__FILE__) + "/factories"
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
+
|
11
|
+
Spec::Runner.configure do |config|
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jakewendt-surveyor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 53
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 11
|
9
|
+
- 3
|
10
|
+
version: 0.11.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Brian Chamberlain
|
14
|
+
- Mark Yoon
|
15
|
+
- Jake Wendt
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2011-02-08 00:00:00 -08:00
|
21
|
+
default_executable:
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: haml
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
32
|
+
segments:
|
33
|
+
- 0
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description:
|
38
|
+
email: github@jake.otherinbox.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README.md
|
45
|
+
files:
|
46
|
+
- MIT-LICENSE
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- VERSION
|
50
|
+
- app/controllers/surveyor_controller.rb
|
51
|
+
- app/helpers/survey_form_builder.rb
|
52
|
+
- app/helpers/surveyor_helper.rb
|
53
|
+
- app/models/answer.rb
|
54
|
+
- app/models/dependency.rb
|
55
|
+
- app/models/dependency_condition.rb
|
56
|
+
- app/models/question.rb
|
57
|
+
- app/models/question_group.rb
|
58
|
+
- app/models/response.rb
|
59
|
+
- app/models/response_set.rb
|
60
|
+
- app/models/survey.rb
|
61
|
+
- app/models/survey_section.rb
|
62
|
+
- app/models/validation.rb
|
63
|
+
- app/models/validation_condition.rb
|
64
|
+
- app/views/layouts/surveyor_default.html.erb
|
65
|
+
- app/views/partials/_answer.html.haml
|
66
|
+
- app/views/partials/_question.html.haml
|
67
|
+
- app/views/partials/_question_group.html.haml
|
68
|
+
- app/views/surveyor/edit.html.haml
|
69
|
+
- app/views/surveyor/new.html.haml
|
70
|
+
- app/views/surveyor/show.html.haml
|
71
|
+
- config/routes.rb
|
72
|
+
- features/step_definitions/surveyor_steps.rb
|
73
|
+
- features/step_definitions/web_steps.rb
|
74
|
+
- features/support/env.rb
|
75
|
+
- features/support/paths.rb
|
76
|
+
- features/surveyor.feature
|
77
|
+
- generators/extend_surveyor/extend_surveyor_generator.rb
|
78
|
+
- generators/extend_surveyor/templates/EXTENDING_SURVEYOR
|
79
|
+
- generators/extend_surveyor/templates/extensions/survey_extensions.rb
|
80
|
+
- generators/extend_surveyor/templates/extensions/surveyor_controller_extensions.rb
|
81
|
+
- generators/extend_surveyor/templates/extensions/surveyor_custom.html.erb
|
82
|
+
- generators/extend_surveyor/templates/extensions/surveyor_helper_extensions.rb
|
83
|
+
- generators/surveyor/surveyor_generator.rb
|
84
|
+
- generators/surveyor/templates/README
|
85
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif
|
86
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif
|
87
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif
|
88
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif
|
89
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif
|
90
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif
|
91
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif
|
92
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif
|
93
|
+
- generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif
|
94
|
+
- generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif
|
95
|
+
- generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif
|
96
|
+
- generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif
|
97
|
+
- generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif
|
98
|
+
- generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif
|
99
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif
|
100
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif
|
101
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif
|
102
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif
|
103
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif
|
104
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif
|
105
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif
|
106
|
+
- generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif
|
107
|
+
- generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif
|
108
|
+
- generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif
|
109
|
+
- generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif
|
110
|
+
- generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif
|
111
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif
|
112
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif
|
113
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif
|
114
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif
|
115
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif
|
116
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif
|
117
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif
|
118
|
+
- generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif
|
119
|
+
- generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif
|
120
|
+
- generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif
|
121
|
+
- generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif
|
122
|
+
- generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif
|
123
|
+
- generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png
|
124
|
+
- generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png
|
125
|
+
- generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png
|
126
|
+
- generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png
|
127
|
+
- generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js
|
128
|
+
- generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js
|
129
|
+
- generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js
|
130
|
+
- generators/surveyor/templates/assets/javascripts/jquery.form.js
|
131
|
+
- generators/surveyor/templates/assets/javascripts/surveyor.js
|
132
|
+
- generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css
|
133
|
+
- generators/surveyor/templates/assets/stylesheets/reset.css
|
134
|
+
- generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass
|
135
|
+
- generators/surveyor/templates/assets/stylesheets/surveyor.css
|
136
|
+
- generators/surveyor/templates/assets/stylesheets/ui.theme.css
|
137
|
+
- generators/surveyor/templates/initializers/haml.rb
|
138
|
+
- generators/surveyor/templates/initializers/surveyor.rb
|
139
|
+
- generators/surveyor/templates/migrate/add_correct_answer_id_to_questions.rb
|
140
|
+
- generators/surveyor/templates/migrate/add_display_order_to_surveys.rb
|
141
|
+
- generators/surveyor/templates/migrate/add_index_to_response_sets.rb
|
142
|
+
- generators/surveyor/templates/migrate/add_index_to_surveys.rb
|
143
|
+
- generators/surveyor/templates/migrate/add_manual_numbering.rb
|
144
|
+
- generators/surveyor/templates/migrate/add_unique_indicies.rb
|
145
|
+
- generators/surveyor/templates/migrate/create_answers.rb
|
146
|
+
- generators/surveyor/templates/migrate/create_dependencies.rb
|
147
|
+
- generators/surveyor/templates/migrate/create_dependency_conditions.rb
|
148
|
+
- generators/surveyor/templates/migrate/create_question_groups.rb
|
149
|
+
- generators/surveyor/templates/migrate/create_questions.rb
|
150
|
+
- generators/surveyor/templates/migrate/create_response_sets.rb
|
151
|
+
- generators/surveyor/templates/migrate/create_responses.rb
|
152
|
+
- generators/surveyor/templates/migrate/create_survey_sections.rb
|
153
|
+
- generators/surveyor/templates/migrate/create_surveys.rb
|
154
|
+
- generators/surveyor/templates/migrate/create_validation_conditions.rb
|
155
|
+
- generators/surveyor/templates/migrate/create_validations.rb
|
156
|
+
- generators/surveyor/templates/surveys/kitchen_sink_survey.rb
|
157
|
+
- generators/surveyor/templates/tasks/surveyor.rb
|
158
|
+
- generators/test_surveyor/templates/TESTING_SURVEYOR
|
159
|
+
- generators/test_surveyor/templates/environments/cucumber.rb
|
160
|
+
- generators/test_surveyor/test_surveyor_generator.rb
|
161
|
+
- jakewendt-surveyor.gemspec
|
162
|
+
- lib/fixtures_extensions.rb
|
163
|
+
- lib/jakewendt-surveyor.rb
|
164
|
+
- lib/surveyor.rb
|
165
|
+
- lib/surveyor/acts_as_response.rb
|
166
|
+
- lib/surveyor/config.rb
|
167
|
+
- lib/tasks/surveyor_tasks.rake
|
168
|
+
- lib/xml_formatter.rb
|
169
|
+
- rails/init.rb
|
170
|
+
- script/surveyor/answer.rb
|
171
|
+
- script/surveyor/base.rb
|
172
|
+
- script/surveyor/dependency.rb
|
173
|
+
- script/surveyor/dependency_condition.rb
|
174
|
+
- script/surveyor/parser.rb
|
175
|
+
- script/surveyor/question.rb
|
176
|
+
- script/surveyor/question_group.rb
|
177
|
+
- script/surveyor/specs/answer_spec.rb
|
178
|
+
- script/surveyor/specs/question_spec.rb
|
179
|
+
- script/surveyor/specs/spec_helper.rb
|
180
|
+
- script/surveyor/specs/survey_section_spec.rb
|
181
|
+
- script/surveyor/specs/validation_condition_spec.rb
|
182
|
+
- script/surveyor/specs/validation_spec.rb
|
183
|
+
- script/surveyor/survey.rb
|
184
|
+
- script/surveyor/survey_section.rb
|
185
|
+
- script/surveyor/validation.rb
|
186
|
+
- script/surveyor/validation_condition.rb
|
187
|
+
- script/surveyor/whr_dsl.tmproj
|
188
|
+
- spec/controllers/surveyor_controller_spec.rb
|
189
|
+
- spec/factories.rb
|
190
|
+
- spec/lib/surveyor_spec.rb
|
191
|
+
- spec/models/answer_spec.rb
|
192
|
+
- spec/models/dependency_condition_spec.rb
|
193
|
+
- spec/models/dependency_spec.rb
|
194
|
+
- spec/models/question_group_spec.rb
|
195
|
+
- spec/models/question_spec.rb
|
196
|
+
- spec/models/response_set_spec.rb
|
197
|
+
- spec/models/response_spec.rb
|
198
|
+
- spec/models/survey_section_spec.rb
|
199
|
+
- spec/models/survey_spec.rb
|
200
|
+
- spec/models/validation_condition_spec.rb
|
201
|
+
- spec/models/validation_spec.rb
|
202
|
+
- spec/rcov.opts
|
203
|
+
- spec/spec.opts
|
204
|
+
- spec/spec_helper.rb
|
205
|
+
has_rdoc: true
|
206
|
+
homepage: http://github.com/jakewendt/surveyor
|
207
|
+
licenses: []
|
208
|
+
|
209
|
+
post_install_message:
|
210
|
+
rdoc_options: []
|
211
|
+
|
212
|
+
require_paths:
|
213
|
+
- lib
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
none: false
|
216
|
+
requirements:
|
217
|
+
- - ">="
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
hash: 3
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
version: "0"
|
223
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
|
+
none: false
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
hash: 3
|
229
|
+
segments:
|
230
|
+
- 0
|
231
|
+
version: "0"
|
232
|
+
requirements: []
|
233
|
+
|
234
|
+
rubyforge_project:
|
235
|
+
rubygems_version: 1.5.0
|
236
|
+
signing_key:
|
237
|
+
specification_version: 3
|
238
|
+
summary: A rails (gem) plugin to enable surveys in your application
|
239
|
+
test_files:
|
240
|
+
- spec/controllers/surveyor_controller_spec.rb
|
241
|
+
- spec/factories.rb
|
242
|
+
- spec/lib/surveyor_spec.rb
|
243
|
+
- spec/models/answer_spec.rb
|
244
|
+
- spec/models/dependency_condition_spec.rb
|
245
|
+
- spec/models/dependency_spec.rb
|
246
|
+
- spec/models/question_group_spec.rb
|
247
|
+
- spec/models/question_spec.rb
|
248
|
+
- spec/models/response_set_spec.rb
|
249
|
+
- spec/models/response_spec.rb
|
250
|
+
- spec/models/survey_section_spec.rb
|
251
|
+
- spec/models/survey_spec.rb
|
252
|
+
- spec/models/validation_condition_spec.rb
|
253
|
+
- spec/models/validation_spec.rb
|
254
|
+
- spec/spec_helper.rb
|