junklet 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzhmYTIyOTAwZDQ0MzM0YTk4ZWUwZjQ3ODBmYjFjNDVmYWE3YzNiNg==
4
+ NDQyODhhM2I3NTQyNzM3MzY1ZGM2NDk4YjZhN2VkMzVjMWZiZDdiYQ==
5
5
  data.tar.gz: !binary |-
6
- MDJjMjVlZjJmOWQ1NjBiZDU4MzI5ZDUzZjZmNDM2NDNmZTBhNjRlNQ==
6
+ ZjUxZWYzYjI3NDJjZDQwZjE4YzlhN2U2ZTI5OWE1NzRlNzhkMjljOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODg2ODhiMmFmNGE2ZDQ2MjI2OTA4NmZhNDhlNDA1MTVhZDU0NTZhZDQzYjBl
10
- NzlkNTg1ZDM2NzhmMjBjYjUyMWQ2NWVjNWE1OTIxYjhkYjU4MDQ1MmIwMjk1
11
- MTllOWRhMWNiM2UwNzNkOTAwMTZiY2U5NDM3MThmYTZiN2Q3OGU=
9
+ NmJjYTk5ZmY1ZWEzOGIxMjY0YzU0NzZiODJmODlkMzNhNGJjNTQ2NTFiOTU2
10
+ MmYxMDc0YTdlOTI5M2UwNjRjMWRjYzVhYjNhYzU3ZDdlNjk4YWQ0YjA5Zjlk
11
+ MDBiZWM5NDIxMzJjZWFlYTM2Yzg5OTVjOTI2NTMwNTIwYzQ5NjY=
12
12
  data.tar.gz: !binary |-
13
- YzE0NzVhYzEzM2QyN2ExMjAwMzk3NmVjOTk2NTc5MjhhODIzOTkyMjU3MzUz
14
- OGM5MmY4YWQ2NTlhODQwODczZWIwMjUyZDU0NjYwZjJiMWVkN2MxMjRiMzI2
15
- YTA0MTM5OTQ2OTQ0NDFiZjY1MDAxYzExMzFhMTZiYzRlZTMwNjc=
13
+ NjZjMDc0ZjNkYjU1YWI1NzA0OWM4MzgxZjA0ZGIwNDc1MjhhNDYwZGU5OTUw
14
+ NzUyYzQxOGI5ZDNkZDJkNTA5ZDA0MzlhYjI3MTUxMjhiZmI3Mzc5NGI0NzRl
15
+ YmY5NmUyM2EyOTg2Yzk0YmRhMzYyZmUyYmE1OWUzZjQ2NTY3ZDI=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junklet (0.0.1)
4
+ junklet (0.9.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -16,6 +16,28 @@ So,
16
16
  * If equality fails we want to be led to the offending field by the
17
17
  error message and not just the line number in the stack trace.
18
18
 
19
+ # Usage
20
+
21
+ junklet :var [, :var_2 [...]] [, options_hash]
22
+
23
+ junklet :first_name
24
+
25
+ Creates a `let :first_name` with the value of
26
+ `first_name-774030d0-f58d-4f58-8c5e-dddbdc7f9580` (the uuid will
27
+ change with each test case)
28
+
29
+ junklet :host_name, separator: '-'
30
+
31
+ Creates a `let :host_name`, but changes underscores to hyphens in the
32
+ string value,
33
+ e.g. `host-name-774030d0-f58d-4f58-8c5e-dddbdc7f9580`. Useful
34
+ specifically for host names, which cannot have underscores in them.
35
+
36
+ junklet :a_a, :b_b, :c_c, separator: '.'
37
+
38
+ Does what it says on the tin: creates 3 items with string values of
39
+ `a.a`, `b.b`, and `c.c` respectively.
40
+
19
41
  # Background
20
42
 
21
43
  At CoverMyMeds we have a legacy impingement that prevents us sometimes
data/junklet.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Dave Brady"]
10
10
  spec.email = ["dbrady@covermymeds.com"]
11
11
  spec.summary = "Easily create junk data for specs"
12
- spec.description = "Works like let and let! for rspec, but creates unique random junk data"
12
+ spec.description = "Works like let for rspec, but creates unique random junk data"
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -1,3 +1,3 @@
1
1
  module Junklet
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
data/lib/junklet.rb CHANGED
@@ -5,8 +5,16 @@ module RSpec
5
5
  module MemoizedHelpers
6
6
  module ClassMethods
7
7
  def junklet(*args)
8
- Array(args).each do |name|
9
- let(name) { "#{name}-#{SecureRandom.uuid}" }
8
+ opts = args.size > 1 && !args.last.is_a?(Symbol) && args.pop || {}
9
+
10
+ names = args.map(&:to_s)
11
+
12
+ if opts.key?(:separator)
13
+ names = names.map {|name| name.gsub(/_/, opts[:separator]) }
14
+ end
15
+
16
+ args.zip(names).each do |arg, name|
17
+ let(arg) { "#{name}-#{SecureRandom.uuid}" }
10
18
  end
11
19
  end
12
20
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Junklet do
4
4
  specify { expect(Junklet).to be }
5
5
 
6
- let(:regex) { /-[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/ }
6
+ let(:uuid_regex) { /-[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/ }
7
7
 
8
8
  describe '.junklet' do
9
9
  context "with a single arg" do
@@ -11,7 +11,7 @@ describe Junklet do
11
11
 
12
12
  specify { expect(junk).to be }
13
13
  specify { expect(junk).to match /^junk-/ }
14
- specify { expect(junk).to match regex }
14
+ specify { expect(junk).to match uuid_regex }
15
15
 
16
16
  describe "memoization" do
17
17
  specify { expect(junk).to eq(junk) }
@@ -22,13 +22,23 @@ describe Junklet do
22
22
  junklet :junk, :toss, :crud, :crap
23
23
 
24
24
  specify { expect(junk).to match /^junk-/ }
25
- specify { expect(junk).to match regex }
25
+ specify { expect(junk).to match uuid_regex }
26
26
  specify { expect(toss).to match /^toss-/ }
27
- specify { expect(toss).to match regex }
27
+ specify { expect(toss).to match uuid_regex }
28
28
  specify { expect(crud).to match /^crud-/ }
29
- specify { expect(crud).to match regex }
29
+ specify { expect(crud).to match uuid_regex }
30
30
  specify { expect(crap).to match /^crap-/ }
31
- specify { expect(crap).to match regex }
31
+ specify { expect(crap).to match uuid_regex }
32
+ end
33
+
34
+ context 'with separator option' do
35
+ junklet :host_name, :last_name, :first_name, separator: '-'
36
+ specify { expect(host_name).to match /^host-name-/ }
37
+ specify { expect(host_name).to match uuid_regex }
38
+ specify { expect(last_name).to match /^last-name-/ }
39
+ specify { expect(last_name).to match uuid_regex }
40
+ specify { expect(first_name).to match /^first-name-/ }
41
+ specify { expect(first_name).to match uuid_regex }
32
42
  end
33
43
  end
34
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junklet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Brady
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Works like let and let! for rspec, but creates unique random junk data
69
+ description: Works like let for rspec, but creates unique random junk data
70
70
  email:
71
71
  - dbrady@covermymeds.com
72
72
  executables: []