Skip to content

Commit

Permalink
Merge pull request #848 from tylerferraro/ferraro/rna-transcription-e…
Browse files Browse the repository at this point in the history
…xpectations

rna-transcription: Update tests to expect ArgumentError if invalid input is supplied
  • Loading branch information
Insti authored Aug 27, 2018
2 parents b9aaefc + 0fbbd1a commit d78cf7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require 'generator/exercise_case'

class RnaTranscriptionCase < Generator::ExerciseCase

def workload
"assert_equal '#{expected}', Complement.of_dna('#{dna}')"
end

end
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Complement
def self.of_dna(strand)
strand =~ /[^CGTA]/ ? '' : strand.tr('CGTA', 'GCAU')
raise ArgumentError if strand =~ /[^CGTA]/
strand.tr('CGTA', 'GCAU')
end
end
6 changes: 3 additions & 3 deletions exercises/rna-transcription/rna_transcription_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ def test_rna_complement

def test_correctly_handles_invalid_input_rna_instead_of_dna
skip
assert_equal '', Complement.of_dna('U')
assert_raises(ArgumentError) { Complement.of_dna('U') }
end

def test_correctly_handles_completely_invalid_dna_input
skip
assert_equal '', Complement.of_dna('XXX')
assert_raises(ArgumentError) { Complement.of_dna('XXX') }
end

def test_correctly_handles_partially_invalid_dna_input
skip
assert_equal '', Complement.of_dna('ACGTXXXCTTAA')
assert_raises(ArgumentError) { Complement.of_dna('ACGTXXXCTTAA') }
end
end

0 comments on commit d78cf7f

Please sign in to comment.