factory_girl_sequences 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in factory_girl_sequences.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Anton Kalyaev
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,81 @@
1
+ # FactoryGirlSequences
2
+
3
+ Collection of useful [FactoryGirl](https://github.com/thoughtbot/factory_girl)
4
+ sequences.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'factory_girl_sequences'
11
+
12
+ Or install it yourself as:
13
+
14
+ $ gem install factory_girl_sequences
15
+
16
+ ## Sequences
17
+
18
+ Format: name (aliases) - example
19
+
20
+ - :integer - 1
21
+ - :string - "string-1"
22
+ - :date - Sat, 20 Oct 2012
23
+ - :datetime - Sat, 20 Oct 2012 16:38:59 MSK +04:00
24
+ - :boolean - true | false
25
+ - :name (:login, :first_name, :last_name) - "name-1"
26
+ - :password - "password-1"
27
+ - :email - "person1@example.com"
28
+ - :ip_address - "192.168.0.1"
29
+ - :ip_subnet - "192.168.10.0"
30
+ - :mac_address - "01:23:45:67:89:01"
31
+ - :title - "Title 1"
32
+ - :body (:description) - "body-1"
33
+ - :slug - "slug-1"
34
+ - :domain - "example1.com"
35
+ - :subdomain - "blog1"
36
+ - :color - "333333"
37
+ - :checksum - 1
38
+
39
+ ## Usage
40
+
41
+ Basic example:
42
+
43
+ ```ruby
44
+ FactoryGirl.generate :email
45
+ # => "person1@example.com"
46
+
47
+ FactoryGirl.generate :email
48
+ # => "person2@example.com"
49
+ ```
50
+
51
+ Use them as attributes (preferable way):
52
+
53
+ ```ruby
54
+ factory :user do
55
+ email
56
+ end
57
+ ```
58
+
59
+ Or in lazy attributes:
60
+
61
+ ```ruby
62
+ factory :invite do
63
+ invitee { generate(:email) }
64
+ end
65
+ ```
66
+
67
+ Check out FactoryGirl's [GETTING_STARTED](https://github.com/thoughtbot/factory_girl) for more information.
68
+
69
+ ## Additionaly
70
+
71
+ All sequences are free to use and
72
+ could be changed depending on your needs. Just copy the sequence in your
73
+ project's `test(spec)/factories/sequences.rb` file and modify it.
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/setup'
3
+ require 'bundler/gem_tasks'
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber) do |t|
7
+ t.fork = true
8
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
9
+ end
10
+
11
+ desc "Default: run the cucumber scenarios"
12
+ task :default => :cucumber
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/factory_girl_sequences/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Anton Kalyaev"]
6
+ gem.email = ["anton.kalyaev@gmail.com"]
7
+ gem.description = %q{factory_girl_sequences provides a collection of useful FactoryGirl sequences}
8
+ gem.summary = %q{Collection of useful FactoryGirl sequences}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "factory_girl_sequences"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = FactoryGirlSequences::VERSION
17
+
18
+ gem.add_runtime_dependency('factory_girl', '~> 4.1.0')
19
+
20
+ gem.add_development_dependency('rake')
21
+ gem.add_development_dependency('cucumber', '~> 1.0.0')
22
+ gem.add_development_dependency('aruba')
23
+ gem.add_development_dependency('rails', '3.0.7')
24
+ end
@@ -0,0 +1,47 @@
1
+ Feature: automatically register sequences
2
+ Background:
3
+ When I successfully run `bundle exec rails new testapp`
4
+ And I cd to "testapp"
5
+ And I add "factory_girl_rails" as a dependency
6
+ And I add "factory_girl_sequences" from this project as a dependency
7
+ When I successfully run `bundle install`
8
+ And I write to "db/migrate/1_create_users.rb" with:
9
+ """
10
+ class CreateUsers < ActiveRecord::Migration
11
+ def self.up
12
+ create_table :users do |t|
13
+ t.string :name
14
+ end
15
+ end
16
+ end
17
+ """
18
+ When I successfully run `bundle exec rake db:migrate --trace`
19
+ And I write to "app/models/user.rb" with:
20
+ """
21
+ class User < ActiveRecord::Base
22
+ end
23
+ """
24
+
25
+ @disable-bundler
26
+ Scenario: generate a rails 3 application and use factory definitions
27
+ When I write to "test/factories.rb" with:
28
+ """
29
+ FactoryGirl.define do
30
+ factory :user do
31
+ name
32
+ end
33
+ end
34
+ """
35
+ When I write to "test/unit/user_test.rb" with:
36
+ """
37
+ require 'test_helper'
38
+
39
+ class UserTest < ActiveSupport::TestCase
40
+ test "use sequence" do
41
+ user = FactoryGirl.create(:user)
42
+ assert user.name
43
+ end
44
+ end
45
+ """
46
+ When I successfully run `bundle exec rake test --trace`
47
+ Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
@@ -0,0 +1,7 @@
1
+ When /^I add "([^"]+)" from this project as a dependency$/ do |gem_name|
2
+ append_to_file('Gemfile', %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n})
3
+ end
4
+
5
+ When /^I add "([^"]+)" as a dependency$/ do |gem_name|
6
+ append_to_file('Gemfile', %{gem "#{gem_name}"\n})
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'aruba/cucumber'
2
+
3
+ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
4
+
5
+ Before do
6
+ @aruba_timeout_seconds = 3600
7
+ end
@@ -0,0 +1,83 @@
1
+ FactoryGirl.define do
2
+ # == Basic types ==
3
+
4
+ sequence :integer do |n|
5
+ n
6
+ end
7
+
8
+ sequence :string do |n|
9
+ "string-#{n}"
10
+ end
11
+
12
+ sequence :date do
13
+ Date.today
14
+ end
15
+
16
+ sequence :datetime do
17
+ Time.current
18
+ end
19
+
20
+ sequence :boolean do |n|
21
+ [false, true][n%2]
22
+ end
23
+
24
+ # == Personal ==
25
+
26
+ sequence :name, :aliases => [:login, :first_name, :last_name] do |n|
27
+ "name-#{n}"
28
+ end
29
+
30
+ sequence :password do |n|
31
+ "password-#{n}"
32
+ end
33
+
34
+ sequence :email do |n|
35
+ "person#{n}@example.com"
36
+ end
37
+
38
+ # == Network ==
39
+
40
+ sequence :ip_address do |n|
41
+ "192.168.0.#{n%256}"
42
+ end
43
+
44
+ sequence :ip_subnet do |n|
45
+ "192.168.#{n%256}.0"
46
+ end
47
+
48
+ sequence :mac_address do |n|
49
+ "01:23:45:67:89:" + ("%02x" % "#{n%256}")
50
+ end
51
+
52
+ # == Post (article) ==
53
+
54
+ sequence :title do
55
+ "Title #{n}"
56
+ end
57
+
58
+ sequence :body, :aliases => [:description] do |n|
59
+ "body-#{n}"
60
+ end
61
+
62
+ sequence :slug do |n|
63
+ "slug-#{n}"
64
+ end
65
+
66
+ # == Other ==
67
+
68
+ sequence :domain do |n|
69
+ "example#{n}.com"
70
+ end
71
+
72
+ sequence :subdomain do |n|
73
+ "blog#{n}"
74
+ end
75
+
76
+ sequence :color do |n|
77
+ "%06d" % n
78
+ end
79
+
80
+ sequence :checksum do |n|
81
+ n
82
+ end
83
+ end
@@ -0,0 +1,3 @@
1
+ module FactoryGirlSequences
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'factory_girl_sequences/sequences'
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: factory_girl_sequences
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Anton Kalyaev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: factory_girl
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 4.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 4.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: cucumber
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: aruba
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 3.0.7
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '='
92
+ - !ruby/object:Gem::Version
93
+ version: 3.0.7
94
+ description: factory_girl_sequences provides a collection of useful FactoryGirl sequences
95
+ email:
96
+ - anton.kalyaev@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE
104
+ - README.md
105
+ - Rakefile
106
+ - factory_girl_sequences.gemspec
107
+ - features/register_sequences.feature
108
+ - features/step_definitions/rails_steps.rb
109
+ - features/support/env.rb
110
+ - lib/factory_girl_sequences.rb
111
+ - lib/factory_girl_sequences/sequences.rb
112
+ - lib/factory_girl_sequences/version.rb
113
+ homepage: ''
114
+ licenses: []
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ segments:
126
+ - 0
127
+ hash: 3825949008437557937
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ segments:
135
+ - 0
136
+ hash: 3825949008437557937
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.24
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Collection of useful FactoryGirl sequences
143
+ test_files:
144
+ - features/register_sequences.feature
145
+ - features/step_definitions/rails_steps.rb
146
+ - features/support/env.rb