any_value 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34e46954b67b61b298a1fb9032192aa102cf7c47
4
- data.tar.gz: 922af0fc2c8b978580bab08fd6b94809af4e9748
3
+ metadata.gz: c2fbdf76dd8789550e713ebccc46ba9d11fe232b
4
+ data.tar.gz: d55f3a1b3eb63a4196f4a12de4dd2c20b123f1dd
5
5
  SHA512:
6
- metadata.gz: 4015a9e6956be16714891d3923be52db9a238d0da720abe18a623a7b722f381f9a65547580053b7ca90ba22d5c565127351b6aedf365811fcd872247144b692b
7
- data.tar.gz: 0d0e6c196643d1992b8ca8f417594f4e450243e750f27f1fd8c030946bf87c3fd03d8ecffba4d5fdebb12cdb3c1269c5f3654b0ff267e5b482fc08ebfbf15517
6
+ metadata.gz: 198334ef88bb4fb8ed5aac9bf47d3bd599199f04f3be1281445d46253414d067cefa76116650547ebdea7284ea2b4ee608b99d70025cfb55efae5a0fc9967be2
7
+ data.tar.gz: af9d7f9abf9dbee6c3edc6351205749b03c3c6c4cb3fac696c24d5abae16eb95337a550a72f06249da85f94c83991b9e392bf14aff2dfce2a884760b661f9633
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # Anything
1
+ # AnyValue
2
2
 
3
- [![Build Status](https://travis-ci.org/wojtekmach/anything.svg)](https://travis-ci.org/wojtekmach/anything)
3
+ [![Build Status](https://travis-ci.org/wojtekmach/any_value.svg)](https://travis-ci.org/wojtekmach/any_value)
4
4
 
5
- Anything is a collection of helper methods like: `anything`, `any_number`, `any_string` that is useful for testing nested data structures (like arrays or hashes) when you care more about some particular elements and the "shape" of the data, than about the entire data structure.
5
+ AnyValue is a collection of helper methods like: `anything`, `any_number`, `any_string` that is useful for testing nested data structures (like arrays or hashes) when you care more about some particular elements and the "shape" of the data, than about the entire data structure.
6
6
 
7
- So, instead of either:
8
-
9
- * Asserting all elements, even the attributes you don't really care about (ids, created_at fields etc)
7
+ **without** this gem:
10
8
 
11
9
  ```ruby
10
+ # Asserting all elements, even the attributes you don't really care about (ids, created_at fields etc)
11
+
12
12
  def test_create
13
13
  item1 = Item.create!(name: "Item 1")
14
14
  item2 = Item.create!(name: "Item 2")
@@ -20,13 +20,9 @@ def test_create
20
20
  {"id" => item2.id, "name" => "Item 2"},
21
21
  ], JSON(response.body)
22
22
  end
23
- ```
24
23
 
25
- or
24
+ # Extracting out subset of attributes you care about:
26
25
 
27
- * Extracting out subset of attributes you care about:
28
-
29
- ```ruby
30
26
  def test_create
31
27
  item1 = Item.create!(name: "Item 1")
32
28
  item2 = Item.create!(name: "Item 2")
@@ -39,7 +35,7 @@ def test_create
39
35
  end
40
36
  ```
41
37
 
42
- You can do this:
38
+ **with** this gem:
43
39
 
44
40
  ```ruby
45
41
  def test_create
@@ -57,20 +53,17 @@ end
57
53
 
58
54
  ## Usage
59
55
 
60
- All you have to do is to include `Anything` module to your program/test/whatever.
56
+ All you have to do is to include `AnyValue` module to your program/test/whatever.
61
57
 
62
58
  Example:
63
59
 
64
60
  ```ruby
65
- require 'anything'
66
-
67
- class Minitest::Test
68
- include Anything
69
- end
70
-
61
+ require 'any_value'
71
62
  require 'minitest/autorun'
72
63
 
73
64
  class Test < Minitest::Test
65
+ include AnyValue
66
+
74
67
  def test_anything
75
68
  assert_equal any_number, 42
76
69
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Wojtek Mach"]
10
10
  spec.email = ["wojtek@wojtekmach.pl"]
11
11
 
12
- spec.summary = %q{Helper objects for testing nested data structures}
12
+ spec.summary = %q{Collection of helper methods for testing "shape" of the data}
13
13
  spec.description = spec.summary
14
14
  spec.homepage = "https://github.com/wojtekmach/any_value"
15
15
  spec.license = "MIT"
@@ -10,6 +10,7 @@
10
10
  require "any_value/version"
11
11
  require "delegate"
12
12
  require "set"
13
+ require "time"
13
14
  require "date"
14
15
  require "uri"
15
16
 
@@ -264,6 +265,18 @@ module AnyValue
264
265
  AnyTime.new
265
266
  end
266
267
 
268
+ class AnyTimeString < Anything
269
+ def ==(o)
270
+ Time.parse(o)
271
+ true
272
+ rescue ArgumentError
273
+ false
274
+ end
275
+ end
276
+ def any_time_string
277
+ AnyTimeString.new
278
+ end
279
+
267
280
  class AnyDate < Anything
268
281
  def ==(o)
269
282
  o.is_a?(Date)
@@ -273,6 +286,30 @@ module AnyValue
273
286
  AnyDate.new
274
287
  end
275
288
 
289
+ class AnyDateString < Anything
290
+ def ==(o)
291
+ Date.parse(o)
292
+ true
293
+ rescue ArgumentError
294
+ false
295
+ end
296
+ end
297
+ def any_date_string
298
+ AnyDateString.new
299
+ end
300
+
301
+ class AnyDateTimeString < Anything
302
+ def ==(o)
303
+ DateTime.parse(o)
304
+ true
305
+ rescue ArgumentError
306
+ false
307
+ end
308
+ end
309
+ def any_datetime_string
310
+ AnyDateTimeString.new
311
+ end
312
+
276
313
  class AnyHTTPURI < Anything
277
314
  def ==(o)
278
315
  uri = URI(o)
@@ -1,3 +1,3 @@
1
1
  module AnyValue
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: any_value
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojtek Mach
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Helper objects for testing nested data structures
55
+ description: Collection of helper methods for testing "shape" of the data
56
56
  email:
57
57
  - wojtek@wojtekmach.pl
58
58
  executables: []
@@ -91,5 +91,5 @@ rubyforge_project:
91
91
  rubygems_version: 2.5.1
92
92
  signing_key:
93
93
  specification_version: 4
94
- summary: Helper objects for testing nested data structures
94
+ summary: Collection of helper methods for testing "shape" of the data
95
95
  test_files: []