Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Added feature specs
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusf committed Jul 2, 2015
1 parent d4d522f commit 4cb0204
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 8 deletions.
49 changes: 41 additions & 8 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FactoryGirl.define do
factory :user do
name "user"
email "user@test.com"
sequence(:email) { |n| "user#{n}@test.com" }
password "foobar"
password_confirmation "foobar"
after(:build) do |user|
Expand All @@ -13,7 +13,7 @@

factory :admin, parent: :user do
name "admin"
email "admin@example.org"
sequence(:email) { |n| "admin#{n}@example.org" }
after(:build) do |user|
user.system_role_id = 1
#user.confirmed_at = Time.now.to_s[0..-7]
Expand All @@ -22,15 +22,15 @@

factory :student, parent: :user do
name "student"
email "student@example.org"
sequence(:email) { |n| "student#{n}@example.org" }
after(:build) do |user|
user.system_role_id = 5
end
end

factory :lecturer, parent: :user do
name "lecturer"
email "lecturer@example.org"
sequence(:email) { |n| "lecturer#{n}@example.org" }
after(:build) do |user|
user.system_role_id = 3
end
Expand Down Expand Up @@ -143,6 +143,20 @@
end
end

trait :with_auto_graded_exact_general_questions do
ignore do
creator { create(:lecturer) }
general_question_count 2
end
after(:build) do |mission, evaluator|
evaluator.general_question_count.times do
mission.questions << create(:general_question,
:auto_grading_exact,
creator: evaluator.creator).question
end
end
end

trait :with_coding_questions do
ignore do
creator { create(:lecturer) }
Expand All @@ -168,7 +182,7 @@
end
end
end

factory :achievement do
title "I won!"
description "Yahoo"
Expand Down Expand Up @@ -198,7 +212,7 @@
submission.build_initial_answers
submission.answers.each do |a|
# Add comments
a.comment_topic = build(:comment_topic, :with_comments, topic: a,
a.comment_topic = build(:comment_topic, :with_comments, topic: a,
course: submission.std_course.course, user_course: submission.std_course)
# Perform additional initialization
answer = a.specific
Expand Down Expand Up @@ -282,6 +296,25 @@
description "Description for factory-generated General question."
max_grade 1
staff_comments "Staff comment for factory-generated General question."

trait :auto_grading_exact do
auto_graded true
auto_grading_type :exact
ignore do
option_count 2
end
after(:build) do |question, evaluator|
evaluator.option_count.times do
question.auto_grading_exact_options << build(:auto_grading_exact_option)
end
end
end
end

factory :auto_grading_exact_option, class: Assessment::AutoGradingExactOption do
correct true
answer 'Some answer'
explanation 'Some explanation'
end

factory :coding_question, class: Assessment::CodingQuestion do
Expand Down Expand Up @@ -315,7 +348,7 @@
# has_many associations
comment_topic.user_courses << evaluator.user_course
evaluator.comment_count.times do
comment_topic.comments << build(:comment, user_course: evaluator.user_course,
comment_topic.comments << build(:comment, user_course: evaluator.user_course,
commentable: comment_topic.topic, comment_topic: comment_topic)
end
end
Expand All @@ -336,7 +369,7 @@
# belongs_to associations
user_course
annotable { Assessment::CodingAnswer.create }

# attributes
text "Text for an annotation."
line_start 1
Expand Down
31 changes: 31 additions & 0 deletions spec/features/general_auto_grading_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'rails_helper'

describe "AutoGrading", :type => :feature do
describe "Mission admin pages" do
let!(:lecturer) { FactoryGirl.create(:lecturer) }
let!(:course) { FactoryGirl.create(:course, creator: lecturer) }
before do
sign_in lecturer
end

describe "Single question exact options" do
let!(:mission) do
FactoryGirl.create(:mission, :with_auto_graded_exact_general_questions, :completed, course: course)
end
before do
visit new_course_assessment_submission_grading_path(course.id,
mission.assessment.id,
mission.submissions.first.id)
end

it 'should display the options' do
expect(page).to have_text("Grading: #{mission.title}")
expect(page).to have_selector('.auto-grading-exact', count: 2)
end
end

# single keyword
# multiple keyword
# multiple exact
end
end

0 comments on commit 4cb0204

Please sign in to comment.