factory_girl_rspec 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/README.md +1 -1
- data/Rakefile +4 -0
- data/factory_girl_rspec.gemspec +2 -0
- data/lib/factory_girl/rspec/version.rb +1 -1
- data/lib/factory_girl/rspec/with.rb +21 -4
- data/spec/factories/users.rb +10 -0
- data/spec/factory_girl_rspec_spec.rb +47 -0
- data/spec/models/user.rb +6 -0
- data/spec/spec_helper.rb +12 -0
- metadata +27 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f430609277352762527d818bbda9c23db1898439
|
4
|
+
data.tar.gz: ee39364decfc0d02e57eadbf397310304f52b65b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ac7ef19aff949d84ffabfd7b9c5d8ee4591e220abd76a9ecbe79a83676fdb9053d15752d78f01eae5f922fccf5bc0ed11cf3cea7cb61b07c9e3a35348d2b1af
|
7
|
+
data.tar.gz: c9985ff30d8b069d1c244e3842de08d56f31b13510f51e8ad7d1921ae18748c0e24337925ffcb056779dbb89e6ce0656e9ed4ca05958928ea9ca0c47854f8df9
|
data/.rspec
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/factory_girl_rspec.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_runtime_dependency 'rspec', '>= 2.0'
|
18
18
|
s.add_runtime_dependency 'factory_girl', '>= 2.0'
|
19
19
|
|
20
|
+
s.add_development_dependency 'sqlite3'
|
21
|
+
|
20
22
|
s.files = `git ls-files`.split("\n")
|
21
23
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
24
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -3,12 +3,29 @@ require 'factory_girl'
|
|
3
3
|
module FactoryGirl
|
4
4
|
module Rspec
|
5
5
|
module With
|
6
|
-
|
7
|
-
|
6
|
+
# define an rspec helper method that lazily creates the referenced
|
7
|
+
# FactoryGirl fixture (via let)
|
8
|
+
# example usage:
|
9
|
+
# with :user
|
10
|
+
def with(*args)
|
11
|
+
register_factory 'let', *args
|
8
12
|
end
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
# define an rspec helper method that eagerly creates the referenced
|
15
|
+
# FactoryGirl fixture (via let!)
|
16
|
+
# example usage:
|
17
|
+
# with! :user
|
18
|
+
def with!(*args)
|
19
|
+
register_factory 'let!', *args
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def register_factory(method_name, *args)
|
25
|
+
variable_name = args.reject {|arg| arg.is_a?(Hash) }.join('_')
|
26
|
+
send(method_name, variable_name) do
|
27
|
+
::FactoryGirl.create *args
|
28
|
+
end
|
12
29
|
end
|
13
30
|
end
|
14
31
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FactoryGirl::Rspec do
|
4
|
+
describe '.with' do
|
5
|
+
context 'with factory' do
|
6
|
+
with :user
|
7
|
+
it 'creates helper method' do
|
8
|
+
expect(user).to_not be_nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
context 'with traits' do
|
12
|
+
with :user, :when_name_is_empty
|
13
|
+
it 'creates helper method name with factory + traits' do
|
14
|
+
expect(user_when_name_is_empty).to_not be_nil
|
15
|
+
expect(user_when_name_is_empty.name).to be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
context 'with overridden properties' do
|
19
|
+
with :user, name: 'Bob'
|
20
|
+
it 'configures instance with overridden properties' do
|
21
|
+
expect(user.name).to eq 'Bob'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.with!' do
|
27
|
+
context 'with factory' do
|
28
|
+
with! :user
|
29
|
+
it 'creates helper method' do
|
30
|
+
expect(user).to_not be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
context 'with traits' do
|
34
|
+
with! :user, :when_name_is_empty
|
35
|
+
it 'creates helper method name with factory + traits' do
|
36
|
+
expect(user_when_name_is_empty).to_not be_nil
|
37
|
+
expect(user_when_name_is_empty.name).to be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
context 'with overridden properties' do
|
41
|
+
with! :user, name: 'Bob'
|
42
|
+
it 'configures instance with overridden properties' do
|
43
|
+
expect(user.name).to eq 'Bob'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/models/user.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'factory_girl_rspec'
|
2
|
+
require 'models/user'
|
3
|
+
|
4
|
+
FactoryGirl.find_definitions
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
config.filter_run :focus
|
10
|
+
|
11
|
+
config.order = 'random'
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Sonnek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: add helper methods to quickly instantiate and assign factory girl fixtures
|
42
56
|
to your test context
|
43
57
|
email:
|
@@ -47,6 +61,7 @@ extensions: []
|
|
47
61
|
extra_rdoc_files: []
|
48
62
|
files:
|
49
63
|
- .gitignore
|
64
|
+
- .rspec
|
50
65
|
- .ruby-gemset
|
51
66
|
- .ruby-version
|
52
67
|
- CONTRIBUTORS.txt
|
@@ -58,6 +73,10 @@ files:
|
|
58
73
|
- lib/factory_girl/rspec/version.rb
|
59
74
|
- lib/factory_girl/rspec/with.rb
|
60
75
|
- lib/factory_girl_rspec.rb
|
76
|
+
- spec/factories/users.rb
|
77
|
+
- spec/factory_girl_rspec_spec.rb
|
78
|
+
- spec/models/user.rb
|
79
|
+
- spec/spec_helper.rb
|
61
80
|
homepage: ''
|
62
81
|
licenses: []
|
63
82
|
metadata: {}
|
@@ -77,8 +96,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
96
|
version: '0'
|
78
97
|
requirements: []
|
79
98
|
rubyforge_project: factory_girl_rspec
|
80
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.1.5
|
81
100
|
signing_key:
|
82
101
|
specification_version: 4
|
83
102
|
summary: integrate factory_girl directly into the RSpec DSL
|
84
|
-
test_files:
|
103
|
+
test_files:
|
104
|
+
- spec/factories/users.rb
|
105
|
+
- spec/factory_girl_rspec_spec.rb
|
106
|
+
- spec/models/user.rb
|
107
|
+
- spec/spec_helper.rb
|