rr 1.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Appraisals +6 -0
- data/CHANGES.md +102 -1
- data/CREDITS.md +5 -0
- data/Gemfile +3 -0
- data/README.md +91 -110
- data/Rakefile +43 -0
- data/doc/02_syntax_comparison.md +1 -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_4.gemfile +15 -0
- data/gemfiles/ruby_19_rspec_2_rails_4.gemfile.lock +119 -0
- data/lib/rr/class_instance_method_defined.rb +1 -1
- data/lib/rr/core_ext/array.rb +2 -0
- data/lib/rr/core_ext/hash.rb +2 -0
- data/lib/rr/deprecations.rb +97 -0
- data/lib/rr/double.rb +28 -10
- data/lib/rr/double_definitions/double_definition.rb +39 -16
- data/lib/rr/double_definitions/double_definition_create.rb +5 -5
- data/lib/rr/double_definitions/double_definition_create_blank_slate.rb +10 -4
- data/lib/rr/double_definitions/double_injections/any_instance_of.rb +1 -1
- data/lib/rr/double_definitions/double_injections/instance.rb +2 -2
- data/lib/rr/double_definitions/strategies/strategy.rb +27 -8
- data/lib/rr/double_definitions/strategies/verification/mock.rb +8 -2
- data/lib/rr/double_matches.rb +4 -3
- data/lib/rr/dsl.rb +152 -0
- data/lib/rr/expectations/any_argument_expectation.rb +4 -4
- data/lib/rr/expectations/argument_equality_expectation.rb +43 -5
- data/lib/rr/injections/double_injection.rb +67 -19
- data/lib/rr/injections/method_missing_injection.rb +37 -6
- data/lib/rr/integrations.rb +13 -12
- data/lib/rr/integrations/decorator.rb +4 -1
- data/lib/rr/integrations/minitest_4.rb +1 -1
- data/lib/rr/integrations/minitest_4_active_support.rb +1 -1
- data/lib/rr/integrations/rspec/invocation_matcher.rb +0 -8
- data/lib/rr/integrations/rspec_2.rb +28 -3
- data/lib/rr/keyword_arguments.rb +15 -0
- data/lib/rr/method_dispatches/base_method_dispatch.rb +22 -5
- data/lib/rr/method_dispatches/method_dispatch.rb +21 -10
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +14 -5
- data/lib/rr/recorded_call.rb +35 -0
- data/lib/rr/recorded_calls.rb +23 -9
- data/lib/rr/space.rb +15 -5
- data/lib/rr/spy_verification.rb +13 -5
- data/lib/rr/version.rb +1 -2
- data/lib/rr/wildcard_matchers.rb +10 -10
- data/lib/rr/without_autohook.rb +7 -14
- data/rr.gemspec +14 -5
- 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 +57 -0
- data/spec/fixtures/rubygems_patch_for_187.rb +598 -0
- data/spec/global_helper.rb +38 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_suite_configuration.rb +126 -0
- data/spec/spec_suite_runner.rb +47 -0
- data/spec/suites.yml +10 -0
- data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +147 -0
- data/spec/suites/rspec_2/functional/dont_allow_spec.rb +17 -0
- data/spec/suites/rspec_2/functional/mock_bang_spec.rb +20 -0
- data/spec/suites/rspec_2/functional/mock_instance_of_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/mock_instance_of_strong_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/mock_proxy_instance_of_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/mock_proxy_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/mock_spec.rb +17 -0
- data/spec/suites/rspec_2/functional/mock_strong_spec.rb +14 -0
- data/spec/suites/rspec_2/functional/received_spec.rb +16 -0
- data/spec/suites/rspec_2/functional/spy_spec.rb +102 -0
- data/spec/suites/rspec_2/functional/stub_bang_spec.rb +20 -0
- data/spec/suites/rspec_2/functional/stub_instance_of_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/stub_instance_of_strong_spec.rb +15 -0
- data/spec/suites/rspec_2/functional/stub_proxy_instance_of_spec.rb +16 -0
- data/spec/suites/rspec_2/functional/stub_proxy_spec.rb +45 -0
- data/spec/suites/rspec_2/functional/stub_spec.rb +71 -0
- data/spec/suites/rspec_2/functional/stub_strong_spec.rb +15 -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/spec_helper.rb +3 -0
- data/spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb +32 -0
- data/spec/suites/rspec_2/support/mixins/double_definition_creator_helpers.rb +173 -0
- data/spec/suites/rspec_2/support/mixins/mock_definition_creator_helpers.rb +45 -0
- data/spec/suites/rspec_2/support/mixins/proxy_definition_creator_helpers.rb +33 -0
- data/spec/suites/rspec_2/support/mixins/stub_creator_helpers.rb +43 -0
- data/spec/suites/rspec_2/support/mixins/stub_definition_creator_helpers.rb +45 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_never_called_qualifier.rb +39 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_times_called_qualifier.rb +50 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_without_qualifiers.rb +131 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/dont_allow.rb +148 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of.rb +26 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of_strong.rb +28 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_proxy.rb +11 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_strong.rb +37 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mocking.rb +107 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of.rb +32 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of_strong.rb +39 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_proxy.rb +11 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_strong.rb +37 -0
- data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stubbing.rb +57 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/array_flatten_bug.rb +35 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/block_form.rb +31 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/comparing_arity.rb +63 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/object_is_proxy.rb +43 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/sequential_invocations.rb +26 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/setting_implementation.rb +51 -0
- data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/yields.rb +81 -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/core_ext/array_spec.rb +39 -0
- data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +53 -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/deprecations_spec.rb +27 -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/dsl/double_creators_spec.rb +133 -0
- data/spec/suites/rspec_2/unit/dsl/space_spec.rb +99 -0
- data/spec/suites/rspec_2/unit/dsl/wildcard_matchers_spec.rb +67 -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 +92 -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 +533 -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 +70 -0
- data/spec/suites/rspec_2/unit/rr_spec.rb +28 -0
- data/spec/suites/rspec_2/unit/space_spec.rb +598 -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/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 +70 -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 +348 -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 +240 -19
- data/VERSION +0 -1
- data/lib/rr/adapters.rb +0 -44
- data/lib/rr/adapters/rr_methods.rb +0 -142
- data/lib/rr/integrations/rspec_1.rb +0 -46
- data/lib/rr/integrations/test_unit_1.rb +0 -63
- data/lib/rr/integrations/test_unit_2.rb +0 -15
- data/lib/rr/integrations/test_unit_200.rb +0 -27
- data/lib/rr/integrations/test_unit_200_active_support.rb +0 -25
- data/lib/rr/integrations/test_unit_2_active_support.rb +0 -38
- data/lib/rr/proc_from_block.rb +0 -11
@@ -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
|