rr 1.1.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,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,348 @@
|
|
|
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 under_jruby?
|
|
309
|
+
RUBY_PLATFORM =~ /java/
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def gem_dependency(dep)
|
|
313
|
+
dep
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def gem_dependency_line(dep)
|
|
317
|
+
dep = dep.dup
|
|
318
|
+
name = dep.delete(:name)
|
|
319
|
+
version = dep.delete(:version)
|
|
320
|
+
"gem #{name.to_s.inspect}, #{version.inspect}, #{dep.inspect}"
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def gem_dependencies_with_rr
|
|
324
|
+
if RR.debug?
|
|
325
|
+
puts "Include RR before test framework? #{include_rr_before_test_framework.inspect}"
|
|
326
|
+
puts "Autorequiring gems? #{autorequire_gems.inspect}"
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
dependencies = gem_dependencies.dup
|
|
330
|
+
|
|
331
|
+
rr_dep = {:name => 'rr', :path => root_dir, :version => RR.version}
|
|
332
|
+
rr_dep[:require] = false unless autorequire_gems
|
|
333
|
+
rr_dep = gem_dependency(rr_dep)
|
|
334
|
+
|
|
335
|
+
if include_rr_before_test_framework
|
|
336
|
+
dependencies.unshift(rr_dep)
|
|
337
|
+
else
|
|
338
|
+
dependencies.push(rr_dep)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
dependencies
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def ruby_command(command)
|
|
345
|
+
command
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
end
|