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,13 @@
|
|
1
|
+
require File.expand_path('../rails', __FILE__)
|
2
|
+
require File.expand_path('../../project/rails_minitest', __FILE__)
|
3
|
+
|
4
|
+
module IntegrationTests
|
5
|
+
module RailsMinitest
|
6
|
+
include Rails
|
7
|
+
|
8
|
+
def configure_project_generator(generator)
|
9
|
+
super
|
10
|
+
generator.mixin Project::RailsMinitest
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../rails', __FILE__)
|
2
|
+
require File.expand_path('../../project/rails_rspec', __FILE__)
|
3
|
+
|
4
|
+
module IntegrationTests
|
5
|
+
module RailsRSpec
|
6
|
+
include Rails
|
7
|
+
|
8
|
+
def configure_project_generator(generator)
|
9
|
+
super
|
10
|
+
generator.mixin Project::RailsRSpec
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../rails', __FILE__)
|
2
|
+
require File.expand_path('../../project/rails_test_unit', __FILE__)
|
3
|
+
|
4
|
+
module IntegrationTests
|
5
|
+
module RailsTestUnit
|
6
|
+
include Rails
|
7
|
+
|
8
|
+
def configure_project_generator(generator)
|
9
|
+
super
|
10
|
+
generator.mixin Project::RailsTestUnit
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../rails', __FILE__)
|
2
|
+
require File.expand_path('../../project/rails_test_unit_like', __FILE__)
|
3
|
+
|
4
|
+
module IntegrationTests
|
5
|
+
module RailsTestUnitLike
|
6
|
+
include Rails
|
7
|
+
|
8
|
+
def configure_project_generator(generator)
|
9
|
+
super
|
10
|
+
generator.mixin Project::RailsTestUnitLike
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../ruby', __FILE__)
|
2
|
+
require File.expand_path('../../project/ruby_minitest', __FILE__)
|
3
|
+
|
4
|
+
module IntegrationTests
|
5
|
+
module RubyMinitest
|
6
|
+
include Ruby
|
7
|
+
|
8
|
+
def configure_project_generator(generator)
|
9
|
+
super
|
10
|
+
generator.mixin Project::RubyMinitest
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../ruby', __FILE__)
|
2
|
+
require File.expand_path('../../project/ruby_rspec', __FILE__)
|
3
|
+
|
4
|
+
module IntegrationTests
|
5
|
+
module RubyRSpec
|
6
|
+
include Ruby
|
7
|
+
|
8
|
+
def configure_project_generator(generator)
|
9
|
+
super
|
10
|
+
generator.mixin Project::RubyRSpec
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../ruby', __FILE__)
|
2
|
+
require File.expand_path('../../project/ruby_test_unit', __FILE__)
|
3
|
+
|
4
|
+
module IntegrationTests
|
5
|
+
module RubyTestUnit
|
6
|
+
include Ruby
|
7
|
+
|
8
|
+
def configure_project_generator(generator)
|
9
|
+
super
|
10
|
+
generator.mixin Project::RubyTestUnit
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class BeASubsetOfMatcher
|
2
|
+
attr_reader :subset, :set
|
3
|
+
|
4
|
+
def initialize(set)
|
5
|
+
@set = set
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(subset)
|
9
|
+
@subset = subset
|
10
|
+
(subset - set).empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
def description
|
14
|
+
"be a subset"
|
15
|
+
end
|
16
|
+
|
17
|
+
def failure_message_for_should
|
18
|
+
"Expected to be a subset.\nSubset: #{subset.inspect}\nSet: #{set.inspect}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def failure_message_for_should_not
|
22
|
+
"Expected not to be a subset.\nSubset: #{subset.inspect}\nSet: #{set.inspect}"
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Project
|
2
|
+
module Cucumber
|
3
|
+
def configure
|
4
|
+
super
|
5
|
+
gem_dependencies << gem_dependency(
|
6
|
+
:name => 'cucumber-rails',
|
7
|
+
:version => cucumber_gem_version,
|
8
|
+
:require => false
|
9
|
+
)
|
10
|
+
if rails_version == 2
|
11
|
+
gem_dependencies << gem_dependency(
|
12
|
+
:name => 'capybara',
|
13
|
+
:version => '~> 0.4.0'
|
14
|
+
)
|
15
|
+
# 1.5.0 is only compatible with >= 1.9.2
|
16
|
+
gem_dependencies << gem_dependency(
|
17
|
+
:name => 'nokogiri',
|
18
|
+
:version => '~> 1.4.0'
|
19
|
+
)
|
20
|
+
end
|
21
|
+
gem_dependencies << gem_dependency(
|
22
|
+
:name => 'database_cleaner'
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate_skeleton
|
27
|
+
super
|
28
|
+
|
29
|
+
if rails_version == 2
|
30
|
+
run_command_within! ruby_command('script/generate cucumber --capybara --backtrace')
|
31
|
+
else
|
32
|
+
run_command_within! ruby_command('rails generate cucumber:install')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_runner_command
|
37
|
+
'cucumber'
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def cucumber_gem_version
|
43
|
+
if rails_version == 2
|
44
|
+
'~> 0.3.2'
|
45
|
+
else
|
46
|
+
'~> 1.3.1'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
require File.expand_path('../../generator', __FILE__)
|
2
|
+
require File.expand_path('../../test_file/generator', __FILE__)
|
3
|
+
require File.expand_path('../../test_helper/generator', __FILE__)
|
4
|
+
require File.expand_path('../../command_runner', __FILE__)
|
5
|
+
require File.expand_path('../tests_runner', __FILE__)
|
6
|
+
|
7
|
+
require 'tempfile'
|
8
|
+
|
9
|
+
module Project
|
10
|
+
class Generator
|
11
|
+
include ::Generator
|
12
|
+
|
13
|
+
attr_accessor \
|
14
|
+
:autorequire_gems,
|
15
|
+
:include_rr_before_test_framework
|
16
|
+
|
17
|
+
attr_reader \
|
18
|
+
:gem_dependencies,
|
19
|
+
:test_requires,
|
20
|
+
:prelude
|
21
|
+
|
22
|
+
def setup
|
23
|
+
super
|
24
|
+
self.autorequire_gems = false
|
25
|
+
self.include_rr_before_test_framework = false
|
26
|
+
@gem_dependencies = []
|
27
|
+
@test_requires = []
|
28
|
+
@number_of_test_files = 0
|
29
|
+
@prelude = ""
|
30
|
+
@files_to_add = []
|
31
|
+
end
|
32
|
+
|
33
|
+
def root_dir
|
34
|
+
File.expand_path('../../../..', __FILE__)
|
35
|
+
end
|
36
|
+
|
37
|
+
def lib_dir
|
38
|
+
File.join(root_dir, 'lib')
|
39
|
+
end
|
40
|
+
|
41
|
+
def directory
|
42
|
+
File.join(root_dir, 'tmp', 'rr-integration-tests', 'test_project')
|
43
|
+
end
|
44
|
+
|
45
|
+
def bundle_dir
|
46
|
+
File.join(directory, '.bundle')
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_filename
|
50
|
+
raise NotImplementedError
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_runner_command
|
54
|
+
raise NotImplementedError
|
55
|
+
end
|
56
|
+
|
57
|
+
def call
|
58
|
+
FileUtils.rm_rf directory
|
59
|
+
FileUtils.mkdir_p File.dirname(directory)
|
60
|
+
generate_skeleton
|
61
|
+
test_helper_generator.call(self)
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_to_prelude(string)
|
65
|
+
test_helper_generator.configure do |file|
|
66
|
+
file.add_to_prelude(string)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_to_test_requires(path)
|
71
|
+
test_helper_generator.configure do |file|
|
72
|
+
file.add_to_requires(path)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_test_file(&block)
|
77
|
+
test_file_generator.call(self, @number_of_test_files, &block)
|
78
|
+
@number_of_test_files += 1
|
79
|
+
end
|
80
|
+
|
81
|
+
def run_tests
|
82
|
+
TestsRunner.call(self)
|
83
|
+
end
|
84
|
+
|
85
|
+
def declare_and_install_gems
|
86
|
+
declare_gems_within_gemfile
|
87
|
+
install_gems_via_bundler
|
88
|
+
end
|
89
|
+
|
90
|
+
def declare_gems_within_gemfile
|
91
|
+
append_to_file 'Gemfile', "\n\n#{build_gem_list}"
|
92
|
+
end
|
93
|
+
|
94
|
+
def install_gems_via_bundler
|
95
|
+
# XXX: This will fail if some gems are not available!
|
96
|
+
#if RR.debug?
|
97
|
+
# run_command! "#{bundle_executable} env"
|
98
|
+
#end
|
99
|
+
|
100
|
+
run_command! ruby_command('bundle check || bundle install')
|
101
|
+
end
|
102
|
+
|
103
|
+
def within(&block)
|
104
|
+
ret = nil
|
105
|
+
Dir.chdir(directory) { ret = block.call }
|
106
|
+
ret
|
107
|
+
end
|
108
|
+
|
109
|
+
def exec(command)
|
110
|
+
CommandRunner.call(command)
|
111
|
+
end
|
112
|
+
|
113
|
+
def exec!(command)
|
114
|
+
result = exec(command)
|
115
|
+
if not result.success?
|
116
|
+
raise "Command failed: #{command}"
|
117
|
+
end
|
118
|
+
result
|
119
|
+
end
|
120
|
+
|
121
|
+
def run_command(command, opts={})
|
122
|
+
f = Tempfile.new('rr-integration-test-file')
|
123
|
+
contents = ""
|
124
|
+
unless opts[:without_bundler_sandbox]
|
125
|
+
# Bundler will set RUBYOPT to "-I <path to bundler> -r bundler/setup".
|
126
|
+
# This is unfortunate as it causes Bundler to be loaded before we
|
127
|
+
# load Bundler in RR::Test.setup_test_suite, thereby rendering our
|
128
|
+
# second Bundler.setup a no-op.
|
129
|
+
contents << <<-EOT
|
130
|
+
export BUNDLE_BIN_PATH=""
|
131
|
+
export BUNDLE_GEMFILE=""
|
132
|
+
export RUBYOPT=""
|
133
|
+
EOT
|
134
|
+
end
|
135
|
+
if opts[:env]
|
136
|
+
opts[:env].split(' ').each do |pair|
|
137
|
+
contents << "export #{pair}\n"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
contents << <<-EOT
|
141
|
+
#{format_command(command)}
|
142
|
+
exit $?
|
143
|
+
EOT
|
144
|
+
if RR.debug?
|
145
|
+
puts "~ File to run ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
146
|
+
puts contents
|
147
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
148
|
+
end
|
149
|
+
f.write(contents)
|
150
|
+
f.close
|
151
|
+
exec("bash #{f.path}")
|
152
|
+
ensure
|
153
|
+
f.unlink if f
|
154
|
+
end
|
155
|
+
|
156
|
+
def run_command!(command, opts={})
|
157
|
+
result = run_command(command, opts)
|
158
|
+
if not result.success?
|
159
|
+
raise "Command failed: #{command}"
|
160
|
+
end
|
161
|
+
result
|
162
|
+
end
|
163
|
+
|
164
|
+
def run_command_within(command, opts={})
|
165
|
+
within { run_command(command, opts) }
|
166
|
+
end
|
167
|
+
|
168
|
+
def run_command_within!(command, opts={})
|
169
|
+
within { run_command!(command, opts) }
|
170
|
+
end
|
171
|
+
|
172
|
+
def format_command(command)
|
173
|
+
if command =~ /^bundle/
|
174
|
+
command
|
175
|
+
else
|
176
|
+
"bundle exec #{command}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def add_file(file_name, content)
|
181
|
+
@files_to_add << [file_name, content]
|
182
|
+
end
|
183
|
+
|
184
|
+
def build_gem_list
|
185
|
+
gem_dependencies_with_rr.
|
186
|
+
map { |dep| gem_dependency_line(dep) }.
|
187
|
+
join("\n")
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_file_generator
|
191
|
+
@test_file_generator ||= TestFile::Generator.factory
|
192
|
+
end
|
193
|
+
|
194
|
+
def requires_with_rr(requires)
|
195
|
+
requires = requires.dup
|
196
|
+
unless autorequire_gems
|
197
|
+
if include_rr_before_test_framework
|
198
|
+
requires.unshift 'rr'
|
199
|
+
else
|
200
|
+
requires.push 'rr'
|
201
|
+
end
|
202
|
+
end
|
203
|
+
requires
|
204
|
+
end
|
205
|
+
|
206
|
+
def require_lines(requires)
|
207
|
+
requires.map { |path| "require '#{path}'" }
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_helper_generator
|
211
|
+
@test_helper_generator ||= TestHelper::Generator.factory
|
212
|
+
end
|
213
|
+
|
214
|
+
private
|
215
|
+
|
216
|
+
def generate_skeleton
|
217
|
+
end
|
218
|
+
|
219
|
+
def create_files
|
220
|
+
@files_to_add.each do |file_name, content|
|
221
|
+
full_file_name = File.join(directory, file_name)
|
222
|
+
FileUtils.mkdir_p File.dirname(full_file_name)
|
223
|
+
create_file full_file_name, content
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def create_link(filename, dest_filename = filename)
|
228
|
+
FileUtils.ln_sf(File.join(root_dir, filename), File.join(directory, dest_filename))
|
229
|
+
end
|
230
|
+
|
231
|
+
def copy_file(filename, dest_filename = filename)
|
232
|
+
FileUtils.cp(File.join(root_dir, filename), File.join(directory, dest_filename))
|
233
|
+
end
|
234
|
+
|
235
|
+
def create_file(filename, content, opts={})
|
236
|
+
File.open(filename, 'w') do |f|
|
237
|
+
if RR.debug? && !opts[:without_debug]
|
238
|
+
puts "~ Adding file #{filename} ~~~~~~~~~~~~~~~~~~~~~~~~"
|
239
|
+
puts content
|
240
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
241
|
+
end
|
242
|
+
f.write(content)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def replace_in_file(filename, search, replace)
|
247
|
+
content = File.read(filename)
|
248
|
+
content.sub!(search, replace)
|
249
|
+
File.open(filename, 'w') { |f| f.write(content) }
|
250
|
+
|
251
|
+
if RR.debug?
|
252
|
+
puts "~ #{filename} is now: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
253
|
+
puts File.read(filename)
|
254
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def append_to_file(filename, additional_content)
|
259
|
+
content = File.read(filename)
|
260
|
+
File.open(filename, 'w') do |f|
|
261
|
+
f.write(content + additional_content)
|
262
|
+
end
|
263
|
+
|
264
|
+
if RR.debug?
|
265
|
+
puts "~ #{filename} is now: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
266
|
+
puts File.read(filename)
|
267
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def prepend_to_file(filename, additional_content)
|
272
|
+
content = File.read(filename)
|
273
|
+
File.open(filename, 'w') do |f|
|
274
|
+
f.write(additional_content + content)
|
275
|
+
end
|
276
|
+
|
277
|
+
if RR.debug?
|
278
|
+
puts "~ #{filename} is now: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
279
|
+
puts File.read(filename)
|
280
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def add_in_file_before(filename, search, additional_content)
|
285
|
+
content = File.read(filename)
|
286
|
+
content.insert(content.index(search), additional_content)
|
287
|
+
File.open(filename, 'w') { |f| f.write(content) }
|
288
|
+
|
289
|
+
if RR.debug?
|
290
|
+
puts "~ #{filename} is now: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
291
|
+
puts File.read(filename)
|
292
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def add_in_file_after(filename, search, additional_content)
|
297
|
+
content = File.read(filename)
|
298
|
+
content.insert(content.index(search) + search.length, additional_content)
|
299
|
+
File.open(filename, 'w') { |f| f.write(content) }
|
300
|
+
|
301
|
+
if RR.debug?
|
302
|
+
puts "~ #{filename} is now: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
303
|
+
puts File.read(filename)
|
304
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
def ruby_18?
|
309
|
+
RUBY_VERSION =~ /^1\.8/
|
310
|
+
end
|
311
|
+
|
312
|
+
def under_jruby?
|
313
|
+
RUBY_PLATFORM =~ /java/
|
314
|
+
end
|
315
|
+
|
316
|
+
def gem_dependency(dep)
|
317
|
+
dep
|
318
|
+
end
|
319
|
+
|
320
|
+
def gem_dependency_line(dep)
|
321
|
+
dep = dep.dup
|
322
|
+
name = dep.delete(:name)
|
323
|
+
version = dep.delete(:version)
|
324
|
+
"gem #{name.to_s.inspect}, #{version.inspect}, #{dep.inspect}"
|
325
|
+
end
|
326
|
+
|
327
|
+
def gem_dependencies_with_rr
|
328
|
+
if RR.debug?
|
329
|
+
puts "Include RR before test framework? #{include_rr_before_test_framework.inspect}"
|
330
|
+
puts "Autorequiring gems? #{autorequire_gems.inspect}"
|
331
|
+
end
|
332
|
+
|
333
|
+
dependencies = gem_dependencies.dup
|
334
|
+
|
335
|
+
rr_dep = {:name => 'rr', :path => root_dir, :version => RR.version}
|
336
|
+
rr_dep[:require] = false unless autorequire_gems
|
337
|
+
rr_dep = gem_dependency(rr_dep)
|
338
|
+
|
339
|
+
if include_rr_before_test_framework
|
340
|
+
dependencies.unshift(rr_dep)
|
341
|
+
else
|
342
|
+
dependencies.push(rr_dep)
|
343
|
+
end
|
344
|
+
|
345
|
+
dependencies
|
346
|
+
end
|
347
|
+
|
348
|
+
def ruby_command(command)
|
349
|
+
command
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|