Permalink
Browse files

cucumber scenario to test Tweaked factory_girls_initialization process

  • Loading branch information...
1 parent 191ce5e commit 06861a9fdb0b62a2d5b90adc8934909fb243afe1 @cryo28 cryo28 committed Nov 30, 2011
Showing with 43 additions and 3 deletions.
  1. +43 −3 features/load_definitions.feature
@@ -1,7 +1,5 @@
Feature: automatically load step definitions
-
- @disable-bundler
- Scenario: generate a rails 3 application and use factory definitions
+ Background:
When I successfully run `bundle exec rails new testapp`
And I cd to "testapp"
And I add "factory_girl_rails" from this project as a dependency
@@ -22,6 +20,9 @@ Feature: automatically load step definitions
class User < ActiveRecord::Base
end
"""
+
+ @disable-bundler
+ Scenario: generate a rails 3 application and use factory definitions
When I write to "test/factories.rb" with:
"""
FactoryGirl.define do
@@ -43,3 +44,42 @@ Feature: automatically load step definitions
"""
When I successfully run `bundle exec rake test --trace`
Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
+
+ @disable-bundler
+ Scenario: use factories advertised by railties/engines/3rd-party gems
+ When I append to "config/application.rb" with:
+ """
+ require File.expand_path('../../lib/some_railtie/railties.rb', __FILE__)
+ """
+ When I write to "lib/some_railtie/railties.rb" with:
+ """
+ module SomeRailtie
+ class Railtie < ::Rails::Engine
+
+ initializer "some_railtie.factories", :after => "factory_girl.set_factory_paths" do
+ FactoryGirl.definition_file_paths << File.expand_path('../factories', __FILE__)
+ end
+ end
+ end
+ """
+ When I write to "lib/some_railtie/factories.rb" with:
+ """
+ FactoryGirl.define do
+ factory :factory_from_some_railtie, :class => 'User' do
+ name 'Artem'
+ end
+ end
+ """
+ When I write to "test/unit/user_test.rb" with:
+ """
+ require 'test_helper'
+
+ class UserTest < ActiveSupport::TestCase
+ test "use factory of some_railtie" do
+ user = FactoryGirl.create(:factory_from_some_railtie)
+ assert_equal 'Artem', user.name
+ end
+ end
+ """
+ When I successfully run `bundle exec rake test --trace`
+ Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"

0 comments on commit 06861a9

Please sign in to comment.