factory_girl_rails 1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +6 -0
- data/Gemfile.lock +40 -0
- data/Rakefile +2 -0
- data/features/load_definitions.feature +12 -16
- data/features/step_definitions/rails_steps.rb +2 -31
- data/features/support/env.rb +3 -0
- metadata +31 -29
- data/features/support/terminal.rb +0 -36
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
aruba (0.2.3)
|
5
|
+
background_process
|
6
|
+
cucumber (~> 0.9.0)
|
7
|
+
background_process (1.2)
|
8
|
+
builder (2.1.2)
|
9
|
+
cucumber (0.9.2)
|
10
|
+
builder (~> 2.1.2)
|
11
|
+
diff-lcs (~> 1.1.2)
|
12
|
+
gherkin (~> 2.2.5)
|
13
|
+
json (~> 1.4.6)
|
14
|
+
term-ansicolor (~> 1.0.5)
|
15
|
+
diff-lcs (1.1.2)
|
16
|
+
gherkin (2.2.8)
|
17
|
+
json (~> 1.4.6)
|
18
|
+
term-ansicolor (~> 1.0.5)
|
19
|
+
json (1.4.6)
|
20
|
+
rake (0.8.7)
|
21
|
+
rspec (2.0.0)
|
22
|
+
rspec-core (= 2.0.0)
|
23
|
+
rspec-expectations (= 2.0.0)
|
24
|
+
rspec-mocks (= 2.0.0)
|
25
|
+
rspec-core (2.0.0)
|
26
|
+
rspec-expectations (2.0.0)
|
27
|
+
diff-lcs (>= 1.1.2)
|
28
|
+
rspec-mocks (2.0.0)
|
29
|
+
rspec-core (= 2.0.0)
|
30
|
+
rspec-expectations (= 2.0.0)
|
31
|
+
term-ansicolor (1.0.5)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
aruba
|
38
|
+
cucumber
|
39
|
+
rake
|
40
|
+
rspec
|
data/Rakefile
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
Feature: automatically load step definitions
|
2
2
|
|
3
|
+
@disable-bundler
|
3
4
|
Scenario: generate a rails 3 application and use factory definitions
|
4
|
-
When I
|
5
|
-
And I
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem 'sqlite3-ruby', :require => 'sqlite3'
|
10
|
-
gem 'factory_girl_rails', :path => '../../'
|
11
|
-
"""
|
12
|
-
When I run "bundle lock"
|
13
|
-
And I save the following as "db/migrate/1_create_users.rb"
|
5
|
+
When I successfully run "rails new testapp"
|
6
|
+
And I cd to "testapp"
|
7
|
+
And I add "factory_girl_rails" from this project as a dependency
|
8
|
+
When I successfully run "bundle install"
|
9
|
+
And I write to "db/migrate/1_create_users.rb" with:
|
14
10
|
"""
|
15
11
|
class CreateUsers < ActiveRecord::Migration
|
16
12
|
def self.up
|
@@ -20,19 +16,19 @@ Feature: automatically load step definitions
|
|
20
16
|
end
|
21
17
|
end
|
22
18
|
"""
|
23
|
-
When I run "rake db:migrate"
|
24
|
-
And I
|
19
|
+
When I successfully run "rake db:migrate --trace"
|
20
|
+
And I write to "app/models/user.rb" with:
|
25
21
|
"""
|
26
22
|
class User < ActiveRecord::Base
|
27
23
|
end
|
28
24
|
"""
|
29
|
-
When I
|
25
|
+
When I write to "test/factories.rb" with:
|
30
26
|
"""
|
31
27
|
Factory.define :user do |user|
|
32
28
|
user.name 'Frank'
|
33
29
|
end
|
34
30
|
"""
|
35
|
-
When I
|
31
|
+
When I write to "test/unit/user_test.rb" with:
|
36
32
|
"""
|
37
33
|
require 'test_helper'
|
38
34
|
|
@@ -43,5 +39,5 @@ Feature: automatically load step definitions
|
|
43
39
|
end
|
44
40
|
end
|
45
41
|
"""
|
46
|
-
When I run "rake test"
|
47
|
-
Then
|
42
|
+
When I successfully run "rake test --trace"
|
43
|
+
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
|
@@ -1,32 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
APP_NAME = 'testapp'.freeze
|
4
|
-
RAILS_ROOT = File.join(TEMP_ROOT, APP_NAME).freeze
|
5
|
-
|
6
|
-
Before do
|
7
|
-
FileUtils.rm_rf(TEMP_ROOT)
|
8
|
-
FileUtils.mkdir_p(TEMP_ROOT)
|
9
|
-
@terminal = Terminal.new
|
1
|
+
When /^I add "([^"]+)" from this project as a dependency$/ do |gem_name|
|
2
|
+
append_to_file('Gemfile', %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"})
|
10
3
|
end
|
11
|
-
|
12
|
-
When /^I generate a new rails application$/ do
|
13
|
-
@terminal.cd(TEMP_ROOT)
|
14
|
-
@terminal.run("rails new #{APP_NAME}")
|
15
|
-
end
|
16
|
-
|
17
|
-
When /^I save the following as "([^\"]*)"$/ do |path, string|
|
18
|
-
FileUtils.mkdir_p(File.join(RAILS_ROOT, File.dirname(path)))
|
19
|
-
File.open(File.join(RAILS_ROOT, path), 'w') { |file| file.write(string) }
|
20
|
-
end
|
21
|
-
|
22
|
-
When /^I run "([^\"]*)"$/ do |command|
|
23
|
-
@terminal.cd(RAILS_ROOT)
|
24
|
-
@terminal.run(command)
|
25
|
-
end
|
26
|
-
|
27
|
-
Then /^I should see "([^\"]*)"$/ do |expected_text|
|
28
|
-
unless @terminal.output.include?(expected_text)
|
29
|
-
raise("Got terminal output:\n#{@terminal.output}\n\nExpected output:\n#{expected_text}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Joe Ferris
|
@@ -14,30 +15,30 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-01-04 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
+
type: :runtime
|
22
23
|
prerelease: false
|
23
|
-
|
24
|
+
name: railties
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
26
|
none: false
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
30
|
+
hash: 7
|
29
31
|
segments:
|
30
32
|
- 3
|
31
33
|
- 0
|
32
34
|
- 0
|
33
|
-
|
34
|
-
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
35
|
+
version: 3.0.0
|
36
|
+
requirement: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
38
|
+
type: :runtime
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
name: factory_girl
|
41
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
42
|
none: false
|
42
43
|
requirements:
|
43
44
|
- - ~>
|
@@ -47,12 +48,12 @@ dependencies:
|
|
47
48
|
- 1
|
48
49
|
- 3
|
49
50
|
version: "1.3"
|
50
|
-
|
51
|
-
version_requirements: *id002
|
51
|
+
requirement: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
|
-
|
53
|
+
type: :development
|
54
54
|
prerelease: false
|
55
|
-
|
55
|
+
name: rake
|
56
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
57
|
none: false
|
57
58
|
requirements:
|
58
59
|
- - ">="
|
@@ -61,12 +62,12 @@ dependencies:
|
|
61
62
|
segments:
|
62
63
|
- 0
|
63
64
|
version: "0"
|
64
|
-
|
65
|
-
version_requirements: *id003
|
65
|
+
requirement: *id003
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
|
-
|
67
|
+
type: :development
|
68
68
|
prerelease: false
|
69
|
-
|
69
|
+
name: rspec
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
71
|
none: false
|
71
72
|
requirements:
|
72
73
|
- - ">="
|
@@ -75,12 +76,12 @@ dependencies:
|
|
75
76
|
segments:
|
76
77
|
- 0
|
77
78
|
version: "0"
|
78
|
-
|
79
|
-
version_requirements: *id004
|
79
|
+
requirement: *id004
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
|
81
|
+
type: :development
|
82
82
|
prerelease: false
|
83
|
-
|
83
|
+
name: cucumber
|
84
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
85
|
none: false
|
85
86
|
requirements:
|
86
87
|
- - ">="
|
@@ -89,8 +90,7 @@ dependencies:
|
|
89
90
|
segments:
|
90
91
|
- 0
|
91
92
|
version: "0"
|
92
|
-
|
93
|
-
version_requirements: *id005
|
93
|
+
requirement: *id005
|
94
94
|
description: |-
|
95
95
|
factory_girl_rails provides integration between
|
96
96
|
factory_girl and rails 3 (currently just automatic factory definition
|
@@ -103,6 +103,8 @@ extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
104
104
|
|
105
105
|
files:
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
106
108
|
- LICENSE
|
107
109
|
- Rakefile
|
108
110
|
- README.rdoc
|
@@ -110,9 +112,9 @@ files:
|
|
110
112
|
- lib/factory_girl_rails.rb
|
111
113
|
- features/load_definitions.feature
|
112
114
|
- features/step_definitions/rails_steps.rb
|
113
|
-
- features/support/
|
115
|
+
- features/support/env.rb
|
114
116
|
has_rdoc: true
|
115
|
-
homepage: http://
|
117
|
+
homepage: http://github.com/thoughtbot/factory_girl_rails
|
116
118
|
licenses: []
|
117
119
|
|
118
120
|
post_install_message:
|
@@ -148,4 +150,4 @@ summary: factory_girl_rails provides integration between factory_girl and rails
|
|
148
150
|
test_files:
|
149
151
|
- features/load_definitions.feature
|
150
152
|
- features/step_definitions/rails_steps.rb
|
151
|
-
- features/support/
|
153
|
+
- features/support/env.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
class Terminal
|
4
|
-
attr_reader :output, :status
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@cwd = FileUtils.pwd
|
8
|
-
@output = ""
|
9
|
-
@status = 0
|
10
|
-
@logger = Logger.new(File.join(TEMP_ROOT, 'terminal.log'))
|
11
|
-
end
|
12
|
-
|
13
|
-
def cd(directory)
|
14
|
-
@cwd = directory
|
15
|
-
end
|
16
|
-
|
17
|
-
def run(command)
|
18
|
-
output << "#{command}\n"
|
19
|
-
FileUtils.cd(@cwd) do
|
20
|
-
logger.debug(command)
|
21
|
-
result = `#{command} 2>&1`
|
22
|
-
logger.debug(result)
|
23
|
-
output << result
|
24
|
-
end
|
25
|
-
@status = $?
|
26
|
-
end
|
27
|
-
|
28
|
-
def echo(string)
|
29
|
-
logger.debug(string)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
attr_reader :logger
|
35
|
-
end
|
36
|
-
|