OSDN Git Service

generate rspec
authorshimada <shimada.cake@gmail.com>
Sat, 24 Apr 2010 17:09:02 +0000 (02:09 +0900)
committershimada <shimada.cake@gmail.com>
Sat, 24 Apr 2010 17:09:02 +0000 (02:09 +0900)
config/environments/test.rb
script/autospec [new file with mode: 0755]
script/spec [new file with mode: 0755]
spec/rcov.opts [new file with mode: 0644]
spec/spec.opts [new file with mode: 0644]
spec/spec_helper.rb [new file with mode: 0644]

index d6f80a4..ed10555 100644 (file)
@@ -25,4 +25,7 @@ config.action_mailer.delivery_method = :test
 # Use SQL instead of Active Record's schema dumper when creating the test database.
 # This is necessary if your schema can't be completely dumped by the schema dumper,
 # like if you have constraints or database-specific column types
-# config.active_record.schema_format = :sql
\ No newline at end of file
+# config.active_record.schema_format = :sql
+
+  config.gem 'rspec',       :version => '>= 1.3.0', :lib => false unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
+  config.gem 'rspec-rails', :version => '>= 1.3.0', :lib => false unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
diff --git a/script/autospec b/script/autospec
new file mode 100755 (executable)
index 0000000..837bbd7
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
+ENV['RSPEC'] = 'true'     # allows autotest to discover rspec
+ENV['AUTOTEST'] = 'true'  # allows autotest to run w/ color on linux
+system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
+  $stderr.puts("Unable to find autotest.  Please install ZenTest or fix your PATH")
diff --git a/script/spec b/script/spec
new file mode 100755 (executable)
index 0000000..46fdbe6
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
+  require 'rubygems' unless ENV['NO_RUBYGEMS']
+else
+  gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
+  ENV["RAILS_ENV"] ||= 'test'
+  require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
+end
+require 'spec/autorun'
+exit ::Spec::Runner::CommandLine.run
diff --git a/spec/rcov.opts b/spec/rcov.opts
new file mode 100644 (file)
index 0000000..274ed51
--- /dev/null
@@ -0,0 +1,2 @@
+--exclude "spec/*,gems/*"
+--rails
\ No newline at end of file
diff --git a/spec/spec.opts b/spec/spec.opts
new file mode 100644 (file)
index 0000000..391705b
--- /dev/null
@@ -0,0 +1,4 @@
+--colour
+--format progress
+--loadby mtime
+--reverse
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644 (file)
index 0000000..1f72de0
--- /dev/null
@@ -0,0 +1,54 @@
+# This file is copied to ~/spec when you run 'ruby script/generate rspec'
+# from the project root directory.
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
+require 'spec/autorun'
+require 'spec/rails'
+
+# Uncomment the next line to use webrat's matchers
+#require 'webrat/integrations/rspec-rails'
+
+# Requires supporting files with custom matchers and macros, etc,
+# in ./support/ and its subdirectories.
+Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
+
+Spec::Runner.configure do |config|
+  # If you're not using ActiveRecord you should remove these
+  # lines, delete config/database.yml and disable :active_record
+  # in your config/boot.rb
+  config.use_transactional_fixtures = true
+  config.use_instantiated_fixtures  = false
+  config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+
+  # == Fixtures
+  #
+  # You can declare fixtures for each example_group like this:
+  #   describe "...." do
+  #     fixtures :table_a, :table_b
+  #
+  # Alternatively, if you prefer to declare them only once, you can
+  # do so right here. Just uncomment the next line and replace the fixture
+  # names with your fixtures.
+  #
+  # config.global_fixtures = :table_a, :table_b
+  #
+  # If you declare global fixtures, be aware that they will be declared
+  # for all of your examples, even those that don't use them.
+  #
+  # You can also declare which fixtures to use (for example fixtures for test/fixtures):
+  #
+  # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+  #
+  # == Mock Framework
+  #
+  # RSpec uses its own mocking framework by default. If you prefer to
+  # use mocha, flexmock or RR, uncomment the appropriate line:
+  #
+  # config.mock_with :mocha
+  # config.mock_with :flexmock
+  # config.mock_with :rr
+  #
+  # == Notes
+  #
+  # For more information take a look at Spec::Runner::Configuration and Spec::Runner
+end