factory_group 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +23 -0
- data/.simplecov +3 -0
- data/.travis.yml +11 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/factory_group.gemspec +30 -0
- data/lib/factory_group.rb +21 -0
- data/lib/factory_group/group.rb +19 -0
- data/lib/factory_group/version.rb +3 -0
- data/spec/acceptance/group_spec.rb +5 -0
- data/spec/factory_group/group_spec.rb +14 -0
- data/spec/factory_group_spec.rb +31 -0
- data/spec/spec_helper.rb +16 -0
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bfcb45568576375988c682e459f52c626d73740
|
4
|
+
data.tar.gz: 56cdd4368d575dfed46ac5d87588c8946a784b71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e87bcecdb5d1dc0d1223c70223571dc99c25d8e1de7c677170d07c417397825bf45d785739d99e3ba15db67fb79142ae5e2221b944a064018f9a8b0f4cebc3a0
|
7
|
+
data.tar.gz: 51f402adead483fb2ff43fcc5f7aa29d473dd30c64573056ddd0093da523e15242e822811285e5dab395e01a8bf103ed03c1712248e811713090c50f2c884a19
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.rspec
|
data/.simplecov
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
rvm:
|
2
|
+
- 2.1.0
|
3
|
+
- 2.0.0-p481
|
4
|
+
- 1.9.3
|
5
|
+
before_install:
|
6
|
+
- gem update --system
|
7
|
+
install: "bundle install"
|
8
|
+
script: "CODECLIMATE_REPO_TOKEN=d3636dec3241cd9be3710d4de49e56b5cba3e56cb682dd0025600b67209520b0 bundle exec rspec spec/"
|
9
|
+
branches:
|
10
|
+
only:
|
11
|
+
- master
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Yuvaraja Balamurugan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# FactoryGroup
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/factory_group.svg)](http://badge.fury.io/rb/factory_group) [![Build Status](https://travis-ci.org/Codebrahma/factory_group.svg?branch=master)](https://travis-ci.org/Codebrahma/factory_group) [![Code Climate](https://codeclimate.com/github/Codebrahma/factory_group/badges/gpa.svg)](https://codeclimate.com/github/Codebrahma/factory_group) [![Dependency Status](https://gemnasium.com/Codebrahma/factory_group.svg)](https://gemnasium.com/Codebrahma/factory_group) [![Test Coverage](https://codeclimate.com/github/Codebrahma/factory_group/badges/coverage.svg)](https://codeclimate.com/github/Codebrahma/factory_group)
|
4
|
+
|
5
|
+
TODO: Write a gem description
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'factory_group'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install factory_group
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/factory_group/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'factory_group/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "factory_group"
|
8
|
+
spec.version = FactoryGroup::VERSION
|
9
|
+
spec.authors = ["Yuvaraja Balamurugan"]
|
10
|
+
spec.email = ["yuv.slm@gmail.com"]
|
11
|
+
spec.summary = %q{Lets you create a group of factories}
|
12
|
+
spec.description = %q{Lets you create a group of factories which can be accessed from your specs}
|
13
|
+
spec.homepage = "http://codebrahma.com/factory_group/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.required_ruby_version = '>= 1.9.3'
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "factory_girl", ">= 4.4.0"
|
24
|
+
|
25
|
+
spec.add_development_dependency "rspec", ">= 2.13.0"
|
26
|
+
spec.add_development_dependency "bundler", ">= 1.6"
|
27
|
+
spec.add_development_dependency "rake", ">= 10.3.1"
|
28
|
+
spec.add_development_dependency "debugger", "~> 1.6.8"
|
29
|
+
spec.add_development_dependency "simplecov", "~> 0.9.0"
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "factory_group/version"
|
2
|
+
require "factory_group/group"
|
3
|
+
|
4
|
+
module FactoryGroup
|
5
|
+
@registry = {}
|
6
|
+
|
7
|
+
def self.registry
|
8
|
+
@registry
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.define(name, &block)
|
12
|
+
group = Group.new
|
13
|
+
group.instance_eval(&block)
|
14
|
+
FactoryGroup.registry[name] = group
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.create(name)
|
18
|
+
factory_group = registry[name]
|
19
|
+
factory_group.factories
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "factory_girl"
|
2
|
+
require "ostruct"
|
3
|
+
|
4
|
+
module FactoryGroup
|
5
|
+
class Group
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@factories = OpenStruct.new({})
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :factories
|
12
|
+
|
13
|
+
# Sets an instance variable with the name as the called method and
|
14
|
+
# assigns the args[0] passed to it.
|
15
|
+
def method_missing(name, *args, &block)
|
16
|
+
@factories.send("#{name.to_s}=", args[0])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe FactoryGroup::Group do
|
4
|
+
let(:group) { described_class.new }
|
5
|
+
|
6
|
+
before do
|
7
|
+
group.instance_eval do
|
8
|
+
user "name"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
it "responds to the user method" do
|
12
|
+
expect(group.factories).to respond_to :user
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe FactoryGroup do
|
4
|
+
|
5
|
+
let(:facory_group_definition) do
|
6
|
+
FactoryGroup.define(:user_group) do
|
7
|
+
user "A User"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "#define" do
|
12
|
+
it "returns the result of evaluating the block passed to define method" do
|
13
|
+
expect(facory_group_definition).to be_an_instance_of FactoryGroup::Group
|
14
|
+
end
|
15
|
+
|
16
|
+
it "stores the created group in the registry" do
|
17
|
+
expect(described_class.registry).to have_key :user_group
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "#create" do
|
22
|
+
it "returns the created FactoryGroup::Group instance" do
|
23
|
+
expect(described_class.create(:user_group)).to be_an_instance_of OpenStruct
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can be used to access the user variable" do
|
27
|
+
expect(described_class.create(:user_group).user).to eq "A User"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
|
3
|
+
CodeClimate::TestReporter.start
|
4
|
+
|
5
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'rspec'
|
10
|
+
require 'debugger'
|
11
|
+
|
12
|
+
require 'factory_group'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_group
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuvaraja Balamurugan
|
@@ -101,7 +101,22 @@ email:
|
|
101
101
|
executables: []
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
|
-
files:
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- .simplecov
|
107
|
+
- .travis.yml
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- factory_group.gemspec
|
113
|
+
- lib/factory_group.rb
|
114
|
+
- lib/factory_group/group.rb
|
115
|
+
- lib/factory_group/version.rb
|
116
|
+
- spec/acceptance/group_spec.rb
|
117
|
+
- spec/factory_group/group_spec.rb
|
118
|
+
- spec/factory_group_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
105
120
|
homepage: http://codebrahma.com/factory_group/
|
106
121
|
licenses:
|
107
122
|
- MIT
|
@@ -114,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
129
|
requirements:
|
115
130
|
- - '>='
|
116
131
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
132
|
+
version: 1.9.3
|
118
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
134
|
requirements:
|
120
135
|
- - '>='
|
@@ -126,4 +141,8 @@ rubygems_version: 2.2.2
|
|
126
141
|
signing_key:
|
127
142
|
specification_version: 4
|
128
143
|
summary: Lets you create a group of factories
|
129
|
-
test_files:
|
144
|
+
test_files:
|
145
|
+
- spec/acceptance/group_spec.rb
|
146
|
+
- spec/factory_group/group_spec.rb
|
147
|
+
- spec/factory_group_spec.rb
|
148
|
+
- spec/spec_helper.rb
|