Skip to content

Commit

Permalink
Adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flbulgarelli committed Oct 23, 2019
1 parent 2127a0a commit bb6879b
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion spec/models/exercise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,75 @@
let(:exercise) { create(:exercise) }
let(:user) { create(:user, first_name: 'Orlo') }

describe("schema fields are in sync") do
describe "schema fields are in sync" do
let(:resource_h_fields) { Exercise.new(guide: Guide.new, language: Language.new).to_expanded_resource_h.keys }
let(:schema_fields) { Mumuki::Domain::Store::Github::ExerciseSchema.fields.map(&:reverse_name) }

it { expect(resource_h_fields).to contain_exactly(*schema_fields) }
end

describe '#to_resource_h' do
let(:exercise) { create(:problem, name: 'Say hello', description: 'say _hello_', layout: 'input_bottom', language: python, bibliotheca_id: 11, locale: 'en') }
let(:python) { create :language, name: 'python', extension: 'py', test_extension: 'py' }

before { exercise.guide.update! language: python }

it { expect(exercise.to_resource_h).to json_eq name: "Say hello",
id: 11,
locale: 'en',
layout: 'input_bottom',
tag_list: [],
extra_visible: false,
manual_evaluation: false,
editor: 'code',
assistance_rules: [],
randomizations: {},
choices: [],
type: "problem",
settings: {},
test: 'dont care',
offline_test: {},
expectations: [],
description: "say _hello_" }

it { expect(exercise.to_resource_h markdownified: true).to json_eq name: "Say hello",
id: 11,
locale: 'en',
layout: 'input_bottom',
tag_list: [],
extra_visible: false,
manual_evaluation: false,
editor: 'code',
assistance_rules: [],
randomizations: {},
choices: [],
type: "problem",
settings: {},
test: 'dont care',
offline_test: {},
expectations: [],
description: "<p>say <em>hello</em></p>\n" }

it { expect(exercise.to_resource_h embed_language: true).to json_eq name: "Say hello",
id: 11,
locale: 'en',
layout: 'input_bottom',
tag_list: [],
extra_visible: false,
manual_evaluation: false,
editor: 'code',
assistance_rules: [],
randomizations: {},
choices: [],
type: "problem",
settings: {},
test: 'dont care',
offline_test: {},
expectations: [],
description: "say _hello_",
language: { name: 'python', extension: 'py', test_extension: 'py' } }
end

describe '#choice_values' do
context 'when choices are in 5.0 format' do
let(:choice_values) { %w(1492 1453 1773) }
Expand Down

0 comments on commit bb6879b

Please sign in to comment.