challah 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -2
- data/README.md +18 -18
- data/lib/challah/test.rb +22 -5
- data/lib/challah/version.rb +1 -1
- data/test/audit_test.rb +32 -32
- data/test/controller_test.rb +9 -9
- data/test/cookie_store_test.rb +25 -25
- data/test/factories.rb +7 -7
- data/test/helper.rb +14 -12
- data/test/permission_test.rb +14 -14
- data/test/restrictions_controller_test.rb +29 -30
- data/test/role_test.rb +26 -26
- data/test/session_test.rb +65 -65
- data/test/sessions_controller_test.rb +13 -13
- data/test/simple_cookie_store_test.rb +25 -25
- data/test/user_test.rb +79 -79
- data/vendor/bundle/cache/factory_girl-3.0.0.gem +0 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/Appraisals +11 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/CONTRIBUTION_GUIDELINES.md +10 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/Changelog +168 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/GETTING_STARTED.md +735 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/Gemfile +5 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/Gemfile.lock +95 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/LICENSE +19 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/README.md +70 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/Rakefile +38 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/cucumber.yml +1 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/factory_girl.gemspec +38 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/features/factory_girl_steps.feature +237 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/features/find_definitions.feature +75 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/features/step_definitions/database_steps.rb +42 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/features/step_definitions/factory_girl_steps.rb +43 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/features/support/env.rb +11 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/features/support/factories.rb +119 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/gemfiles/2.3.gemfile +7 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/gemfiles/3.0.gemfile +7 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/gemfiles/3.0.gemfile.lock +86 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/gemfiles/3.1.gemfile +7 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/gemfiles/3.1.gemfile.lock +95 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/gemfiles/3.2.gemfile +7 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/gemfiles/3.2.gemfile.lock +93 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl.rb +69 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/aliases.rb +19 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/attribute.rb +40 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/attribute/association.rb +23 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/attribute/dynamic.rb +20 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/attribute/sequence.rb +17 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/attribute/static.rb +15 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/attribute_assigner.rb +73 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/attribute_list.rb +54 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/callback.rb +33 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/declaration.rb +22 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/declaration/association.rb +25 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/declaration/dynamic.rb +25 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/declaration/implicit.rb +32 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/declaration/static.rb +25 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/declaration_list.rb +48 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/definition.rb +76 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/definition_proxy.rb +159 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/errors.rb +19 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/evaluator.rb +76 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/evaluator_class_definer.rb +34 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/factory.rb +145 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/factory_runner.rb +24 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/find_definitions.rb +25 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/null_factory.rb +15 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/null_object.rb +7 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/registry.rb +46 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/reload.rb +8 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/sequence.rb +24 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/step_definitions.rb +130 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/strategy.rb +32 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/strategy/attributes_for.rb +12 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/strategy/build.rb +15 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/strategy/create.rb +17 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/strategy/stub.rb +61 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/strategy_calculator.rb +29 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax.rb +16 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/blueprint.rb +42 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/default.rb +56 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/generate.rb +70 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb +45 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/methods.rb +136 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/sham.rb +45 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/vintage.rb +130 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/trait.rb +29 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/version.rb +4 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/aliases_spec.rb +19 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/attribute_aliases_spec.rb +45 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/attribute_existing_on_object_spec.rb +68 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/attributes_for_spec.rb +89 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/attributes_from_instance_spec.rb +53 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/attributes_ordered_spec.rb +51 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/build_list_spec.rb +41 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/build_spec.rb +89 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/build_stubbed_spec.rb +104 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/callbacks_spec.rb +47 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/create_list_spec.rb +82 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/create_spec.rb +117 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/define_child_before_parent_spec.rb +21 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/definition_spec.rb +26 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/definition_without_block_spec.rb +15 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/initialize_with_spec.rb +147 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/modify_factories_spec.rb +184 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/modify_inherited_spec.rb +52 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/nested_attributes_spec.rb +32 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/overrides_spec.rb +61 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/parent_spec.rb +90 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/sequence_spec.rb +33 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/stub_spec.rb +62 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb +34 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/generate_spec.rb +59 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/make_spec.rb +52 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/sham_spec.rb +43 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/vintage_spec.rb +217 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/traits_spec.rb +421 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/transient_attributes_spec.rb +124 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/aliases_spec.rb +31 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/attribute/association_spec.rb +28 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/attribute/dynamic_spec.rb +52 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/attribute/sequence_spec.rb +16 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/attribute/static_spec.rb +19 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/attribute_list_spec.rb +78 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/attribute_spec.rb +16 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/callback_spec.rb +41 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/declaration/implicit_spec.rb +25 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/declaration_list_spec.rb +71 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/definition_proxy_spec.rb +197 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/definition_spec.rb +104 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/evaluator_class_definer_spec.rb +54 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/factory_spec.rb +279 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/find_definitions_spec.rb +110 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/null_factory_spec.rb +13 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/null_object_spec.rb +8 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/registry_spec.rb +81 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/sequence_spec.rb +47 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/strategy/attributes_for_spec.rb +18 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/strategy/build_spec.rb +7 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/strategy/create_spec.rb +13 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/strategy/stub_spec.rb +40 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/strategy_calculator_spec.rb +33 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl/strategy_spec.rb +21 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/factory_girl_spec.rb +22 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/spec_helper.rb +26 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/support/macros/define_constant.rb +86 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/support/matchers/callback.rb +9 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/support/matchers/declaration.rb +71 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/support/matchers/delegate.rb +44 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/support/matchers/trait.rb +9 -0
- data/vendor/bundle/gems/factory_girl-3.0.0/spec/support/shared_examples/strategy.rb +104 -0
- data/vendor/bundle/specifications/factory_girl-3.0.0.gemspec +62 -0
- metadata +147 -12
@@ -0,0 +1,75 @@
|
|
1
|
+
Feature: Factory girl can find factory definitions correctly
|
2
|
+
Scenario: Find definitions with a path
|
3
|
+
Given a file named "awesome_factories.rb" with:
|
4
|
+
"""
|
5
|
+
FactoryGirl.define do
|
6
|
+
factory :awesome_category, :class => Category do
|
7
|
+
name "awesome!!!"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
"""
|
11
|
+
When "awesome_factories.rb" is added to Factory Girl's file definitions path
|
12
|
+
And I create a "awesome_category" instance from Factory Girl
|
13
|
+
Then I should find the following for the last category:
|
14
|
+
| name |
|
15
|
+
| awesome!!! |
|
16
|
+
|
17
|
+
Scenario: Find definitions with an absolute path
|
18
|
+
Given a file named "awesome_factories.rb" with:
|
19
|
+
"""
|
20
|
+
FactoryGirl.define do
|
21
|
+
factory :another_awesome_category, :class => Category do
|
22
|
+
name "awesome!!!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
"""
|
26
|
+
When "awesome_factories.rb" is added to Factory Girl's file definitions path as an absolute path
|
27
|
+
And I create a "another_awesome_category" instance from Factory Girl
|
28
|
+
Then I should find the following for the last category:
|
29
|
+
| name |
|
30
|
+
| awesome!!! |
|
31
|
+
|
32
|
+
Scenario: Find definitions with a folder
|
33
|
+
Given a file named "nested/great_factories.rb" with:
|
34
|
+
"""
|
35
|
+
FactoryGirl.define do
|
36
|
+
factory :great_category, :class => Category do
|
37
|
+
name "great!!!"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
When "nested" is added to Factory Girl's file definitions path
|
42
|
+
And I create a "great_category" instance from Factory Girl
|
43
|
+
Then I should find the following for the last category:
|
44
|
+
| name |
|
45
|
+
| great!!! |
|
46
|
+
|
47
|
+
Scenario: Reload Factory Girl
|
48
|
+
Given a file named "nested/reload_factories.rb" with:
|
49
|
+
"""
|
50
|
+
FactoryGirl.define do
|
51
|
+
sequence(:great)
|
52
|
+
trait :admin do
|
53
|
+
admin true
|
54
|
+
end
|
55
|
+
|
56
|
+
factory :handy_category, :class => Category do
|
57
|
+
name "handy"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
"""
|
61
|
+
When "nested" is added to Factory Girl's file definitions path
|
62
|
+
And I append to "nested/reload_factories.rb" with:
|
63
|
+
"""
|
64
|
+
|
65
|
+
FactoryGirl.modify do
|
66
|
+
factory :handy_category do
|
67
|
+
name "HANDY!!!"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
"""
|
71
|
+
And I reload factories
|
72
|
+
And I create a "handy_category" instance from Factory Girl
|
73
|
+
Then I should find the following for the last category:
|
74
|
+
| name |
|
75
|
+
| HANDY!!! |
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Then /^I should find the following for the last (.*):$/ do |model, table|
|
2
|
+
model_class = model.camelize.constantize
|
3
|
+
last_instance = model_class.last or raise "No #{model.pluralize} exist"
|
4
|
+
table.hashes.first.each do |key, value|
|
5
|
+
last_instance.attributes[key].to_s.should == value
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^there should be (\d+) (.*)$/ do |count, model|
|
10
|
+
model_class = model.singularize.camelize.constantize
|
11
|
+
model_class.count.should == count.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^the post "([^"]*)" should (not )?have the following tags?:$/ do |post_title, negate, table|
|
15
|
+
post = Post.find_by_title!(post_title)
|
16
|
+
|
17
|
+
table.hashes.each do |row|
|
18
|
+
tag = Tag.find_by_name(row[:name])
|
19
|
+
|
20
|
+
if negate
|
21
|
+
post.tags.should_not include(tag)
|
22
|
+
else
|
23
|
+
post.tags.should include(tag)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Transform /^table:(?:.*,)?tags(?:,.*)?$/ do |table|
|
29
|
+
table.map_column!("tags") do |tags|
|
30
|
+
tags.split(',').map {|tag| Tag.find_by_name! tag.strip }
|
31
|
+
end
|
32
|
+
table
|
33
|
+
end
|
34
|
+
|
35
|
+
Before do
|
36
|
+
Post.delete_all
|
37
|
+
Tag.delete_all
|
38
|
+
User.delete_all
|
39
|
+
Category.delete_all
|
40
|
+
CategoryGroup.delete_all
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module FactoryGirlDefinitionsHelper
|
2
|
+
def append_file_to_factory_girl_definitions_path(path_to_file)
|
3
|
+
FactoryGirl.definition_file_paths ||= []
|
4
|
+
FactoryGirl.definition_file_paths << path_to_file
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
World(FactoryGirlDefinitionsHelper)
|
9
|
+
|
10
|
+
When /^"([^"]*)" is added to Factory Girl's file definitions path$/ do |file_name|
|
11
|
+
new_factory_file = File.join(current_dir, file_name.gsub(".rb", ""))
|
12
|
+
|
13
|
+
append_file_to_factory_girl_definitions_path(new_factory_file)
|
14
|
+
|
15
|
+
When %{I find definitions}
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^"([^"]*)" is added to Factory Girl's file definitions path as an absolute path$/ do |file_name|
|
19
|
+
new_factory_file = File.expand_path(File.join(current_dir, file_name.gsub(".rb", "")))
|
20
|
+
|
21
|
+
append_file_to_factory_girl_definitions_path(new_factory_file)
|
22
|
+
|
23
|
+
When %{I find definitions}
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^I create a "([^"]*)" instance from Factory Girl$/ do |factory_name|
|
27
|
+
FactoryGirl.create(factory_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
Given /^these super users exist:$/ do |table|
|
31
|
+
headers = table.headers + ["admin"]
|
32
|
+
rows = table.rows.map { |row| row + [true] }
|
33
|
+
new_table = Cucumber::Ast::Table.new([headers] + rows)
|
34
|
+
Given %{the following person exists:}, new_table
|
35
|
+
end
|
36
|
+
|
37
|
+
When /^I find definitions$/ do
|
38
|
+
FactoryGirl.find_definitions
|
39
|
+
end
|
40
|
+
|
41
|
+
When /^I reload factories$/ do
|
42
|
+
FactoryGirl.reload
|
43
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
ActiveRecord::Base.establish_connection(
|
2
|
+
:adapter => 'sqlite3',
|
3
|
+
:database => File.join(File.dirname(__FILE__), 'test.db')
|
4
|
+
)
|
5
|
+
|
6
|
+
class CreateSchema < ActiveRecord::Migration
|
7
|
+
def self.up
|
8
|
+
create_table :posts, :force => true do |t|
|
9
|
+
t.integer :author_id
|
10
|
+
t.integer :category_id
|
11
|
+
t.string :title
|
12
|
+
t.string :body
|
13
|
+
end
|
14
|
+
|
15
|
+
create_table :category_groups, :force => true do |t|
|
16
|
+
t.string :name
|
17
|
+
end
|
18
|
+
|
19
|
+
create_table :categories, :force => true do |t|
|
20
|
+
t.integer :category_group_id
|
21
|
+
t.string :name
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table :tags, :force => true do |t|
|
25
|
+
t.integer :post_id
|
26
|
+
t.string :name
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table :users, :force => true do |t|
|
30
|
+
t.string :name
|
31
|
+
t.boolean :admin, :default => false, :null => false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
CreateSchema.suppress_messages { CreateSchema.migrate(:up) }
|
37
|
+
|
38
|
+
class User < ActiveRecord::Base
|
39
|
+
end
|
40
|
+
|
41
|
+
class CategoryGroup < ActiveRecord::Base
|
42
|
+
end
|
43
|
+
|
44
|
+
class Category < ActiveRecord::Base
|
45
|
+
belongs_to :category_group
|
46
|
+
end
|
47
|
+
|
48
|
+
class Post < ActiveRecord::Base
|
49
|
+
belongs_to :author, :class_name => 'User'
|
50
|
+
belongs_to :category
|
51
|
+
has_many :tags
|
52
|
+
end
|
53
|
+
|
54
|
+
class Tag < ActiveRecord::Base
|
55
|
+
belongs_to :post
|
56
|
+
end
|
57
|
+
|
58
|
+
class NonActiveRecord
|
59
|
+
end
|
60
|
+
|
61
|
+
class SimpleColumn
|
62
|
+
def self.columns
|
63
|
+
[:name]
|
64
|
+
end
|
65
|
+
|
66
|
+
def save!
|
67
|
+
@@count ||= 0
|
68
|
+
@@count += 1
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.count
|
72
|
+
@@count
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
FactoryGirl.define do
|
77
|
+
# To make sure the step defs work with an email
|
78
|
+
sequence :email do |n|
|
79
|
+
"email#{n}@example.com"
|
80
|
+
end
|
81
|
+
|
82
|
+
factory :user, :aliases => [:person] do
|
83
|
+
factory :admin_user do
|
84
|
+
admin true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
factory :category do
|
89
|
+
name "programming"
|
90
|
+
category_group
|
91
|
+
end
|
92
|
+
|
93
|
+
factory :category_group do
|
94
|
+
name "tecnhology"
|
95
|
+
end
|
96
|
+
|
97
|
+
factory :post do
|
98
|
+
association :author, :factory => :user
|
99
|
+
category
|
100
|
+
end
|
101
|
+
|
102
|
+
factory :titled_post, :parent => :post do
|
103
|
+
title 'A Post with a Title'
|
104
|
+
end
|
105
|
+
|
106
|
+
factory :tag do
|
107
|
+
post
|
108
|
+
end
|
109
|
+
# This is here to ensure that factory step definitions don't raise for a non-AR factory
|
110
|
+
factory :non_active_record do
|
111
|
+
end
|
112
|
+
|
113
|
+
# This is here to make FG work with ORMs that have `columns => [:name, :admin, :etc]` on the class (Neo4j)
|
114
|
+
factory :simple_column do
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
require 'factory_girl/step_definitions'
|
119
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/joshuaclayton/dev/gems/factory_girl
|
3
|
+
specs:
|
4
|
+
factory_girl (3.0.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (3.0.9)
|
11
|
+
activesupport (= 3.0.9)
|
12
|
+
builder (~> 2.1.2)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
activerecord (3.0.9)
|
15
|
+
activemodel (= 3.0.9)
|
16
|
+
activesupport (= 3.0.9)
|
17
|
+
arel (~> 2.0.10)
|
18
|
+
tzinfo (~> 0.3.23)
|
19
|
+
activesupport (3.0.9)
|
20
|
+
appraisal (0.3.8)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
arel (2.0.10)
|
24
|
+
aruba (0.3.7)
|
25
|
+
childprocess (>= 0.1.9)
|
26
|
+
cucumber (>= 0.10.5)
|
27
|
+
rspec (>= 2.6.0)
|
28
|
+
bluecloth (2.1.0)
|
29
|
+
bourne (1.0)
|
30
|
+
mocha (= 0.9.8)
|
31
|
+
builder (2.1.2)
|
32
|
+
childprocess (0.1.9)
|
33
|
+
ffi (~> 1.0.6)
|
34
|
+
cucumber (1.0.0)
|
35
|
+
builder (>= 2.1.2)
|
36
|
+
diff-lcs (>= 1.1.2)
|
37
|
+
gherkin (~> 2.4.1)
|
38
|
+
json (>= 1.4.6)
|
39
|
+
term-ansicolor (>= 1.0.5)
|
40
|
+
diff-lcs (1.1.2)
|
41
|
+
ffi (1.0.9)
|
42
|
+
gherkin (2.4.1)
|
43
|
+
json (>= 1.4.6)
|
44
|
+
i18n (0.5.0)
|
45
|
+
json (1.5.3)
|
46
|
+
mocha (0.9.8)
|
47
|
+
rake
|
48
|
+
multi_json (1.1.0)
|
49
|
+
rake (0.9.2)
|
50
|
+
rspec (2.6.0)
|
51
|
+
rspec-core (~> 2.6.0)
|
52
|
+
rspec-expectations (~> 2.6.0)
|
53
|
+
rspec-mocks (~> 2.6.0)
|
54
|
+
rspec-core (2.6.4)
|
55
|
+
rspec-expectations (2.6.0)
|
56
|
+
diff-lcs (~> 1.1.2)
|
57
|
+
rspec-mocks (2.6.0)
|
58
|
+
simplecov (0.6.1)
|
59
|
+
multi_json (~> 1.0)
|
60
|
+
simplecov-html (~> 0.5.3)
|
61
|
+
simplecov-html (0.5.3)
|
62
|
+
sqlite3 (1.3.3)
|
63
|
+
sqlite3-ruby (1.3.3)
|
64
|
+
sqlite3 (>= 1.3.3)
|
65
|
+
term-ansicolor (1.0.5)
|
66
|
+
timecop (0.3.5)
|
67
|
+
tzinfo (0.3.28)
|
68
|
+
yard (0.7.2)
|
69
|
+
|
70
|
+
PLATFORMS
|
71
|
+
ruby
|
72
|
+
|
73
|
+
DEPENDENCIES
|
74
|
+
activerecord (~> 3.0)
|
75
|
+
appraisal (~> 0.3.8)
|
76
|
+
aruba
|
77
|
+
bluecloth
|
78
|
+
bourne
|
79
|
+
cucumber (~> 1.0.0)
|
80
|
+
factory_girl!
|
81
|
+
mocha
|
82
|
+
rspec (~> 2.0)
|
83
|
+
simplecov
|
84
|
+
sqlite3-ruby
|
85
|
+
timecop
|
86
|
+
yard
|
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/joshuaclayton/dev/gems/factory_girl
|
3
|
+
specs:
|
4
|
+
factory_girl (3.0.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (3.1.0)
|
11
|
+
activesupport (= 3.1.0)
|
12
|
+
bcrypt-ruby (~> 3.0.0)
|
13
|
+
builder (~> 3.0.0)
|
14
|
+
i18n (~> 0.6)
|
15
|
+
activerecord (3.1.0)
|
16
|
+
activemodel (= 3.1.0)
|
17
|
+
activesupport (= 3.1.0)
|
18
|
+
arel (~> 2.2.1)
|
19
|
+
tzinfo (~> 0.3.29)
|
20
|
+
activesupport (3.1.0)
|
21
|
+
multi_json (~> 1.0)
|
22
|
+
appraisal (0.3.8)
|
23
|
+
bundler
|
24
|
+
rake
|
25
|
+
arel (2.2.1)
|
26
|
+
aruba (0.4.5)
|
27
|
+
bcat (>= 0.6.1)
|
28
|
+
childprocess (>= 0.1.9)
|
29
|
+
cucumber (>= 0.10.7)
|
30
|
+
rdiscount (>= 1.6.8)
|
31
|
+
rspec (>= 2.6.0)
|
32
|
+
bcat (0.6.1)
|
33
|
+
rack (~> 1.0)
|
34
|
+
bcrypt-ruby (3.0.0)
|
35
|
+
bluecloth (2.1.0)
|
36
|
+
bourne (1.0)
|
37
|
+
mocha (= 0.9.8)
|
38
|
+
builder (3.0.0)
|
39
|
+
childprocess (0.2.1)
|
40
|
+
ffi (~> 1.0.6)
|
41
|
+
cucumber (1.0.2)
|
42
|
+
builder (>= 2.1.2)
|
43
|
+
diff-lcs (>= 1.1.2)
|
44
|
+
gherkin (~> 2.4.5)
|
45
|
+
json (>= 1.4.6)
|
46
|
+
term-ansicolor (>= 1.0.5)
|
47
|
+
diff-lcs (1.1.3)
|
48
|
+
ffi (1.0.9)
|
49
|
+
gherkin (2.4.16)
|
50
|
+
json (>= 1.4.6)
|
51
|
+
i18n (0.6.0)
|
52
|
+
json (1.5.4)
|
53
|
+
mocha (0.9.8)
|
54
|
+
rake
|
55
|
+
multi_json (1.0.3)
|
56
|
+
rack (1.3.2)
|
57
|
+
rake (0.9.2)
|
58
|
+
rdiscount (1.6.8)
|
59
|
+
rspec (2.6.0)
|
60
|
+
rspec-core (~> 2.6.0)
|
61
|
+
rspec-expectations (~> 2.6.0)
|
62
|
+
rspec-mocks (~> 2.6.0)
|
63
|
+
rspec-core (2.6.4)
|
64
|
+
rspec-expectations (2.6.0)
|
65
|
+
diff-lcs (~> 1.1.2)
|
66
|
+
rspec-mocks (2.6.0)
|
67
|
+
simplecov (0.6.1)
|
68
|
+
multi_json (~> 1.0)
|
69
|
+
simplecov-html (~> 0.5.3)
|
70
|
+
simplecov-html (0.5.3)
|
71
|
+
sqlite3 (1.3.4)
|
72
|
+
sqlite3-ruby (1.3.3)
|
73
|
+
sqlite3 (>= 1.3.3)
|
74
|
+
term-ansicolor (1.0.6)
|
75
|
+
timecop (0.3.5)
|
76
|
+
tzinfo (0.3.29)
|
77
|
+
yard (0.7.2)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
activerecord (~> 3.1)
|
84
|
+
appraisal (~> 0.3.8)
|
85
|
+
aruba
|
86
|
+
bluecloth
|
87
|
+
bourne
|
88
|
+
cucumber (~> 1.0.0)
|
89
|
+
factory_girl!
|
90
|
+
mocha
|
91
|
+
rspec (~> 2.0)
|
92
|
+
simplecov
|
93
|
+
sqlite3-ruby
|
94
|
+
timecop
|
95
|
+
yard
|