From 9a874a83229ec30e9a648558303155795c448a1f Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Tue, 4 Jan 2011 17:44:01 -0500 Subject: [PATCH] Backported fixes from 1.1 --- .bundle/config | 2 ++ .gitignore | 1 + Gemfile | 6 ++++ Gemfile.lock | 40 ++++++++++++++++++++++++ Rakefile | 2 ++ factory_girl_rails.gemspec | 4 +-- features/load_definitions.feature | 28 +++++++---------- features/step_definitions/rails_steps.rb | 33 ++----------------- features/support/env.rb | 3 ++ features/support/terminal.rb | 36 --------------------- 10 files changed, 70 insertions(+), 85 deletions(-) create mode 100644 .bundle/config create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 features/support/env.rb delete mode 100644 features/support/terminal.rb diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000..8ebbe30 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_DISABLE_SHARED_GEMS: "1" diff --git a/.gitignore b/.gitignore index dc313f6..bd72a09 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ factory_girl-*.gem tmp rdoc coverage +pkg diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..dd8b0f1 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source "http://rubygems.org" +gem "cucumber" +gem "aruba" +gem "rake" +gem "rspec" + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..4e57b0b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,40 @@ +GEM + remote: http://rubygems.org/ + specs: + aruba (0.2.3) + background_process + cucumber (~> 0.9.0) + background_process (1.2) + builder (2.1.2) + cucumber (0.9.2) + builder (~> 2.1.2) + diff-lcs (~> 1.1.2) + gherkin (~> 2.2.5) + json (~> 1.4.6) + term-ansicolor (~> 1.0.5) + diff-lcs (1.1.2) + gherkin (2.2.8) + json (~> 1.4.6) + term-ansicolor (~> 1.0.5) + json (1.4.6) + rake (0.8.7) + rspec (2.0.0) + rspec-core (= 2.0.0) + rspec-expectations (= 2.0.0) + rspec-mocks (= 2.0.0) + rspec-core (2.0.0) + rspec-expectations (2.0.0) + diff-lcs (>= 1.1.2) + rspec-mocks (2.0.0) + rspec-core (= 2.0.0) + rspec-expectations (= 2.0.0) + term-ansicolor (1.0.5) + +PLATFORMS + ruby + +DEPENDENCIES + aruba + cucumber + rake + rspec diff --git a/Rakefile b/Rakefile index caf838a..0c955a1 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +require 'rubygems' +require 'bundler/setup' require 'rake/gempackagetask' require 'cucumber/rake/task' diff --git a/factory_girl_rails.gemspec b/factory_girl_rails.gemspec index baef821..b7ab7d7 100644 --- a/factory_girl_rails.gemspec +++ b/factory_girl_rails.gemspec @@ -11,8 +11,8 @@ Gem::Specification.new do |s| s.test_files = Dir['spec/**/*_spec.rb', 'features/**/*'] s.authors = ["Joe Ferris"] s.email = %q{jferris@thoughtbot.com} - s.homepage = "http://thoughtbot.com/projects/factory_girl_rails" - s.add_runtime_dependency('rails', '>= 3.0.0.beta4') + s.homepage = "http://github.com/thoughtbot/factory_girl_rails" + s.add_runtime_dependency('railties', '>= 3.0.0') s.add_runtime_dependency('factory_girl', '~> 1.3') s.add_development_dependency('rake') s.add_development_dependency('rspec') diff --git a/features/load_definitions.feature b/features/load_definitions.feature index 44e9b70..cb36281 100644 --- a/features/load_definitions.feature +++ b/features/load_definitions.feature @@ -1,16 +1,12 @@ Feature: automatically load step definitions + @disable-bundler Scenario: generate a rails 3 application and use factory definitions - When I generate a new rails application - And I save the following as "Gemfile" - """ - source "http://rubygems.org" - gem 'rails', '3.0.0.beta4' - gem 'sqlite3-ruby', :require => 'sqlite3' - gem 'factory_girl_rails', :path => '../../' - """ - When I run "bundle lock" - And I save the following as "db/migrate/1_create_users.rb" + When I successfully run "rails new testapp" + And I cd to "testapp" + And I add "factory_girl_rails" from this project as a dependency + When I successfully run "bundle install" + And I write to "db/migrate/1_create_users.rb" with: """ class CreateUsers < ActiveRecord::Migration def self.up @@ -20,19 +16,19 @@ Feature: automatically load step definitions end end """ - When I run "rake db:migrate" - And I save the following as "app/models/user.rb" + When I successfully run "rake db:migrate --trace" + And I write to "app/models/user.rb" with: """ class User < ActiveRecord::Base end """ - When I save the following as "test/factories.rb" + When I write to "test/factories.rb" with: """ Factory.define :user do |user| user.name 'Frank' end """ - When I save the following as "test/unit/user_test.rb" + When I write to "test/unit/user_test.rb" with: """ require 'test_helper' @@ -43,5 +39,5 @@ Feature: automatically load step definitions end end """ - When I run "rake test" - Then I should see "1 tests, 1 assertions, 0 failures, 0 errors" + When I successfully run "rake test --trace" + Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors" diff --git a/features/step_definitions/rails_steps.rb b/features/step_definitions/rails_steps.rb index 0ce1f92..18bc3a5 100644 --- a/features/step_definitions/rails_steps.rb +++ b/features/step_definitions/rails_steps.rb @@ -1,32 +1,3 @@ -PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze -TEMP_ROOT = File.join(PROJECT_ROOT, 'tmp').freeze -APP_NAME = 'testapp'.freeze -RAILS_ROOT = File.join(TEMP_ROOT, APP_NAME).freeze - -Before do - FileUtils.rm_rf(TEMP_ROOT) - FileUtils.mkdir_p(TEMP_ROOT) - @terminal = Terminal.new +When /^I add "([^"]+)" from this project as a dependency$/ do |gem_name| + append_to_file('Gemfile', %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"}) end - -When /^I generate a new rails application$/ do - @terminal.cd(TEMP_ROOT) - @terminal.run("rails new #{APP_NAME}") -end - -When /^I save the following as "([^\"]*)"$/ do |path, string| - FileUtils.mkdir_p(File.join(RAILS_ROOT, File.dirname(path))) - File.open(File.join(RAILS_ROOT, path), 'w') { |file| file.write(string) } -end - -When /^I run "([^\"]*)"$/ do |command| - @terminal.cd(RAILS_ROOT) - @terminal.run(command) -end - -Then /^I should see "([^\"]*)"$/ do |expected_text| - unless @terminal.output.include?(expected_text) - raise("Got terminal output:\n#{@terminal.output}\n\nExpected output:\n#{expected_text}") - end -end - diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..8631cf1 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,3 @@ +require 'aruba' + +PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze diff --git a/features/support/terminal.rb b/features/support/terminal.rb deleted file mode 100644 index c4b5bd0..0000000 --- a/features/support/terminal.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'fileutils' - -class Terminal - attr_reader :output, :status - - def initialize - @cwd = FileUtils.pwd - @output = "" - @status = 0 - @logger = Logger.new(File.join(TEMP_ROOT, 'terminal.log')) - end - - def cd(directory) - @cwd = directory - end - - def run(command) - output << "#{command}\n" - FileUtils.cd(@cwd) do - logger.debug(command) - result = `#{command} 2>&1` - logger.debug(result) - output << result - end - @status = $? - end - - def echo(string) - logger.debug(string) - end - - private - - attr_reader :logger -end -