Skip to content
Browse files

First steps towards testing

  • Loading branch information...
1 parent cf1bc40 commit e20821b71a3658072bb1bf9d4765868916c826b7 @wycats wycats committed
Showing with 56 additions and 1 deletion.
  1. +5 −1 Gemfile
  2. +12 −0 spec/build_spec.rb
  3. +16 −0 spec/spec_helper.rb
  4. +23 −0 spec/support/runner.rb
View
6 Gemfile
@@ -3,4 +3,8 @@ git "http://github.com/datamapper/dm-rails.git"
git "http://github.com/datamapper/dm-core.git"
git "http://github.com/datamapper/dm-active_model.git"
-gem "beard", :path => File.expand_path("..", __FILE__)
+gem "beard", :path => File.expand_path("..", __FILE__)
+
+group :test do
+ gem "rails", :git => "git://github.com/rails/rails.git"
+end
View
12 spec/build_spec.rb
@@ -0,0 +1,12 @@
+require "spec_helper"
+
+describe "generating a Rails app with the beard builder" do
+ before do
+ wipe_tmp
+ generate_beard
+ end
+
+ it "is true" do
+ true.should == true
+ end
+end
View
16 spec/spec_helper.rb
@@ -0,0 +1,16 @@
+require "rspec"
+require "support/runner"
+
+Rspec.configure do |config|
+ config.include Spec::BeardRunner
+
+ original_wd = Dir.pwd
+
+ config.before do
+ Dir.chdir(root)
+ end
+
+ config.after do
+ Dir.chdir(original_wd)
+ end
+end
View
23 spec/support/runner.rb
@@ -0,0 +1,23 @@
+require "pathname"
+
+module Spec
+ module BeardRunner
+ def beard_root
+ Pathname.new(File.expand_path("../../..", __FILE__))
+ end
+
+ def root
+ beard_root.join("tmp")
+ end
+
+ def wipe_tmp
+ FileUtils.rm_rf(root)
+ FileUtils.mkdir_p(root)
+ end
+
+ def generate_beard
+ beard_builder = beard_root.join("lib/beard/app_builder.rb")
+ system "rails temp_app -b #{beard_root}"
+ end
+ end
+end

0 comments on commit e20821b

Please sign in to comment.
Something went wrong with that request. Please try again.