README.md in tspec-0.2.0 vs README.md in tspec-0.3.0

- old
+ new

@@ -35,10 +35,13 @@ require 'tspec' def echo(str) puts str end.receive(str: String) + +echo('hello world') #=> ok +echo(123) #=> TSpec::ArgumentTypeError ``` You can specify multiple type, too. ```ruby @@ -46,12 +49,13 @@ def echo(val) puts val end.receive(val: [String, Float]) -echo('hello') -echo(3.14) +echo('hello') #=> ok +echo(3.14) #=> ok +echo(123) #=> TSpec::ArgumentTypeError ``` If single method argument is given, you can skip keyword. ```ruby @@ -59,11 +63,12 @@ def join_array(arr) arr.join(' ') end.receive([String]) -puts join_array(%w(hello world)) +puts join_array(%w(hello world)) #=> ok +puts join_array([1,2,3]) #=> TSpec::ArgumentTypeError ``` You can specify Array content type, although it may seem strange. ```ruby @@ -71,11 +76,12 @@ def receive_string_array(arr) arr.join end.receive(arr: [[String]]) -puts receive_string_array(['hello', 'world']) +puts receive_string_array(['hello', 'world']) #=> ok +puts receive_string_array([:hello, :world]) #=> TSpec::ArgumentTypeError ``` ### return @@ -85,10 +91,17 @@ require 'tspec' def message 'hello world' end.return(String) + +def dummy_message + 'hello world' +end.return(Symbol) + +puts message #=> ok +puts dummy_message #=> TSpec::ReturnValueTypeError ``` You can specify multiple return value, too. ```ruby @@ -124,18 +137,17 @@ def string2symbol(str) str.to_sym end.receive(str: String).return(Symbol) -p string2symbol('hello') #=> :hello -p string2symbol(123) #=> TSpec::ArgumentTypeError +p string2symbol('hello') #=> :hello +p string2symbol(123) #=> TSpec::ArgumentTypeError ``` ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/siman-man/tspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available under the terms of the [MIT License](http://opensource.org/licenses/MIT). -