stamped 0.1.0 → 0.2.0

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: ccb6aab236ff833114af9f3b85326dc4d552dc29
4
- data.tar.gz: 403ee84944880cb29ea8fc6d084b5b4d2cd3f7bf
3
+ metadata.gz: c10d7c06816d9b3d7ae3a32e699348120376ab6b
4
+ data.tar.gz: 6385a82e161a0a1125fa6be939cee9b54b07cf6c
5
5
  SHA512:
6
- metadata.gz: 105623246d9d22a06c010c7f60db9adf6caa336a7ec649da2623ac27d534569b75d4bddb644cd9c640090bc918eac3e12746a22ac2fd1dbe1083130fad9ad6a2
7
- data.tar.gz: 09ea5c8ba60b7ada473c62ba8eb4607c2ae17981e64339dcbdca777a8183b4d96176b7367a08d71d70005a661ad36f31fe56953eabe90d6d3851a70f9b41bbd5
6
+ metadata.gz: a877ad69c62446f697c6398ded2dddcb1b79fc04dfcf929da98a290b9dee19781b089944d9caeb93f64b32bce0acd90ce5f6ffe235942f62470156a144aed45f
7
+ data.tar.gz: 401efbf29f0bb483c95ec3e3c1193b41d06318df5a588ce8396d73f6ff97622a853c85815c016f0246684a6b11986fffb61069408f155249e8f9c383f6eb27fc
data/README.md CHANGED
@@ -28,6 +28,39 @@ Time.now.stamp #=> "2015-03-25T00:53:36Z"
28
28
  Time.stamp_time #=> 2015-03-25 00:53:44 UTC
29
29
  ```
30
30
 
31
+ ## Testing
32
+
33
+ When testing with time, you often just want to make sure you have a valid timestamp, rather than a specific time. To aid this case, you can use the `be_timestamp` matcher.
34
+
35
+ ``` ruby
36
+ # spec_helper.rb
37
+ require 'stamped/rspec'
38
+
39
+ # delivery.rb
40
+ class Delivery
41
+ def initialize(time)
42
+ @time = time
43
+ end
44
+
45
+ def timestamp
46
+ @time.stamp
47
+ end
48
+
49
+ # ...
50
+ end
51
+
52
+ # delivery_spec.rb
53
+ require 'spec_helper'
54
+
55
+ describe Delivery do
56
+ it 'has a valid timestamp' do
57
+ delivery = Delivery.new(3.days.from_now)
58
+
59
+ expect(delivery.timestamp).to be_timestamp
60
+ end
61
+ end
62
+ ```
63
+
31
64
  ## Development
32
65
 
33
66
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,10 @@
1
+ require 'rspec'
2
+
3
+ RSpec::Matchers.define :be_timestamp do
4
+ match do |actual|
5
+ @expected = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/
6
+ actual =~ @expected
7
+ end
8
+
9
+ diffable
10
+ end
@@ -1,4 +1,4 @@
1
1
  # Stamped version
2
2
  module Stamped
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stamped
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Madsen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,6 +98,7 @@ files:
98
98
  - bin/console
99
99
  - bin/setup
100
100
  - lib/stamped.rb
101
+ - lib/stamped/rspec.rb
101
102
  - lib/stamped/version.rb
102
103
  - stamped.gemspec
103
104
  homepage: https://github.com/lintci/stamped