rr 1.1.1 → 1.1.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +46 -0
- data/CHANGES.md +21 -1
- data/Gemfile +19 -0
- data/README.md +91 -106
- data/Rakefile +55 -0
- data/gemfiles/ruby_18_rspec_1.gemfile +14 -0
- data/gemfiles/ruby_18_rspec_1.gemfile.lock +38 -0
- data/gemfiles/ruby_18_rspec_1_rails_2.gemfile +18 -0
- data/gemfiles/ruby_18_rspec_1_rails_2.gemfile.lock +64 -0
- data/gemfiles/ruby_19_rspec_2.gemfile +14 -0
- data/gemfiles/ruby_19_rspec_2.gemfile.lock +49 -0
- data/gemfiles/ruby_19_rspec_2_rails_3.gemfile +15 -0
- data/gemfiles/ruby_19_rspec_2_rails_3.gemfile.lock +123 -0
- data/gemfiles/ruby_19_rspec_2_rails_4.gemfile +15 -0
- data/gemfiles/ruby_19_rspec_2_rails_4.gemfile.lock +119 -0
- data/lib/rr/adapters.rb +4 -14
- data/lib/rr/integrations.rb +13 -12
- data/lib/rr/integrations/decorator.rb +4 -1
- data/lib/rr/integrations/rspec_2.rb +6 -1
- data/lib/rr/integrations/test_unit_1.rb +2 -2
- data/lib/rr/integrations/test_unit_2.rb +3 -1
- data/lib/rr/version.rb +1 -2
- data/lib/rr/without_autohook.rb +1 -1
- data/rr.gemspec +6 -2
- data/spec/custom_formatter_for_rspec.rb +18 -0
- data/spec/custom_formatter_for_rspec_2.rb +40 -0
- data/spec/defines_spec_suite_tasks.rb +45 -0
- data/spec/fixtures/rubygems_patch_for_187.rb +598 -0
- data/spec/global_helper.rb +33 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_suite_configuration.rb +132 -0
- data/spec/spec_suite_runner.rb +47 -0
- data/spec/suites.yml +24 -0
- data/spec/suites/rspec_1/helper.rb +24 -0
- data/spec/suites/rspec_1/integration/rspec_1_spec.rb +93 -0
- data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +102 -0
- data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +109 -0
- data/spec/suites/rspec_1/spec_helper.rb +3 -0
- data/spec/suites/rspec_1_rails_2/integration/astc_rails_2_spec.rb +141 -0
- data/spec/suites/rspec_1_rails_2/integration/rspec_1_rails_2_spec.rb +132 -0
- data/spec/suites/rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb +141 -0
- data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +148 -0
- data/spec/suites/rspec_1_rails_2/spec_helper.rb +3 -0
- data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +47 -0
- data/spec/suites/rspec_2/functional/dont_allow_spec.rb +12 -0
- data/spec/suites/rspec_2/functional/dsl_spec.rb +13 -0
- data/spec/suites/rspec_2/functional/instance_of_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/mock_spec.rb +241 -0
- data/spec/suites/rspec_2/functional/proxy_spec.rb +136 -0
- data/spec/suites/rspec_2/functional/spy_spec.rb +41 -0
- data/spec/suites/rspec_2/functional/strong_spec.rb +79 -0
- data/spec/suites/rspec_2/functional/stub_spec.rb +190 -0
- data/spec/suites/rspec_2/functional/wildcard_matchers_spec.rb +128 -0
- data/spec/suites/rspec_2/helper.rb +28 -0
- data/spec/suites/rspec_2/integration/minitest_4_spec.rb +109 -0
- data/spec/suites/rspec_2/integration/minitest_spec.rb +109 -0
- data/spec/suites/rspec_2/integration/rspec_2_spec.rb +133 -0
- data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +102 -0
- data/spec/suites/rspec_2/integration/test_unit_2_spec.rb +109 -0
- data/spec/suites/rspec_2/spec_helper.rb +3 -0
- data/spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb +32 -0
- data/spec/suites/rspec_2/support/shared_examples/space.rb +13 -0
- data/spec/suites/rspec_2/support/shared_examples/times_called_expectation.rb +9 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +135 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +101 -0
- data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/core_ext/array_spec.rb +39 -0
- data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +81 -0
- data/spec/suites/rspec_2/unit/core_ext/hash_spec.rb +55 -0
- data/spec/suites/rspec_2/unit/core_ext/range_spec.rb +41 -0
- data/spec/suites/rspec_2/unit/core_ext/regexp_spec.rb +41 -0
- data/spec/suites/rspec_2/unit/double_definitions/child_double_definition_create_spec.rb +114 -0
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_blank_slate_spec.rb +93 -0
- data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +446 -0
- data/spec/suites/rspec_2/unit/errors/rr_error_spec.rb +67 -0
- data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +48 -0
- data/spec/suites/rspec_2/unit/expectations/anything_argument_equality_expectation_spec.rb +14 -0
- data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +135 -0
- data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +30 -0
- data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +82 -0
- data/spec/suites/rspec_2/unit/expectations/satisfy_argument_equality_expectation_spec.rb +61 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/any_times_matcher_spec.rb +22 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_least_matcher_spec.rb +37 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb +43 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/integer_matcher_spec.rb +58 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/proc_matcher_spec.rb +35 -0
- data/spec/suites/rspec_2/unit/expectations/times_called_expectation/range_matcher_spec.rb +39 -0
- data/spec/suites/rspec_2/unit/hash_with_object_id_key_spec.rb +88 -0
- data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb +545 -0
- data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb +32 -0
- data/spec/suites/rspec_2/unit/integrations/rspec/invocation_matcher_spec.rb +297 -0
- data/spec/suites/rspec_2/unit/integrations/rspec_spec.rb +85 -0
- data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +14 -0
- data/spec/suites/rspec_2/unit/rr_spec.rb +28 -0
- data/spec/suites/rspec_2/unit/space_spec.rb +595 -0
- data/spec/suites/rspec_2/unit/spy_verification_spec.rb +133 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/any_times_matcher_spec.rb +46 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/at_least_matcher_spec.rb +54 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/at_most_matcher_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/integer_matcher_spec.rb +69 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/proc_matcher_spec.rb +54 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/range_matcher_spec.rb +75 -0
- data/spec/suites/rspec_2/unit/times_called_matchers/times_called_matcher_spec.rb +117 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/anything_spec.rb +33 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/boolean_spec.rb +45 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/duck_type_spec.rb +64 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/hash_including_spec.rb +64 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/is_a_spec.rb +55 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/numeric_spec.rb +46 -0
- data/spec/suites/rspec_2/unit/wildcard_matchers/satisfy_spec.rb +57 -0
- data/spec/suites/rspec_2_rails_3/integration/astc_rails_3_spec.rb +141 -0
- data/spec/suites/rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb +148 -0
- data/spec/suites/rspec_2_rails_3/integration/rspec_2_rails_3_spec.rb +172 -0
- data/spec/suites/rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb +141 -0
- data/spec/suites/rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb +148 -0
- data/spec/suites/rspec_2_rails_3/spec_helper.rb +3 -0
- data/spec/suites/rspec_2_rails_4/integration/astc_rails_4_spec.rb +142 -0
- data/spec/suites/rspec_2_rails_4/integration/minitest_4_rails_4_spec.rb +149 -0
- data/spec/suites/rspec_2_rails_4/integration/rspec_2_rails_4_spec.rb +173 -0
- data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +142 -0
- data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +149 -0
- data/spec/suites/rspec_2_rails_4/spec_helper.rb +3 -0
- data/spec/support/adapter.rb +22 -0
- data/spec/support/adapter_tests/base.rb +45 -0
- data/spec/support/adapter_tests/minitest.rb +7 -0
- data/spec/support/adapter_tests/rspec.rb +66 -0
- data/spec/support/adapter_tests/test_unit.rb +47 -0
- data/spec/support/command_runner.rb +105 -0
- data/spec/support/generator.rb +56 -0
- data/spec/support/integration_tests/base.rb +64 -0
- data/spec/support/integration_tests/rails.rb +60 -0
- data/spec/support/integration_tests/rails_minitest.rb +13 -0
- data/spec/support/integration_tests/rails_rspec.rb +13 -0
- data/spec/support/integration_tests/rails_test_unit.rb +13 -0
- data/spec/support/integration_tests/rails_test_unit_like.rb +13 -0
- data/spec/support/integration_tests/ruby.rb +7 -0
- data/spec/support/integration_tests/ruby_minitest.rb +13 -0
- data/spec/support/integration_tests/ruby_rspec.rb +13 -0
- data/spec/support/integration_tests/ruby_test_unit.rb +13 -0
- data/spec/support/matchers/be_a_subset_of_matcher.rb +24 -0
- data/spec/support/project/cucumber.rb +50 -0
- data/spec/support/project/generator.rb +352 -0
- data/spec/support/project/minitest.rb +39 -0
- data/spec/support/project/rails.rb +199 -0
- data/spec/support/project/rails_minitest.rb +17 -0
- data/spec/support/project/rails_rspec.rb +50 -0
- data/spec/support/project/rails_test_unit.rb +17 -0
- data/spec/support/project/rails_test_unit_like.rb +17 -0
- data/spec/support/project/rspec.rb +69 -0
- data/spec/support/project/ruby.rb +34 -0
- data/spec/support/project/ruby_minitest.rb +11 -0
- data/spec/support/project/ruby_rspec.rb +29 -0
- data/spec/support/project/ruby_test_unit.rb +11 -0
- data/spec/support/project/ruby_test_unit_like.rb +21 -0
- data/spec/support/project/test_unit.rb +29 -0
- data/spec/support/project/test_unit_like.rb +7 -0
- data/spec/support/project/tests_runner.rb +22 -0
- data/spec/support/test.sqlite3 +0 -0
- data/spec/support/test_case/generator.rb +53 -0
- data/spec/support/test_case/minitest.rb +13 -0
- data/spec/support/test_case/rspec.rb +19 -0
- data/spec/support/test_case/test_unit.rb +21 -0
- data/spec/support/test_file/generator.rb +120 -0
- data/spec/support/test_file/minitest.rb +19 -0
- data/spec/support/test_file/rails_minitest.rb +7 -0
- data/spec/support/test_file/rails_rspec.rb +12 -0
- data/spec/support/test_file/rails_test_unit.rb +25 -0
- data/spec/support/test_file/rspec.rb +33 -0
- data/spec/support/test_file/test_unit.rb +36 -0
- data/spec/support/test_helper/generator.rb +27 -0
- data/spec/support/test_helper/minitest.rb +7 -0
- data/spec/support/test_helper/rails.rb +31 -0
- data/spec/support/test_helper/rails_minitest.rb +7 -0
- data/spec/support/test_helper/rails_rspec.rb +25 -0
- data/spec/support/test_helper/rails_test_unit.rb +23 -0
- data/spec/support/test_helper/rspec.rb +7 -0
- data/spec/support/test_helper/ruby.rb +31 -0
- data/spec/support/test_helper/test_unit.rb +7 -0
- metadata +172 -6
- data/VERSION +0 -1
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('../test_unit_like', __FILE__)
|
2
|
+
require File.expand_path('../../test_file/minitest', __FILE__)
|
3
|
+
require File.expand_path('../../test_helper/minitest', __FILE__)
|
4
|
+
|
5
|
+
module Project
|
6
|
+
module Minitest
|
7
|
+
include TestUnitLike
|
8
|
+
|
9
|
+
attr_accessor :minitest_version
|
10
|
+
|
11
|
+
def configure
|
12
|
+
super
|
13
|
+
if minitest_version
|
14
|
+
gem_dependencies << gem_dependency(
|
15
|
+
:name => 'minitest',
|
16
|
+
:version => minitest_gem_version
|
17
|
+
)
|
18
|
+
end
|
19
|
+
add_to_test_requires 'minitest/autorun'
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup
|
23
|
+
super
|
24
|
+
test_file_generator.mixin TestFile::Minitest
|
25
|
+
test_helper_generator.mixin TestHelper::Minitest
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def minitest_gem_version
|
31
|
+
case minitest_version
|
32
|
+
when 4 then '~> 4.0'
|
33
|
+
when 5 then '~> 5.0'
|
34
|
+
when nil then raise ArgumentError, "minitest_version isn't set!"
|
35
|
+
else raise ArgumentError, "Invalid Minitest version '#{minitest_version}'"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
require File.expand_path('../../test_helper/generator', __FILE__)
|
2
|
+
|
3
|
+
module Project
|
4
|
+
module Rails
|
5
|
+
attr_accessor :rails_version
|
6
|
+
|
7
|
+
def add_model_and_migration(model_name, table_name, attributes)
|
8
|
+
model_class_name = model_name.to_s.capitalize
|
9
|
+
symbolized_attribute_names = attributes.keys.map {|v| ":#{v}" }.join(', ')
|
10
|
+
migration_timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
11
|
+
camelized_table_name = table_name.to_s.capitalize
|
12
|
+
migration_column_definitions = attributes.map do |name, type|
|
13
|
+
"t.#{type} :#{name}"
|
14
|
+
end.join("\n")
|
15
|
+
|
16
|
+
model_content = "class #{model_class_name} < ActiveRecord::Base\n"
|
17
|
+
if rails_version == 3
|
18
|
+
model_content << "attr_accessible #{symbolized_attribute_names}\n"
|
19
|
+
end
|
20
|
+
model_content << "end\n"
|
21
|
+
add_file "app/models/#{model_name}.rb", model_content
|
22
|
+
|
23
|
+
add_file "db/migrate/#{migration_timestamp}_create_#{table_name}.rb", <<-EOT
|
24
|
+
class Create#{camelized_table_name} < ActiveRecord::Migration
|
25
|
+
def #{'self.' if rails_version == 2}up
|
26
|
+
create_table :#{table_name} do |t|
|
27
|
+
#{migration_column_definitions}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def #{'self.' if rails_version == 2}down
|
32
|
+
drop_table :#{table_name}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
EOT
|
36
|
+
end
|
37
|
+
|
38
|
+
def gem_dependency(dep)
|
39
|
+
dep = dep.dup
|
40
|
+
dep[:version] ||= '>= 0'
|
41
|
+
groups = Array(dep[:group] || [])
|
42
|
+
groups << :test unless groups.include?(:test)
|
43
|
+
dep[:group] = groups
|
44
|
+
dep
|
45
|
+
end
|
46
|
+
|
47
|
+
def sqlite_adapter
|
48
|
+
under_jruby? ? 'jdbcsqlite3' : 'sqlite3'
|
49
|
+
end
|
50
|
+
|
51
|
+
def database_file_path
|
52
|
+
File.join(directory, 'db/test.sqlite3')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_helper_generator
|
56
|
+
@test_helper_generator ||= TestHelper::Generator.factory
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def generate_skeleton
|
62
|
+
super
|
63
|
+
|
64
|
+
create_rails_app
|
65
|
+
|
66
|
+
within do
|
67
|
+
if rails_version == 2
|
68
|
+
add_bundler_support
|
69
|
+
fix_obsolete_reference_to_rdoctask_in_rakefile
|
70
|
+
monkeypatch_gem_source_index
|
71
|
+
end
|
72
|
+
|
73
|
+
if under_jruby? && rails_version == 4
|
74
|
+
update_activerecord_jdbc_adapter_to_beta_version
|
75
|
+
end
|
76
|
+
|
77
|
+
declare_and_install_gems
|
78
|
+
create_files
|
79
|
+
configure_database
|
80
|
+
run_migrations
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_rails_app
|
85
|
+
# remember that this has to be run with `bundle exec` to catch the correct
|
86
|
+
# 'rails' executable (rails 3 or rails 4)!
|
87
|
+
run_command! create_rails_app_command, :without_bundler_sandbox => true
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_rails_app_command
|
91
|
+
command = 'rails'
|
92
|
+
if rails_version == 2
|
93
|
+
command << " #{directory}"
|
94
|
+
else
|
95
|
+
command << " new #{directory} --skip-bundle"
|
96
|
+
end
|
97
|
+
ruby_command(command)
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_bundler_support
|
101
|
+
create_file 'config/patch_bundler_into_rails_23.rb', <<'EOT'
|
102
|
+
class Rails::Boot
|
103
|
+
def run
|
104
|
+
load_initializer
|
105
|
+
|
106
|
+
Rails::Initializer.class_eval do
|
107
|
+
def load_gems
|
108
|
+
@bundler_loaded ||= Bundler.require :default, Rails.env
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
Rails::Initializer.run(:set_load_path)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
EOT
|
116
|
+
|
117
|
+
add_in_file_before 'config/boot.rb', "Rails.boot!\n", <<-EOT
|
118
|
+
load File.expand_path('../patch_bundler_into_rails_23.rb', __FILE__)
|
119
|
+
EOT
|
120
|
+
|
121
|
+
create_file 'config/preinitializer.rb', <<'EOT'
|
122
|
+
begin
|
123
|
+
require 'rubygems'
|
124
|
+
require 'bundler'
|
125
|
+
rescue LoadError
|
126
|
+
raise "Could not load the bundler gem. Install it with `gem install bundler`."
|
127
|
+
end
|
128
|
+
|
129
|
+
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
|
130
|
+
raise RuntimeError, "Your bundler version is too old for Rails 2.3.\n" +
|
131
|
+
"Run `gem install bundler` to upgrade."
|
132
|
+
end
|
133
|
+
|
134
|
+
begin
|
135
|
+
# Set up load paths for all bundled gems
|
136
|
+
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
|
137
|
+
Bundler.setup
|
138
|
+
rescue Bundler::GemNotFound
|
139
|
+
raise RuntimeError, "Bundler couldn't find some gems.\n" +
|
140
|
+
"Did you run `bundle install`?"
|
141
|
+
end
|
142
|
+
EOT
|
143
|
+
|
144
|
+
create_file 'Gemfile', <<'EOT'
|
145
|
+
source 'https://rubygems.org'
|
146
|
+
|
147
|
+
gem 'rails', '~> 2.3.0'
|
148
|
+
gem 'sqlite3-ruby', :require => 'sqlite3'
|
149
|
+
gem 'rdoc'
|
150
|
+
EOT
|
151
|
+
end
|
152
|
+
|
153
|
+
def monkeypatch_gem_source_index
|
154
|
+
create_file 'config/rubygems_patch.rb',
|
155
|
+
File.read(File.expand_path('../../../fixtures/rubygems_patch_for_187.rb', __FILE__)),
|
156
|
+
:without_debug => true
|
157
|
+
|
158
|
+
# http://djellemah.com/blog/2013/02/27/rails-23-with-ruby-20/
|
159
|
+
add_in_file_before 'config/boot.rb', "Rails.boot!\n", <<-EOT
|
160
|
+
Rails::GemBoot.module_eval do
|
161
|
+
class << self
|
162
|
+
alias :original_load_rubygems :load_rubygems
|
163
|
+
def load_rubygems
|
164
|
+
original_load_rubygems
|
165
|
+
load File.expand_path('../rubygems_patch.rb', __FILE__)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
EOT
|
170
|
+
end
|
171
|
+
|
172
|
+
def fix_obsolete_reference_to_rdoctask_in_rakefile
|
173
|
+
replace_in_file 'Rakefile', 'rake/rdoctask', 'rdoc/task'
|
174
|
+
end
|
175
|
+
|
176
|
+
def update_activerecord_jdbc_adapter_to_beta_version
|
177
|
+
# The latest version of activerecord-jdbcsqlite3-adapter is not quite
|
178
|
+
# compatible with Rails 4 -- see:
|
179
|
+
# <https://github.com/jruby/activerecord-jdbc-adapter/issues/253>
|
180
|
+
replace_in_file 'Gemfile',
|
181
|
+
"gem 'activerecord-jdbcsqlite3-adapter'\n",
|
182
|
+
"gem 'activerecord-jdbcsqlite3-adapter', '1.3.0.beta2'\n"
|
183
|
+
end
|
184
|
+
|
185
|
+
def configure_database
|
186
|
+
create_file 'config/database.yml', <<EOT
|
187
|
+
development: &development
|
188
|
+
adapter: #{sqlite_adapter}
|
189
|
+
database: #{database_file_path}
|
190
|
+
test:
|
191
|
+
<<: *development
|
192
|
+
EOT
|
193
|
+
end
|
194
|
+
|
195
|
+
def run_migrations
|
196
|
+
run_command_within! ruby_command('rake db:migrate --trace')
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../minitest', __FILE__)
|
2
|
+
require File.expand_path('../rails', __FILE__)
|
3
|
+
require File.expand_path('../../test_file/rails_minitest', __FILE__)
|
4
|
+
require File.expand_path('../../test_helper/rails_minitest', __FILE__)
|
5
|
+
|
6
|
+
module Project
|
7
|
+
module RailsMinitest
|
8
|
+
include Minitest
|
9
|
+
include Rails
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
test_file_generator.mixin TestFile::RailsMinitest
|
14
|
+
test_helper_generator.mixin TestHelper::RailsMinitest
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path('../rspec', __FILE__)
|
2
|
+
require File.expand_path('../rails', __FILE__)
|
3
|
+
require File.expand_path('../../test_file/rails_rspec', __FILE__)
|
4
|
+
require File.expand_path('../../test_helper/rails_rspec', __FILE__)
|
5
|
+
|
6
|
+
module Project
|
7
|
+
module RailsRSpec
|
8
|
+
include RSpec
|
9
|
+
include Rails
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
test_file_generator.mixin TestFile::RailsRSpec
|
14
|
+
test_helper_generator.mixin TestHelper::RailsRSpec
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure
|
18
|
+
super
|
19
|
+
gem_dependencies << gem_dependency(
|
20
|
+
:name => 'rspec-rails',
|
21
|
+
:version => rspec_gem_version,
|
22
|
+
:group => [:development, :test]
|
23
|
+
)
|
24
|
+
add_to_test_requires(rspec_rails_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_skeleton
|
28
|
+
super
|
29
|
+
run_command_within!(generate_rspec_command)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def rspec_rails_path
|
35
|
+
if rails_version == 2
|
36
|
+
'spec/rails'
|
37
|
+
else
|
38
|
+
'rspec/rails'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def generate_rspec_command
|
43
|
+
if rails_version == 2
|
44
|
+
ruby_command('script/generate rspec --skip')
|
45
|
+
else
|
46
|
+
ruby_command('rails generate rspec:install --skip')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../test_unit', __FILE__)
|
2
|
+
require File.expand_path('../rails', __FILE__)
|
3
|
+
require File.expand_path('../../test_file/rails_test_unit', __FILE__)
|
4
|
+
require File.expand_path('../../test_helper/rails_test_unit', __FILE__)
|
5
|
+
|
6
|
+
module Project
|
7
|
+
module RailsTestUnit
|
8
|
+
include TestUnit
|
9
|
+
include Rails
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
test_file_generator.mixin TestFile::RailsTestUnit
|
14
|
+
test_helper_generator.mixin TestHelper::RailsTestUnit
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../test_unit_like', __FILE__)
|
2
|
+
require File.expand_path('../rails', __FILE__)
|
3
|
+
require File.expand_path('../../test_file/rails_test_unit', __FILE__)
|
4
|
+
require File.expand_path('../../test_helper/rails_test_unit', __FILE__)
|
5
|
+
|
6
|
+
module Project
|
7
|
+
module RailsTestUnitLike
|
8
|
+
include TestUnitLike
|
9
|
+
include Rails
|
10
|
+
|
11
|
+
def setup
|
12
|
+
super
|
13
|
+
test_file_generator.mixin TestFile::RailsTestUnit
|
14
|
+
test_helper_generator.mixin TestHelper::RailsTestUnit
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path('../../test_file/rspec', __FILE__)
|
2
|
+
require File.expand_path('../../test_helper/rspec', __FILE__)
|
3
|
+
|
4
|
+
module Project
|
5
|
+
module RSpec
|
6
|
+
attr_accessor :rspec_version
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
test_file_generator.mixin TestFile::RSpec
|
11
|
+
test_helper_generator.mixin TestHelper::RSpec
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure
|
15
|
+
super
|
16
|
+
gem_dependencies << gem_dependency(
|
17
|
+
:name => 'rspec',
|
18
|
+
:version => rspec_gem_version
|
19
|
+
)
|
20
|
+
add_to_test_requires(rspec_autorun_path)
|
21
|
+
add_file(rspec_options_filename, dot_rspec_content)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_runner_command
|
25
|
+
ruby_command('rake spec')
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def rspec_gem_version
|
31
|
+
case rspec_version
|
32
|
+
when 2 then '~> 2.13'
|
33
|
+
when 1 then '~> 1.3'
|
34
|
+
when nil then raise ArgumentError, "rspec_version isn't set!"
|
35
|
+
else raise ArgumentError, "Invalid RSpec version '#{rspec_version}'"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def rspec_autorun_path
|
40
|
+
if rspec_version == 1
|
41
|
+
'spec/autorun'
|
42
|
+
else
|
43
|
+
'rspec/autorun'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def rspec_options_filename
|
48
|
+
if rspec_version == 1
|
49
|
+
'spec/spec.opts'
|
50
|
+
else
|
51
|
+
'.rspec'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def dot_rspec_content
|
56
|
+
lines = []
|
57
|
+
lines << '--color'
|
58
|
+
if rspec_version == 1
|
59
|
+
lines << '--format nested'
|
60
|
+
else
|
61
|
+
lines << '--format documentation'
|
62
|
+
end
|
63
|
+
if RR.debug?
|
64
|
+
lines << '--backtrace'
|
65
|
+
end
|
66
|
+
lines.join("\n")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path('../../test_helper/ruby', __FILE__)
|
2
|
+
|
3
|
+
module Project
|
4
|
+
module Ruby
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
test_helper_generator.mixin TestHelper::Ruby
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def generate_skeleton
|
13
|
+
super
|
14
|
+
|
15
|
+
FileUtils.mkdir_p(directory)
|
16
|
+
|
17
|
+
within do
|
18
|
+
create_gemfile
|
19
|
+
declare_and_install_gems
|
20
|
+
create_files
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_gemfile
|
25
|
+
File.open('Gemfile', 'w') do |f|
|
26
|
+
contents = <<-EOT
|
27
|
+
source 'https://rubygems.org'
|
28
|
+
gem 'rake'
|
29
|
+
EOT
|
30
|
+
f.write(contents)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|