fakery 0.2.0 → 0.3.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: 5459515e0ea465c6584439c32d60489c1f1d5873
4
- data.tar.gz: 7fea7ae849a853694108d840a3c2174ba8586ab2
3
+ metadata.gz: dbc188f39d30e86ae661ade53a2c14d8bf55e3ff
4
+ data.tar.gz: d365ddbe995a8212d6ca3892966c56f19a6b491c
5
5
  SHA512:
6
- metadata.gz: 9499de891351b88e108f90e551a776f96e541d44d0482faabf40c61068a94a188621fdcdc167645cb51ce48259dbebcfb6534e8eb9fc7b18cc140f2615fe381e
7
- data.tar.gz: 881113d46f68162e8967247ff30d4ef08d964dfb205bec82ef6fd8766d769b9f9eccb6e3a39d29508ed2063937a5dfc920f902984abf5e01fb7e7e2138bf5b1f
6
+ metadata.gz: 0869138fda5b663cb23068f60dca01c309e50ee6ff7a7662fe1a239f384e9111b6d882ce57475fbae7f6819bffa82baf27f2599c64714123016f8c3fdf5b067c
7
+ data.tar.gz: b9b5a77c1550bacd46c45177de1d9a3d22b1648d1dc454c2a0161d7c101e2a264b6be79bb0287c6c32b7aaad49bddfc19572830c3aea39c7a12d4d2a4ca89aa4
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  .*.sw[pon]
2
2
  .AppleDouble
3
3
  .DS_Store
4
+ .byebug_history
4
5
  .ruby-version
5
6
  .rvmrc
6
7
  .utilsrc
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ GemHadar do
12
12
  test_dir 'spec'
13
13
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '.rvmrc',
14
14
  '.ruby-version', '.AppleDouble', 'tags', '.DS_Store', '.utilsrc', 'doc',
15
- 'errors.lst'
15
+ 'errors.lst', '.byebug_history'
16
16
  readme 'README.md'
17
17
  title "#{name.camelize} -- "
18
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: fakery 0.2.0 ruby lib
2
+ # stub: fakery 0.3.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fakery"
6
- s.version = "0.2.0"
6
+ s.version = "0.3.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["betterplace Developers"]
11
- s.date = "2016-05-26"
11
+ s.date = "2016-06-01"
12
12
  s.description = "This library fakes ruby objects from JSON API responses for testing purposes."
13
13
  s.email = "developers@betterplace.org"
14
14
  s.extra_rdoc_files = ["README.md", "lib/fakery.rb", "lib/fakery/api.rb", "lib/fakery/api_error.rb", "lib/fakery/change.rb", "lib/fakery/fake.rb", "lib/fakery/fakery_error.rb", "lib/fakery/registry.rb", "lib/fakery/seeding.rb", "lib/fakery/version.rb", "lib/fakery/wrapping.rb"]
@@ -3,7 +3,7 @@ class Fakery::Change
3
3
  # which the field was changed. +to+ is the new value to which the field was
4
4
  # changed. If +added+ is false (default) this is a change from previously set
5
5
  # value, if it's true then this change is a new addition of a field.
6
- def initialize(name: nil, from: nil, to: nil, added: false) # TODO remove nil in Ruby 2.1
6
+ def initialize(name:, from:, to:, added: false)
7
7
  name or raise ArgumentError, 'name keyword argument is required'
8
8
  @name, @from, @to, @added = name, from, to, added
9
9
  end
@@ -1,6 +1,6 @@
1
1
  module Fakery
2
2
  # Fakery version
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -10,9 +10,10 @@ module Fakery::Wrapping
10
10
 
11
11
  # Return an instance of class +as+ initialized with the hash representation
12
12
  # of +fake+ (via its constructor).
13
- def instance(fake, as: nil) # TODO remove nil in Ruby 2.1
13
+ def instance(fake, as:, with: nil)
14
14
  as or raise ArgumentError, 'as keyword argument is required'
15
15
  fake = Fakery::Fake.cast(fake)
16
+ with and fake = Fakery::Fake.cast(fake.to_hash.merge(with))
16
17
  as.new(fake.to_hash)
17
18
  end
18
19
  end
@@ -57,6 +57,11 @@ describe Fakery::Wrapping do
57
57
  obj = Fakery.instance(:foo, as: klass)
58
58
  expect(obj.attrs[:name]).to eq fake.name
59
59
  end
60
+
61
+ it 'returns a modified instance' do
62
+ obj = Fakery.instance(:foo, as: klass, with: { name: 'bar' })
63
+ expect(obj.attrs[:name]).to eq 'bar'
64
+ end
60
65
  end
61
66
  end
62
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-26 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar