Permalink
Browse files

Use aruba (based on patches from Mike Gehard)

  • Loading branch information...
1 parent c340abd commit 98b00ce10afc97b8df183d8043555533e5f60c9c @jferris jferris committed Nov 10, 2010
@@ -1,16 +1,11 @@
Feature: automatically load step definitions
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'
- 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 +15,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"
+ 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 +38,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"
+ Then the output should contain "1 tests, 1 assertions, 0 failures, 0 errors"
@@ -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
-
View
@@ -0,0 +1,3 @@
+require 'aruba'
+
+PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
@@ -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
-

0 comments on commit 98b00ce

Please sign in to comment.