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,38 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
|
5
|
+
if ENV['COVERAGE']
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.start
|
8
|
+
end
|
9
|
+
|
10
|
+
module RR
|
11
|
+
module Test
|
12
|
+
def self.setup_test_suite(adapter_name)
|
13
|
+
puts "Setting up test suite for #{adapter_name}" if ENV['RR_DEBUG']
|
14
|
+
unset_bundler_vars
|
15
|
+
adapter = Adapter.new(adapter_name)
|
16
|
+
ENV['ADAPTER'] = adapter.name.to_s
|
17
|
+
puts "Using appraisal: #{adapter.appraisal.name}" if ENV['RR_DEBUG']
|
18
|
+
ENV['BUNDLE_GEMFILE'] = adapter.appraisal.gemfile_path
|
19
|
+
puts "Using gemfile: #{adapter.appraisal.gemfile_path}" if ENV['RR_DEBUG']
|
20
|
+
Bundler.setup(:default)
|
21
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.unset_bundler_vars
|
25
|
+
# Copied from appraisal
|
26
|
+
%w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).each do |name|
|
27
|
+
ENV[name] = nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
lib_path = File.expand_path("../../lib", __FILE__)
|
34
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
35
|
+
|
36
|
+
Dir[ File.expand_path('../support/**/*.rb', __FILE__) ].each { |fn| require fn }
|
37
|
+
|
38
|
+
$stdout.sync = true
|
data/spec/spec.opts
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.expand_path('../spec_suite_runner', __FILE__)
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'erb'
|
5
|
+
require 'forwardable'
|
6
|
+
require 'ostruct'
|
7
|
+
|
8
|
+
class SpecSuiteConfiguration
|
9
|
+
SUITES_CONFIG_FILE = File.expand_path('../suites.yml', __FILE__)
|
10
|
+
TRAVIS_CONFIG_FILE = File.expand_path('../../.travis.yml', __FILE__)
|
11
|
+
|
12
|
+
class Suite < Struct.new(:name, :desc, :rvm_version, :ruby_id, :env, :travis)
|
13
|
+
attr_reader :runner
|
14
|
+
|
15
|
+
def initialize(name, desc, rvm_version, ruby_id, env, travis)
|
16
|
+
super
|
17
|
+
@runner = SpecSuiteRunner.new(self)
|
18
|
+
end
|
19
|
+
|
20
|
+
def appraisal_name
|
21
|
+
"ruby_#{ruby_id}_#{name}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
runner.call
|
26
|
+
end
|
27
|
+
|
28
|
+
def current_ruby_id
|
29
|
+
'19'
|
30
|
+
end
|
31
|
+
|
32
|
+
def matching_current_ruby_version?
|
33
|
+
ruby_id == current_ruby_id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_reader :ruby_groups, :runners
|
38
|
+
|
39
|
+
def self.build
|
40
|
+
new(parse)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.parse
|
44
|
+
suites = []
|
45
|
+
yaml = ERB.new(File.read(SUITES_CONFIG_FILE)).result(binding)
|
46
|
+
ruby_groups = YAML.load(yaml)
|
47
|
+
ruby_groups.each do |ruby_id, ruby_group|
|
48
|
+
base_env = ruby_group.fetch('env', {})
|
49
|
+
ruby_group['suites'].each do |suite|
|
50
|
+
ruby_group['rvm_versions'].each do |rvm_version|
|
51
|
+
suite = suite.dup
|
52
|
+
suite['ruby_id'] = ruby_id.to_s
|
53
|
+
suite['rvm_version'] = rvm_version['name']
|
54
|
+
suite['env'] = base_env.merge(rvm_version.fetch('env', {}))
|
55
|
+
suite['travis'] = ruby_group.fetch('travis', {})
|
56
|
+
suite['travis']['env'] = base_env.merge(suite['travis'].fetch('env', {}))
|
57
|
+
suites << suite
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
suites
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.root_dir
|
65
|
+
File.expand_path('../..', __FILE__)
|
66
|
+
end
|
67
|
+
|
68
|
+
attr_reader :suites
|
69
|
+
|
70
|
+
def initialize(suites)
|
71
|
+
@suites = suites.map do |suite|
|
72
|
+
Suite.new(
|
73
|
+
suite['name'],
|
74
|
+
suite['desc'],
|
75
|
+
suite['rvm_version'],
|
76
|
+
suite['ruby_id'],
|
77
|
+
suite['env'],
|
78
|
+
suite['travis']
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def each_matching_suite(&block)
|
84
|
+
suites.
|
85
|
+
select { |suite| suite.matching_current_ruby_version? }.
|
86
|
+
each(&block)
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_travis_config
|
90
|
+
inclusions = []
|
91
|
+
allowed_failures = []
|
92
|
+
|
93
|
+
sorted_suites = suites.sort_by { |suite| [suite.rvm_version, suite.name] }
|
94
|
+
|
95
|
+
sorted_suites.each do |suite|
|
96
|
+
env = suite.travis['env'].merge('SUITE' => suite.name)
|
97
|
+
row = {
|
98
|
+
'rvm' => suite.rvm_version,
|
99
|
+
'env' => env.map { |key, val| "#{key}=#{val.inspect}" }
|
100
|
+
}
|
101
|
+
inclusions << row
|
102
|
+
if suite.rvm_version == 'jruby-19mode'
|
103
|
+
allowed_failures << row
|
104
|
+
end
|
105
|
+
end
|
106
|
+
{
|
107
|
+
'language' => 'ruby',
|
108
|
+
'script' => 'rake spec:${SUITE}',
|
109
|
+
'rvm' => '1.9.3',
|
110
|
+
'matrix' => {
|
111
|
+
# exclude default row
|
112
|
+
'exclude' => [
|
113
|
+
{'rvm' => '1.9.3'},
|
114
|
+
],
|
115
|
+
'include' => inclusions,
|
116
|
+
'allow_failures' => allowed_failures
|
117
|
+
}
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def generate_travis_config
|
122
|
+
config = to_travis_config
|
123
|
+
File.open(TRAVIS_CONFIG_FILE, 'w') {|f| YAML.dump(config, f) }
|
124
|
+
puts "Updated .travis.yml."
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class SpecSuiteRunner
|
2
|
+
attr_reader :suite
|
3
|
+
|
4
|
+
def initialize(suite)
|
5
|
+
@suite = suite
|
6
|
+
end
|
7
|
+
|
8
|
+
def call
|
9
|
+
command = build_command
|
10
|
+
if ENV['RR_DEBUG']
|
11
|
+
puts "Running: #{command}"
|
12
|
+
end
|
13
|
+
execute_command(command)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def execute_command(command)
|
19
|
+
system(command)
|
20
|
+
status = $?.exitstatus
|
21
|
+
OpenStruct.new(:success? => (status == 0))
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_command
|
25
|
+
parts = ['env'] + build_env_pairs + ['ruby'] + build_file_list
|
26
|
+
parts.join(" ")
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_env_pairs
|
30
|
+
# If `bundle exec rake` is run instead of just `rake`, Bundler will set
|
31
|
+
# RUBYOPT to "-I <path to bundler> -r bundler/setup". This is unfortunate as
|
32
|
+
# it causes Bundler to be loaded before we load Bundler in
|
33
|
+
# RR::Test.setup_test_suite, thereby rendering our second Bundler.setup a
|
34
|
+
# no-op.
|
35
|
+
env = suite.env.merge(
|
36
|
+
'BUNDLE_BIN_PATH' => '',
|
37
|
+
'BUNDLE_GEMFILE' => '',
|
38
|
+
'RUBYOPT' => '',
|
39
|
+
'ADAPTER' => suite.name
|
40
|
+
)
|
41
|
+
env.map { |key, val| "#{key}=\"#{val}\"" }
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_file_list
|
45
|
+
Dir[ File.expand_path("../suites/#{suite.name}/{.,*,**}/*_spec.rb", __FILE__) ]
|
46
|
+
end
|
47
|
+
end
|
data/spec/suites.yml
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe 'any_instance_of' do
|
4
|
+
context 'stubs for instance methods of a class' do
|
5
|
+
context 'via block form' do
|
6
|
+
context 'for existing methods' do
|
7
|
+
it "can be defined" do
|
8
|
+
a_class = Class.new { def some_method; 'value'; end }
|
9
|
+
any_instance_of(a_class) { |c| stub(c).some_method { 'value' } }
|
10
|
+
instance = a_class.new
|
11
|
+
expect(instance.some_method).to eq 'value'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can be reset" do
|
15
|
+
a_class = Class.new { def some_method; 'original value'; end }
|
16
|
+
any_instance_of(a_class) { |c| stub(c).some_method { 'value' } }
|
17
|
+
RR.reset
|
18
|
+
instance = a_class.new
|
19
|
+
expect(instance.some_method).to eq 'original value'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'for non-existing methods' do
|
24
|
+
it "can be defined" do
|
25
|
+
a_class = Class.new
|
26
|
+
any_instance_of(a_class) { |c| stub(c).some_method { 'value' } }
|
27
|
+
instance = a_class.new
|
28
|
+
expect(instance.some_method).to eq 'value'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "can be reset" do
|
32
|
+
a_class = Class.new
|
33
|
+
any_instance_of(a_class) { |c| stub(c).some_method { 'value' } }
|
34
|
+
RR.reset
|
35
|
+
instance = a_class.new
|
36
|
+
expect(instance).not_to respond_to(:some_method)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'via hash form' do
|
42
|
+
context 'for existing methods' do
|
43
|
+
it "can be defined" do
|
44
|
+
a_class = Class.new { def some_method; 'value'; end }
|
45
|
+
any_instance_of(a_class, :some_method => lambda { 'value' })
|
46
|
+
instance = a_class.new
|
47
|
+
expect(instance.some_method).to eq 'value'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "can be reset" do
|
51
|
+
a_class = Class.new { def some_method; 'original value'; end }
|
52
|
+
any_instance_of(a_class, :some_method => lambda { 'value' })
|
53
|
+
RR.reset
|
54
|
+
instance = a_class.new
|
55
|
+
expect(instance.some_method).to eq 'original value'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'for non-existing methods' do
|
60
|
+
it "can be defined" do
|
61
|
+
a_class = Class.new
|
62
|
+
any_instance_of(a_class, :some_method => lambda { 'value' })
|
63
|
+
instance = a_class.new
|
64
|
+
expect(instance.some_method).to eq 'value'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "can be reset" do
|
68
|
+
a_class = Class.new
|
69
|
+
any_instance_of(a_class, :some_method => lambda { 'value' })
|
70
|
+
RR.reset
|
71
|
+
instance = a_class.new
|
72
|
+
expect(instance).not_to respond_to(:some_method)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'stub-proxies for instance methods of a class' do
|
79
|
+
it "can be defined" do
|
80
|
+
a_class = Class.new { def some_method; 'value'; end }
|
81
|
+
any_instance_of(a_class) { |c| stub.proxy(c).some_method { 'value' } }
|
82
|
+
instance = a_class.new
|
83
|
+
expect(instance.some_method).to eq 'value'
|
84
|
+
end
|
85
|
+
|
86
|
+
it "can be reset" do
|
87
|
+
a_class = Class.new { def some_method; 'original value'; end }
|
88
|
+
any_instance_of(a_class) { |c| stub.proxy(c).some_method { 'value' } }
|
89
|
+
RR.reset
|
90
|
+
instance = a_class.new
|
91
|
+
expect(instance.some_method).to eq 'original value'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'mocks for instance methods of a class' do
|
96
|
+
context 'for existing methods' do
|
97
|
+
it "can be defined" do
|
98
|
+
a_class = Class.new { def some_method; 'value'; end }
|
99
|
+
any_instance_of(a_class) { |c| mock(c).some_method { 'value' } }
|
100
|
+
instance = a_class.new
|
101
|
+
expect(instance.some_method).to eq 'value'
|
102
|
+
end
|
103
|
+
|
104
|
+
it "can be reset" do
|
105
|
+
a_class = Class.new { def some_method; 'original value'; end }
|
106
|
+
any_instance_of(a_class) { |c| mock(c).some_method { 'value' } }
|
107
|
+
RR.reset
|
108
|
+
instance = a_class.new
|
109
|
+
expect(instance.some_method).to eq 'original value'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'for non-existing methods' do
|
114
|
+
it "can be defined" do
|
115
|
+
a_class = Class.new
|
116
|
+
any_instance_of(a_class) { |c| mock(c).some_method { 'value' } }
|
117
|
+
instance = a_class.new
|
118
|
+
expect(instance.some_method).to eq 'value'
|
119
|
+
end
|
120
|
+
|
121
|
+
it "can be reset" do
|
122
|
+
a_class = Class.new
|
123
|
+
any_instance_of(a_class) { |c| mock(c).some_method { 'value' } }
|
124
|
+
RR.reset
|
125
|
+
instance = a_class.new
|
126
|
+
expect(instance).not_to respond_to(:some_method)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'mock-proxies for instance methods of a class' do
|
132
|
+
it "can be defined" do
|
133
|
+
a_class = Class.new { def some_method; 'value'; end }
|
134
|
+
any_instance_of(a_class) { |c| mock.proxy(c).some_method { 'value' } }
|
135
|
+
instance = a_class.new
|
136
|
+
expect(instance.some_method).to eq 'value'
|
137
|
+
end
|
138
|
+
|
139
|
+
it "can be reset" do
|
140
|
+
a_class = Class.new { def some_method; 'original value'; end }
|
141
|
+
any_instance_of(a_class) { |c| mock.proxy(c).some_method { 'value' } }
|
142
|
+
RR.reset
|
143
|
+
instance = a_class.new
|
144
|
+
expect(instance.some_method).to eq 'original value'
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe 'dont_allow', is_mock: true, is_dont_allow: true do
|
4
|
+
include MockDefinitionCreatorHelpers
|
5
|
+
|
6
|
+
context 'against instance methods', method_type: :instance do
|
7
|
+
include_context 'tests for a double definition creator method that supports dont_allow'
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'against class methods', method_type: :class do
|
11
|
+
include_context 'tests for a double definition creator method that supports dont_allow'
|
12
|
+
end
|
13
|
+
|
14
|
+
def double_definition_creator_for(object, &block)
|
15
|
+
dont_allow(object, &block)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe 'mock!' do
|
4
|
+
it "is a terser way of creating an object and mocking it" do
|
5
|
+
object = mock!.some_method { 'value' }.subject
|
6
|
+
expect(object.some_method).to eq 'value'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can be used inside the implementation block of a double" do
|
10
|
+
object = Object.new
|
11
|
+
stub(object).some_method { mock!.another_method { 'value' } }
|
12
|
+
expect(object.some_method.another_method).to eq 'value'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can be called on a double" do
|
16
|
+
object = Object.new
|
17
|
+
stub(object).some_method.mock!.another_method { 'value' }
|
18
|
+
expect(object.some_method.another_method).to eq 'value'
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
permutations =
|
4
|
+
%w(mock instance_of).permutation.map { |parts| parts.join('.') }
|
5
|
+
|
6
|
+
permutations.each do |permutation|
|
7
|
+
describe permutation, is_mock: true, is_instance_of: true do
|
8
|
+
include_context 'mock + instance_of'
|
9
|
+
|
10
|
+
define_method(:double_definition_creator_for) do |object, &block|
|
11
|
+
eval(permutation + '(object, &block)')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
permutations =
|
4
|
+
%w(mock instance_of strong).permutation.to_a.
|
5
|
+
map { |parts| parts.join('.') }
|
6
|
+
|
7
|
+
permutations.each do |permutation|
|
8
|
+
describe permutation, is_mock: true, is_instance_of: true, is_strong: true do
|
9
|
+
include_context 'mock + instance_of + strong'
|
10
|
+
|
11
|
+
define_method(:double_definition_creator_for) do |object, &block|
|
12
|
+
eval(permutation + '(object, &block)')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|