fakery 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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +10 -2
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/fakery.gemspec +6 -6
- data/lib/fakery.rb +1 -1
- data/lib/fakery/fake.rb +1 -1
- data/lib/fakery/registry.rb +11 -0
- data/lib/fakery/version.rb +1 -1
- data/spec/fake_spec.rb +7 -0
- data/spec/registry_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5459515e0ea465c6584439c32d60489c1f1d5873
|
4
|
+
data.tar.gz: 7fea7ae849a853694108d840a3c2174ba8586ab2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9499de891351b88e108f90e551a776f96e541d44d0482faabf40c61068a94a188621fdcdc167645cb51ce48259dbebcfb6534e8eb9fc7b18cc140f2615fe381e
|
7
|
+
data.tar.gz: 881113d46f68162e8967247ff30d4ef08d964dfb205bec82ef6fd8766d769b9f9eccb6e3a39d29508ed2063937a5dfc920f902984abf5e01fb7e7e2138bf5b1f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
rvm:
|
2
|
-
- 2.1
|
2
|
+
- 2.1
|
3
|
+
- 2.2
|
4
|
+
- 2.3.1
|
5
|
+
- ruby-head
|
3
6
|
matrix:
|
4
7
|
allow_failures:
|
5
8
|
- rvm: ruby-head
|
6
9
|
env:
|
7
|
-
-
|
10
|
+
- CODECLIMATE_REPO_TOKEN=af3a05003c763bcee8abfdd7d7c46cc122c02ea09e5a71c3e16cf0a26685a851
|
11
|
+
|
12
|
+
before_install:
|
13
|
+
- gem install bundler
|
14
|
+
|
15
|
+
sudo: false
|
data/Rakefile
CHANGED
@@ -11,7 +11,8 @@ GemHadar do
|
|
11
11
|
description "This library fakes ruby objects from JSON API responses for testing purposes."
|
12
12
|
test_dir 'spec'
|
13
13
|
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '.rvmrc',
|
14
|
-
'.ruby-version', '.AppleDouble', 'tags', '.DS_Store', '.utilsrc', 'doc'
|
14
|
+
'.ruby-version', '.AppleDouble', 'tags', '.DS_Store', '.utilsrc', 'doc',
|
15
|
+
'errors.lst'
|
15
16
|
readme 'README.md'
|
16
17
|
title "#{name.camelize} -- "
|
17
18
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/fakery.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: fakery 0.
|
2
|
+
# stub: fakery 0.2.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fakery"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.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-
|
11
|
+
s.date = "2016-05-26"
|
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"]
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.specification_version = 4
|
24
24
|
|
25
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_development_dependency(%q<gem_hadar>, ["~> 1.
|
26
|
+
s.add_development_dependency(%q<gem_hadar>, ["~> 1.7.1"])
|
27
27
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
28
28
|
s.add_development_dependency(%q<rspec>, ["~> 3.0"])
|
29
29
|
s.add_development_dependency(%q<rspec-nc>, [">= 0"])
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_runtime_dependency(%q<typhoeus>, ["~> 1.0"])
|
34
34
|
s.add_runtime_dependency(%q<json>, ["~> 1.0"])
|
35
35
|
else
|
36
|
-
s.add_dependency(%q<gem_hadar>, ["~> 1.
|
36
|
+
s.add_dependency(%q<gem_hadar>, ["~> 1.7.1"])
|
37
37
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
38
38
|
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
39
39
|
s.add_dependency(%q<rspec-nc>, [">= 0"])
|
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
s.add_dependency(%q<json>, ["~> 1.0"])
|
45
45
|
end
|
46
46
|
else
|
47
|
-
s.add_dependency(%q<gem_hadar>, ["~> 1.
|
47
|
+
s.add_dependency(%q<gem_hadar>, ["~> 1.7.1"])
|
48
48
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
49
49
|
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
50
50
|
s.add_dependency(%q<rspec-nc>, [">= 0"])
|
data/lib/fakery.rb
CHANGED
data/lib/fakery/fake.rb
CHANGED
data/lib/fakery/registry.rb
CHANGED
@@ -28,6 +28,17 @@ module Fakery::Registry
|
|
28
28
|
registered_fakes[register_name] = Fakery::Fake.cast(fake)
|
29
29
|
end
|
30
30
|
|
31
|
+
def register_files(*files)
|
32
|
+
files = files.flatten
|
33
|
+
puts "Registering fakes…"
|
34
|
+
for file in files
|
35
|
+
name = File.basename(file).sub('.json', '').to_sym
|
36
|
+
Fakery.register(name, File.read(file))
|
37
|
+
puts "Just registered the fake #{name.inspect}"
|
38
|
+
end
|
39
|
+
puts "Done."
|
40
|
+
end
|
41
|
+
|
31
42
|
# Builds a the fake registered under the name +register_name+. All its fields
|
32
43
|
# can be changed according to the names and values in the +with+ keyword
|
33
44
|
# argument or later by using setters on the object.
|
data/lib/fakery/version.rb
CHANGED
data/spec/fake_spec.rb
CHANGED
@@ -91,6 +91,13 @@ describe Fakery::Fake do
|
|
91
91
|
expect(fake.name).to eq 'foo'
|
92
92
|
end
|
93
93
|
|
94
|
+
it 'casts from an object implementing as_json method' do
|
95
|
+
object = double(as_json: { name: 'foo' })
|
96
|
+
casted = Fakery::Fake.cast(object)
|
97
|
+
expect(casted).to be_a Fakery::Fake
|
98
|
+
expect(casted.name).to eq 'foo'
|
99
|
+
end
|
100
|
+
|
94
101
|
it 'raises an ArgumentError if it cannot cast' do
|
95
102
|
expect { Fakery::Fake.cast(Object.new) }.to raise_error ArgumentError
|
96
103
|
end
|
data/spec/registry_spec.rb
CHANGED
@@ -19,6 +19,12 @@ describe Fakery::Registry do
|
|
19
19
|
Fakery.register 'foo', fake
|
20
20
|
end
|
21
21
|
|
22
|
+
it 'can register files containing json as fakes' do
|
23
|
+
expect(File).to receive(:read).with('bar/foo.json').and_return fake.to_json
|
24
|
+
Fakery.register_files 'bar/foo.json'
|
25
|
+
expect(Fakery.build(:foo).name).to eq 'foo'
|
26
|
+
end
|
27
|
+
|
22
28
|
context 'registered fake' do
|
23
29
|
before :each do
|
24
30
|
Fakery.register :foo, fake
|
data/spec/spec_helper.rb
CHANGED
@@ -4,14 +4,8 @@ if ENV['START_SIMPLECOV'].to_i == 1
|
|
4
4
|
SimpleCov.start do
|
5
5
|
add_filter "#{File.basename(File.dirname(__FILE__))}/"
|
6
6
|
end
|
7
|
-
|
8
|
-
|
9
|
-
if ENV['START_SIMPLECOV']
|
10
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
11
|
-
SimpleCov::Formatter::HTMLFormatter,
|
12
|
-
CodeClimate::TestReporter::Formatter
|
13
|
-
]
|
14
|
-
end
|
7
|
+
elsif ENV['CODECLIMATE_REPO_TOKEN']
|
8
|
+
require 'codeclimate-test-reporter'
|
15
9
|
CodeClimate::TestReporter.start
|
16
10
|
end
|
17
11
|
require 'rspec'
|
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.7.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.7.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simplecov
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|