Skip to content
This repository
Browse code

Separate test environment setup and misc setup blocks into spec/suppo…

…rt dir.

Move custom_macros into spec/support directory where rspec automatically loads it.
Add log/ directory and files to the .gitignore file. RSpec 2.0 is writing some
logs there.
  • Loading branch information...
commit b86266edbc170f32c9fdfb0764aed85c8b29d7eb 1 parent 431333f
Morton Jonuschat yabawock authored
1  .gitignore
@@ -3,3 +3,4 @@ coverage
3 3 pkg
4 4 *~
5 5 *watchr.rb
  6 +log/*
40 spec/spec_helper.rb
... ... @@ -1,49 +1,17 @@
1 1 # coding: utf-8
2 2 require 'rubygems'
3   -
4   -gem 'activesupport', '>=2.3.8'
5   -gem 'actionpack', '>=2.3.8'
6 3 require 'active_support'
7 4 require 'action_pack'
8 5 require 'action_view'
9 6 require 'action_controller'
10 7
11   -begin
12   - gem 'activemodel', '>= 3.0.0.beta'
13   - require 'active_model'
14   -rescue Exception
15   -end
16   -
17   -gem 'rspec', '>= 1.2.6'
18   -gem 'rspec-rails', '>= 1.2.6'
19   -gem 'hpricot', '>= 0.6.1'
20   -gem 'rspec_tag_matchers', '>= 1.0.0'
21   -require 'rspec_tag_matchers'
22   -
23   -require 'custom_macros'
24   -
25   -begin
26   - Spec::Runner.configure do |config|
27   - config.include(RspecTagMatchers)
28   - config.include(CustomMacros)
29   - end
30   -rescue
31   - require 'rspec/core'
32   - Rspec.configure do |config|
33   - config.include RspecTagMatchers
34   - config.include CustomMacros
35   - config.mock_with :rspec
36   - end
37   -end
38   -
39   -require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
40 8 require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/util'))
  9 +require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
41 10 require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/layout_helper'))
42 11
43   -module ActionView
44   - class OutputBuffer < Formtastic::Util.rails_safe_buffer_class
45   - end
46   -end
  12 +# Requires supporting files with custom matchers and macros, etc,
  13 +# in ./support/ and its subdirectories.
  14 +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
47 15
48 16 module FormtasticSpecHelper
49 17 include ActionPack
0  spec/custom_macros.rb → spec/support/custom_macros.rb
File renamed without changes
4 spec/support/output_buffer.rb
... ... @@ -0,0 +1,4 @@
  1 +module ActionView
  2 + class OutputBuffer < Formtastic::Util.rails_safe_buffer_class
  3 + end
  4 +end
39 spec/support/test_environment.rb
... ... @@ -0,0 +1,39 @@
  1 +if Formtastic::Util.rails3?
  2 + gem 'rspec', '~> 2.0.0.beta12'
  3 + gem 'rspec-rails', '~> 2.0.0.beta12'
  4 +
  5 + require "rubygems"
  6 + require "action_controller/railtie"
  7 + require "active_resource/railtie"
  8 + require 'active_model'
  9 + require 'rspec/core'
  10 + require 'rspec/rails'
  11 + require 'rspec_tag_matchers'
  12 +
  13 + # Create a simple rails application for use in testing the viewhelper
  14 + module FormtasticTest
  15 + class Application < Rails::Application
  16 + # Configure the default encoding used in templates for Ruby 1.9.
  17 + config.encoding = "utf-8"
  18 + end
  19 + end
  20 + FormtasticTest::Application.initialize!
  21 +
  22 + # Configure RSpec 2.0
  23 + RSpec.configure do |config|
  24 + config.include RspecTagMatchers
  25 + config.include CustomMacros
  26 + config.mock_with :rspec
  27 + end
  28 +
  29 +else
  30 + gem 'rspec', '>= 1.2.6'
  31 + gem 'rspec-rails', '>= 1.2.6'
  32 + gem 'hpricot', '>= 0.6.1'
  33 + require 'rspec_tag_matchers'
  34 +
  35 + Spec::Runner.configure do |config|
  36 + config.include(RspecTagMatchers)
  37 + config.include(CustomMacros)
  38 + end
  39 +end

0 comments on commit b86266e

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