spec/adhearsion/call_controller/utility_spec.rb in adhearsion-2.1.3 vs spec/adhearsion/call_controller/utility_spec.rb in adhearsion-2.2.0
- old
+ new
@@ -45,24 +45,44 @@
it 'filters meaningless characters out' do
subject.grammar_accept('3+5').to_s.should be == grxml.to_s
end
end # grammar_accept
- describe "#parse_single_dtmf" do
- it "correctly returns the parsed input" do
- subject.parse_single_dtmf("dtmf-3").should be == '3'
- end
+ describe "#parse_dtmf" do
+ context "with a single digit" do
+ it "correctly returns the parsed input" do
+ subject.parse_dtmf("dtmf-3").should be == '3'
+ end
- it "correctly returns star as *" do
- subject.parse_single_dtmf("dtmf-star").should be == '*'
- end
+ it "correctly returns star as *" do
+ subject.parse_dtmf("dtmf-star").should be == '*'
+ end
- it "correctly returns pound as #" do
- subject.parse_single_dtmf("dtmf-pound").should be == '#'
+ it "correctly returns * as *" do
+ subject.parse_dtmf("*").should be == '*'
+ end
+
+ it "correctly returns pound as #" do
+ subject.parse_dtmf("dtmf-pound").should be == '#'
+ end
+
+ it "correctly returns # as #" do
+ subject.parse_dtmf("#").should be == '#'
+ end
+
+ it "correctly parses digits without the dtmf- prefix" do
+ subject.parse_dtmf('1').should be == '1'
+ end
+
+ it "correctly returns nil when input is nil" do
+ subject.parse_dtmf(nil).should be == nil
+ end
end
- it "correctly returns nil when input is nil" do
- subject.parse_single_dtmf(nil).should be == nil
+ context "with multiple digits separated by spaces" do
+ it "returns the digits without space separation" do
+ subject.parse_dtmf('1 dtmf-5 dtmf-star # 2').should be == '15*#2'
+ end
end
end # describe #grammar_accept
end
end
end