-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from instedd/regression-tests
Add some regression tests For #25
- Loading branch information
Showing
9 changed files
with
319 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker-compose run --rm web crystal spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "spec" | ||
require "../../src/models/ao_message" | ||
|
||
include Twiliosim | ||
|
||
describe AOMessage do | ||
describe "#message" do | ||
it "initializes OK" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
|
||
ao_message.message.should eq "foo" | ||
end | ||
end | ||
|
||
describe "#redirect_url" do | ||
it "initializes OK" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
|
||
ao_message.redirect_url.should eq "bar" | ||
end | ||
end | ||
|
||
describe "#to_s" do | ||
it "returns the string representation" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
|
||
str = ao_message.to_s | ||
|
||
str.should eq "AOMessage - bar - foo" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
require "spec" | ||
require "../../src/models/call" | ||
|
||
include Twiliosim | ||
|
||
describe Call do | ||
describe "#status" do | ||
it "initializes created" do | ||
call = Call.new("foo", "bar", "baz") | ||
|
||
call.status.should eq "created" | ||
end | ||
|
||
it "starts in-progress" do | ||
call = Call.new("foo", "bar", "baz") | ||
|
||
call.start | ||
|
||
call.status.should eq "in-progress" | ||
end | ||
|
||
it "finished completed" do | ||
call = Call.new("foo", "bar", "baz") | ||
|
||
call.finish | ||
|
||
call.status.should eq "completed" | ||
end | ||
end | ||
|
||
describe "#id" do | ||
it "initializes with a new (random) UUID" do | ||
call_0 = Call.new("foo_0", "bar_1", "baz_2") | ||
call_1 = Call.new("foo_1", "bar_1", "baz_1") | ||
uuid_size = 36 | ||
|
||
call_0.id.size.should eq uuid_size | ||
call_1.id.size.should eq uuid_size | ||
call_0.id.should_not eq call_1.id | ||
end | ||
end | ||
|
||
describe "#to" do | ||
it "initializes OK" do | ||
call = Call.new("foo", "bar", "baz") | ||
|
||
call.to.should eq "foo" | ||
end | ||
end | ||
|
||
describe "#from" do | ||
it "initializes OK" do | ||
call = Call.new("foo", "bar", "baz") | ||
|
||
call.from.should eq "bar" | ||
end | ||
end | ||
|
||
describe "#account_sid" do | ||
it "initializes OK" do | ||
call = Call.new("foo", "bar", "baz") | ||
|
||
call.account_sid.should eq "baz" | ||
end | ||
end | ||
|
||
describe "#no_reply" do | ||
it "initializes OK" do | ||
call = Call.new("foo", "bar", "baz") | ||
|
||
call.no_reply.should eq false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require "spec" | ||
require "../../src/models/ao_message" | ||
require "../../src/models/reply_command" | ||
|
||
include Twiliosim | ||
|
||
describe PressDigits do | ||
describe "#ao_message" do | ||
it "initializes OK" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
foo = 28 | ||
|
||
reply_command = PressDigits.new(ao_message, foo) | ||
|
||
reply_command.ao_message.should eq ao_message | ||
end | ||
end | ||
|
||
describe "#digits" do | ||
it "initializes OK" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
foo = 53 | ||
|
||
reply_command = PressDigits.new(ao_message, foo) | ||
|
||
reply_command.digits.should eq foo | ||
end | ||
end | ||
|
||
describe "#to_s" do | ||
it "returns the string representation" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
foo = 95 | ||
reply_command = PressDigits.new(ao_message, foo) | ||
|
||
str = reply_command.to_s | ||
|
||
str.should eq "PressDigits < ReplyCommand #{foo}" | ||
end | ||
end | ||
end | ||
|
||
describe HangUp do | ||
describe "#ao_message" do | ||
it "initializes OK" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
foo = 28 | ||
|
||
reply_command = HangUp.new(ao_message) | ||
|
||
reply_command.ao_message.should eq ao_message | ||
end | ||
end | ||
|
||
describe "#to_s" do | ||
it "returns the string representation" do | ||
ao_message = AOMessage.new("foo", "bar") | ||
reply_command = HangUp.new(ao_message) | ||
|
||
str = reply_command.to_s | ||
|
||
str.should eq "HangUp < ReplyCommand" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
require "spec" | ||
require "../../src/models/simulator_command" | ||
require "../../src/config" | ||
|
||
include Twiliosim | ||
|
||
describe SimulatorCommand do | ||
describe "#parse" do | ||
it "returns nil when invalid" do | ||
simulator_command = SimulatorCommand.parse("foo") | ||
|
||
simulator_command.should eq nil | ||
end | ||
|
||
it "returns a OneOfCommand" do | ||
message = "#oneof:1,2" | ||
|
||
simulator_command = SimulatorCommand.parse(message) | ||
|
||
simulator_command.is_a?(OneOfCommand).should eq true | ||
simulator_command.should eq OneOfCommand.parse(message) | ||
end | ||
|
||
it "returns a NumericCommand" do | ||
message = "#numeric:1-2" | ||
|
||
simulator_command = SimulatorCommand.parse(message) | ||
|
||
simulator_command.is_a?(NumericCommand).should eq true | ||
simulator_command.should eq NumericCommand.parse(message) | ||
end | ||
end | ||
|
||
describe OneOfCommand do | ||
describe "#choices" do | ||
it "initializes OK" do | ||
foo = [1, 2] | ||
|
||
simulator_command = OneOfCommand.new(foo) | ||
|
||
simulator_command.choices.should eq foo | ||
end | ||
end | ||
|
||
describe "#parse" do | ||
it "returns a OneOfCommand initialized OK" do | ||
foo = [1, 2] | ||
control_command = OneOfCommand.new(foo) | ||
message = "#oneof:1,2" | ||
|
||
parsed_command = OneOfCommand.parse(message) | ||
|
||
parsed_command.should eq control_command | ||
end | ||
end | ||
|
||
describe "#valid_sample" do | ||
it "returns a sample in choices" do | ||
choices = [1, 2] | ||
simulator_command = OneOfCommand.new(choices) | ||
|
||
valid_sample = simulator_command.valid_sample | ||
|
||
choices.includes?(valid_sample).should eq true | ||
end | ||
end | ||
|
||
describe "#invalid_sample" do | ||
it "returns a sample not in choices" do | ||
choices = [1, 2] | ||
simulator_command = OneOfCommand.new(choices) | ||
|
||
invalid_sample = simulator_command.invalid_sample(Config.load) | ||
|
||
choices.includes?(invalid_sample).should eq false | ||
end | ||
end | ||
end | ||
|
||
describe NumericCommand do | ||
describe "#min" do | ||
it "initializes OK" do | ||
min = 1 | ||
max = 2 | ||
|
||
simulator_command = NumericCommand.new(min, max) | ||
|
||
simulator_command.min.should eq min | ||
end | ||
end | ||
|
||
describe "#max" do | ||
it "initializes OK" do | ||
min = 1 | ||
max = 2 | ||
|
||
simulator_command = NumericCommand.new(min, max) | ||
|
||
simulator_command.max.should eq max | ||
end | ||
end | ||
|
||
describe "#parse" do | ||
it "returns a NumericCommand initialized OK" do | ||
min = 1 | ||
max = 2 | ||
control_command = NumericCommand.new(min, max) | ||
message = "#numeric:#{min}-#{max}" | ||
|
||
parsed_command = NumericCommand.parse(message) | ||
|
||
parsed_command.should eq control_command | ||
end | ||
end | ||
|
||
describe "#valid_sample" do | ||
it "returns a sample in range" do | ||
min = 1 | ||
max = 2 | ||
simulator_command = NumericCommand.new(min, max) | ||
|
||
valid_sample = simulator_command.valid_sample | ||
|
||
(min..max).to_a.includes?(valid_sample).should eq true | ||
end | ||
end | ||
|
||
describe "#invalid_sample" do | ||
it "returns a sample not in range" do | ||
min = 1 | ||
max = 2 | ||
simulator_command = NumericCommand.new(min, max) | ||
|
||
invalid_sample = simulator_command.invalid_sample(Config.load) | ||
|
||
(min..max).to_a.includes?(invalid_sample).should eq false | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters