factory_girl_sequences 0.1.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,8 +1,15 @@
1
- language: ruby
2
- script: "bundle exec rake cucumber"
3
1
  rvm:
4
2
  - 1.9.2
5
3
  - 1.9.3
4
+ - jruby-19mode
5
+ before_install:
6
+ - gem update --system
7
+ - gem install turn --version 0.8.2
8
+ - gem install turn --version 0.8.3
9
+ jdk:
10
+ - openjdk6
11
+ gemfile:
12
+ - gemfiles/rails3.2.gemfile
6
13
  branches:
7
14
  only:
8
- - master
15
+ - master
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "rails3.2" do
2
+ gem "rails", "3.2.12"
3
+ gem "sass-rails"
4
+ gem "coffee-rails"
5
+ gem "uglifier"
6
+ gem "sqlite3", ">= 1.3.4", platforms: :mri
7
+ gem "activerecord-jdbcsqlite3-adapter", "~> 1.2.5", platforms: :jruby
8
+ gem "therubyrhino"
9
+ gem "jquery-rails"
10
+ gem "factory_girl_rails"
11
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 4.0.0 / 2013-02-22
2
+
3
+ * updated factory_girl version
4
+ * added appraisal
5
+ * rewrite tests
6
+ * created separate reload method
7
+
1
8
  ## 0.1.1 / 2012-10-27
2
9
 
3
10
  * Updated README
@@ -20,4 +27,4 @@
20
27
  ## 0.0.3 / 2012-10-20
21
28
 
22
29
  * Updated README
23
- * Added link to the homepage
30
+ * Added link to the homepage
data/Gemfile CHANGED
@@ -1,3 +1,8 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'rake'
6
+ gem 'appraisal', '~> 0.5.0'
7
+ gem 'cucumber', '~> 1.2.1'
8
+ gem 'aruba', '~> 0.5.1'
data/README.md CHANGED
@@ -167,11 +167,9 @@ end
167
167
 
168
168
  Check out FactoryGirl's [GETTING_STARTED](http://github.com/thoughtbot/factory_girl) for more information.
169
169
 
170
- ## Additional notes
170
+ ### Spork or tconsole
171
171
 
172
- All sequences are free to use and
173
- could be changed depending on your needs. Just copy the sequence in your
174
- project's `test(spec)/factories/sequences.rb` file and modify it.
172
+ For whose of you who are using spork or tconsole, consider adding `FactoryGirlSequences.reload` right after `FactoryGirl.reload`.
175
173
 
176
174
  ## Contributing
177
175
 
@@ -181,3 +179,13 @@ project's `test(spec)/factories/sequences.rb` file and modify it.
181
179
  4. Test your changes by running `bundle exec rake cucumber` command
182
180
  5. Push to the branch (`git push origin my-new-feature`)
183
181
  6. Create new Pull Request
182
+
183
+ ## Credits
184
+
185
+ Created by [Anton Kalyaev](http://github.com/akalyaev)
186
+
187
+ Thank you to all our amazing [contributors](http://github.com/akalyaev/factory_girl_sequences/contributors)!
188
+
189
+ ## License
190
+
191
+ FactoryGirlSequences is Copyright © 2012-2013 Anton Kalyaev. It is free software, and may be redistributed under the terms specified in the [MIT License](http://www.opensource.org/licenses/MIT) file.
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env rake
2
1
  require 'bundler/setup'
3
2
  require 'bundler/gem_tasks'
4
3
  require 'cucumber/rake/task'
@@ -8,5 +7,17 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
8
7
  t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
9
8
  end
10
9
 
11
- desc "Default: run the cucumber scenarios"
12
- task :default => :cucumber
10
+ require 'appraisal'
11
+
12
+ desc 'Run the test suite'
13
+ task :default do |t|
14
+ if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
15
+ exec 'rake cucumber'
16
+ else
17
+ Rake::Task['appraise'].execute
18
+ end
19
+ end
20
+
21
+ task :appraise => ['appraisal:install'] do |t|
22
+ exec 'rake appraisal'
23
+ end
@@ -19,10 +19,6 @@ Gem::Specification.new do |gem|
19
19
  gem.rdoc_options = %w(--line-numbers --inline-source --title factory_girl_sequences --main README.md)
20
20
  gem.extra_rdoc_files = %w(README.md CHANGELOG.md LICENSE)
21
21
 
22
- gem.add_runtime_dependency('factory_girl', '~> 4.1.0')
23
-
24
- gem.add_development_dependency('rake')
25
- gem.add_development_dependency('cucumber', '~> 1.0.0')
26
- gem.add_development_dependency('aruba')
27
- gem.add_development_dependency('rails', '3.0.7')
22
+ gem.add_dependency 'factory_girl', '~> 4.0'
23
+ gem.add_dependency 'activesupport', '>= 3.0.0'
28
24
  end
@@ -0,0 +1,26 @@
1
+ Feature:
2
+ I would like Factory Girl Sequences gem to automatically register sequences
3
+
4
+ Background:
5
+ Given I successfully run `bundle exec rails new testapp --skip-bundle`
6
+ And I cd to "testapp"
7
+ And I add "factory_girl_rails" as a dependency
8
+ And I add "factory_girl_sequences" from this project as a dependency
9
+
10
+ Scenario: Using Factory Girl Sequences registers predefined sequences
11
+ And I run `bundle install` with a clean environment
12
+ And I run `bundle exec rails generate model User name:string` with a clean environment
13
+ And I run `bundle exec rake db:migrate` with a clean environment
14
+ When I write to "test/unit/user_test.rb" with:
15
+ """
16
+ require 'test_helper'
17
+
18
+ class UserTest < ActiveSupport::TestCase
19
+ test "factory_girl should know name sequence" do
20
+ user = FactoryGirl.create(:user)
21
+ assert user.name
22
+ end
23
+ end
24
+ """
25
+ And I run `bundle exec rake test` with a clean environment
26
+ Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
@@ -0,0 +1,3 @@
1
+ When /^I run `([^"]+)` with a clean environment$/ do |command|
2
+ step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil}, "#{command}")'`}
3
+ end
@@ -4,4 +4,4 @@ end
4
4
 
5
5
  When /^I add "([^"]+)" as a dependency$/ do |gem_name|
6
6
  append_to_file('Gemfile', %{gem "#{gem_name}"\n})
7
- end
7
+ end
@@ -4,4 +4,11 @@ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).f
4
4
 
5
5
  Before do
6
6
  @aruba_timeout_seconds = 3600
7
- end
7
+ end
8
+
9
+ Aruba.configure do |config|
10
+ config.before_cmd do |cmd|
11
+ set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
12
+ set_env('JAVA_OPTS', "-d32 #{ENV['JAVA_OPTS']}") # force jRuby to use client JVM for faster startup times
13
+ end
14
+ end if RUBY_PLATFORM == 'java'
@@ -0,0 +1,19 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "appraisal", "~> 0.5.0"
7
+ gem "cucumber", "~> 1.2.1"
8
+ gem "aruba", "~> 0.5.1"
9
+ gem "rails", "3.2.12"
10
+ gem "sass-rails"
11
+ gem "coffee-rails"
12
+ gem "uglifier"
13
+ gem "sqlite3", ">= 1.3.4", :platforms=>:mri
14
+ gem "activerecord-jdbcsqlite3-adapter", "~> 1.2.5", :platforms=>:jruby
15
+ gem "therubyrhino"
16
+ gem "jquery-rails"
17
+ gem "factory_girl_rails"
18
+
19
+ gemspec :path=>"../"
@@ -0,0 +1,155 @@
1
+ PATH
2
+ remote: /home/vagrant/projects/funbox/factory_girl_sequences
3
+ specs:
4
+ factory_girl_sequences (0.1.1)
5
+ activesupport (>= 3.0.0)
6
+ factory_girl (~> 4.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.12)
12
+ actionpack (= 3.2.12)
13
+ mail (~> 2.4.4)
14
+ actionpack (3.2.12)
15
+ activemodel (= 3.2.12)
16
+ activesupport (= 3.2.12)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.4)
20
+ rack (~> 1.4.5)
21
+ rack-cache (~> 1.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.2.1)
24
+ activemodel (3.2.12)
25
+ activesupport (= 3.2.12)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.12)
28
+ activemodel (= 3.2.12)
29
+ activesupport (= 3.2.12)
30
+ arel (~> 3.0.2)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.12)
33
+ activemodel (= 3.2.12)
34
+ activesupport (= 3.2.12)
35
+ activesupport (3.2.12)
36
+ i18n (~> 0.6)
37
+ multi_json (~> 1.0)
38
+ appraisal (0.5.1)
39
+ bundler
40
+ rake
41
+ arel (3.0.2)
42
+ aruba (0.5.1)
43
+ childprocess (~> 0.3.6)
44
+ cucumber (>= 1.1.1)
45
+ rspec-expectations (>= 2.7.0)
46
+ builder (3.0.4)
47
+ childprocess (0.3.8)
48
+ ffi (~> 1.0, >= 1.0.11)
49
+ coffee-rails (3.2.2)
50
+ coffee-script (>= 2.2.0)
51
+ railties (~> 3.2.0)
52
+ coffee-script (2.2.0)
53
+ coffee-script-source
54
+ execjs
55
+ coffee-script-source (1.4.0)
56
+ cucumber (1.2.1)
57
+ builder (>= 2.1.2)
58
+ diff-lcs (>= 1.1.3)
59
+ gherkin (~> 2.11.0)
60
+ json (>= 1.4.6)
61
+ diff-lcs (1.1.3)
62
+ erubis (2.7.0)
63
+ execjs (1.4.0)
64
+ multi_json (~> 1.0)
65
+ factory_girl (4.2.0)
66
+ activesupport (>= 3.0.0)
67
+ factory_girl_rails (4.2.1)
68
+ factory_girl (~> 4.2.0)
69
+ railties (>= 3.0.0)
70
+ ffi (1.4.0)
71
+ gherkin (2.11.6)
72
+ json (>= 1.7.6)
73
+ hike (1.2.1)
74
+ i18n (0.6.1)
75
+ journey (1.0.4)
76
+ jquery-rails (2.2.1)
77
+ railties (>= 3.0, < 5.0)
78
+ thor (>= 0.14, < 2.0)
79
+ json (1.7.7)
80
+ mail (2.4.4)
81
+ i18n (>= 0.4.0)
82
+ mime-types (~> 1.16)
83
+ treetop (~> 1.4.8)
84
+ mime-types (1.21)
85
+ multi_json (1.6.1)
86
+ polyglot (0.3.3)
87
+ rack (1.4.5)
88
+ rack-cache (1.2)
89
+ rack (>= 0.4)
90
+ rack-ssl (1.3.3)
91
+ rack
92
+ rack-test (0.6.2)
93
+ rack (>= 1.0)
94
+ rails (3.2.12)
95
+ actionmailer (= 3.2.12)
96
+ actionpack (= 3.2.12)
97
+ activerecord (= 3.2.12)
98
+ activeresource (= 3.2.12)
99
+ activesupport (= 3.2.12)
100
+ bundler (~> 1.0)
101
+ railties (= 3.2.12)
102
+ railties (3.2.12)
103
+ actionpack (= 3.2.12)
104
+ activesupport (= 3.2.12)
105
+ rack-ssl (~> 1.3.2)
106
+ rake (>= 0.8.7)
107
+ rdoc (~> 3.4)
108
+ thor (>= 0.14.6, < 2.0)
109
+ rake (10.0.3)
110
+ rdoc (3.12.1)
111
+ json (~> 1.4)
112
+ rspec-expectations (2.12.1)
113
+ diff-lcs (~> 1.1.3)
114
+ sass (3.2.5)
115
+ sass-rails (3.2.6)
116
+ railties (~> 3.2.0)
117
+ sass (>= 3.1.10)
118
+ tilt (~> 1.3)
119
+ sprockets (2.2.2)
120
+ hike (~> 1.2)
121
+ multi_json (~> 1.0)
122
+ rack (~> 1.0)
123
+ tilt (~> 1.1, != 1.3.0)
124
+ sqlite3 (1.3.7)
125
+ therubyrhino (2.0.2)
126
+ therubyrhino_jar (>= 1.7.3)
127
+ therubyrhino_jar (1.7.4)
128
+ thor (0.17.0)
129
+ tilt (1.3.3)
130
+ treetop (1.4.12)
131
+ polyglot
132
+ polyglot (>= 0.3.1)
133
+ tzinfo (0.3.35)
134
+ uglifier (1.3.0)
135
+ execjs (>= 0.3.0)
136
+ multi_json (~> 1.0, >= 1.0.2)
137
+
138
+ PLATFORMS
139
+ ruby
140
+
141
+ DEPENDENCIES
142
+ activerecord-jdbcsqlite3-adapter (~> 1.2.5)
143
+ appraisal (~> 0.5.0)
144
+ aruba (~> 0.5.1)
145
+ coffee-rails
146
+ cucumber (~> 1.2.1)
147
+ factory_girl_rails
148
+ factory_girl_sequences!
149
+ jquery-rails
150
+ rails (= 3.2.12)
151
+ rake
152
+ sass-rails
153
+ sqlite3 (>= 1.3.4)
154
+ therubyrhino
155
+ uglifier
@@ -1 +1,2 @@
1
- require 'factory_girl_sequences/sequences'
1
+ require 'factory_girl_sequences/sequences'
2
+ require 'factory_girl_sequences/reload'
@@ -0,0 +1,5 @@
1
+ module FactoryGirlSequences
2
+ def self.reload
3
+ FactoryGirl.register_default_sequences
4
+ end
5
+ end
@@ -4,7 +4,7 @@ module FactoryGirl
4
4
  # basic types
5
5
  register_sequence(Sequence.new(:integer, :aliases => [:checksum]) { |n| n })
6
6
  register_sequence(Sequence.new(:string) { |n| "string-#{n}" })
7
- register_sequence(Sequence.new(:date) { Date.today })
7
+ register_sequence(Sequence.new(:date) { Date.current })
8
8
  register_sequence(Sequence.new(:datetime) { Time.current })
9
9
  register_sequence(Sequence.new(:boolean) { |n| [false, true][n%2] })
10
10
 
@@ -29,15 +29,6 @@ module FactoryGirl
29
29
  register_sequence(Sequence.new(:subdomain) { |n| "blog#{n}" })
30
30
  register_sequence(Sequence.new(:color) { |n| "%06d" % n })
31
31
  end
32
-
33
- # FIXME [AK] Monkey-patching here. There should be another way around.
34
- def self.reload
35
- reset_configuration
36
- register_default_strategies
37
- register_default_callbacks
38
- register_default_sequences
39
- find_definitions
40
- end
41
32
  end
42
33
 
43
- FactoryGirl.register_default_sequences
34
+ FactoryGirl.register_default_sequences
@@ -1,3 +1,3 @@
1
1
  module FactoryGirlSequences
2
- VERSION = "0.1.1"
2
+ VERSION = "4.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl_sequences
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 4.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-27 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: factory_girl
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 4.1.0
21
+ version: '4.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,71 +26,23 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 4.1.0
29
+ version: '4.0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: rake
31
+ name: activesupport
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
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
37
+ version: 3.0.0
38
+ type: :runtime
71
39
  prerelease: false
72
40
  version_requirements: !ruby/object:Gem::Requirement
73
41
  none: false
74
42
  requirements:
75
43
  - - ! '>='
76
44
  - !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
45
+ version: 3.0.0
94
46
  description: factory_girl_sequences provides a collection of useful FactoryGirl sequences
95
47
  email:
96
48
  - anton.kalyaev@gmail.com
@@ -104,16 +56,21 @@ files:
104
56
  - .gitignore
105
57
  - .travis.yml
106
58
  - .yardopts
59
+ - Appraisals
107
60
  - CHANGELOG.md
108
61
  - Gemfile
109
62
  - LICENSE
110
63
  - README.md
111
64
  - Rakefile
112
65
  - factory_girl_sequences.gemspec
113
- - features/register_sequences.feature
66
+ - features/sequences.feature
67
+ - features/step_definitions/appraisal.rb
114
68
  - features/step_definitions/rails_steps.rb
115
69
  - features/support/env.rb
70
+ - gemfiles/rails3.2.gemfile
71
+ - gemfiles/rails3.2.gemfile.lock
116
72
  - lib/factory_girl_sequences.rb
73
+ - lib/factory_girl_sequences/reload.rb
117
74
  - lib/factory_girl_sequences/sequences.rb
118
75
  - lib/factory_girl_sequences/version.rb
119
76
  homepage: http://github.com/akalyaev/factory_girl_sequences
@@ -136,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
93
  version: '0'
137
94
  segments:
138
95
  - 0
139
- hash: -4006842941733718079
96
+ hash: 2845564833420658873
140
97
  required_rubygems_version: !ruby/object:Gem::Requirement
141
98
  none: false
142
99
  requirements:
@@ -145,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
102
  version: '0'
146
103
  segments:
147
104
  - 0
148
- hash: -4006842941733718079
105
+ hash: 2845564833420658873
149
106
  requirements: []
150
107
  rubyforge_project:
151
108
  rubygems_version: 1.8.24
@@ -153,6 +110,7 @@ signing_key:
153
110
  specification_version: 3
154
111
  summary: Collection of useful FactoryGirl sequences
155
112
  test_files:
156
- - features/register_sequences.feature
113
+ - features/sequences.feature
114
+ - features/step_definitions/appraisal.rb
157
115
  - features/step_definitions/rails_steps.rb
158
116
  - features/support/env.rb
@@ -1,47 +0,0 @@
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"