Skip to content

Commit

Permalink
rb: deal with invalid type argument
Browse files Browse the repository at this point in the history
When an invalid type argument is given, an ArgumentError should be raised.

Signed-off-by: Andreas Tolfsen <[email protected]>
  • Loading branch information
jimvm authored and andreastt committed Mar 2, 2015
1 parent 147d4df commit 29ea618
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def network_connection_type
end

def network_connection_type=(connection_type)
raise ArgumentError, "Invalid connection type" unless valid_type? connection_type

connection_value = type_to_values[connection_type]

@bridge.setNetworkConnection connection_value
Expand All @@ -27,6 +29,10 @@ def type_to_values
def values_to_type
type_to_values.invert
end

def valid_type?(type)
type_to_values.keys.include? type
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class FakeDriver

driver.network_connection_type = :airplane_mode
end

it "returns an error when an invalid argument is given" do
expect { driver.network_connection_type = :something }.
to raise_error(ArgumentError, "Invalid connection type")
end
end
end
end
Expand Down

0 comments on commit 29ea618

Please sign in to comment.