rspec-core 2.0.0.a1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +7 -0
- data/.treasure_map.rb +23 -0
- data/License.txt +22 -0
- data/README.markdown +9 -0
- data/Rakefile +76 -0
- data/TODO.markdown +16 -0
- data/VERSION +1 -0
- data/VERSION.yml +5 -0
- data/bin/rspec +12 -0
- data/cucumber.yml +2 -0
- data/example_specs/failing/README.txt +7 -0
- data/example_specs/failing/diffing_spec.rb +36 -0
- data/example_specs/failing/failing_implicit_docstrings_example.rb +19 -0
- data/example_specs/failing/failure_in_after.rb +10 -0
- data/example_specs/failing/failure_in_before.rb +10 -0
- data/example_specs/failing/mocking_example.rb +40 -0
- data/example_specs/failing/mocking_with_flexmock.rb +26 -0
- data/example_specs/failing/mocking_with_mocha.rb +25 -0
- data/example_specs/failing/mocking_with_rr.rb +27 -0
- data/example_specs/failing/partial_mock_example.rb +20 -0
- data/example_specs/failing/pending_example.rb +9 -0
- data/example_specs/failing/predicate_example.rb +34 -0
- data/example_specs/failing/raising_example.rb +47 -0
- data/example_specs/failing/spec_helper.rb +3 -0
- data/example_specs/failing/syntax_error_example.rb +7 -0
- data/example_specs/failing/team_spec.rb +44 -0
- data/example_specs/failing/timeout_behaviour.rb +7 -0
- data/example_specs/passing/custom_formatter.rb +12 -0
- data/example_specs/passing/custom_matchers.rb +54 -0
- data/example_specs/passing/dynamic_spec.rb +9 -0
- data/example_specs/passing/file_accessor.rb +19 -0
- data/example_specs/passing/file_accessor_spec.rb +38 -0
- data/example_specs/passing/filtered_formatter.rb +18 -0
- data/example_specs/passing/filtered_formatter_example.rb +31 -0
- data/example_specs/passing/greeter_spec.rb +31 -0
- data/example_specs/passing/helper_method_example.rb +14 -0
- data/example_specs/passing/implicit_docstrings_example.rb +18 -0
- data/example_specs/passing/io_processor.rb +8 -0
- data/example_specs/passing/io_processor_spec.rb +21 -0
- data/example_specs/passing/mocking_example.rb +27 -0
- data/example_specs/passing/multi_threaded_example_group_runner.rb +26 -0
- data/example_specs/passing/nested_classes_example.rb +36 -0
- data/example_specs/passing/options_example.rb +31 -0
- data/example_specs/passing/options_formatter.rb +20 -0
- data/example_specs/passing/partial_mock_example.rb +29 -0
- data/example_specs/passing/pending_example.rb +20 -0
- data/example_specs/passing/predicate_example.rb +27 -0
- data/example_specs/passing/shared_example_group_example.rb +81 -0
- data/example_specs/passing/shared_stack_examples.rb +36 -0
- data/example_specs/passing/simple_matcher_example.rb +31 -0
- data/example_specs/passing/spec_helper.rb +14 -0
- data/example_specs/passing/stack.rb +36 -0
- data/example_specs/passing/stack_spec.rb +64 -0
- data/example_specs/passing/stack_spec_with_nested_example_groups.rb +67 -0
- data/example_specs/passing/stubbing_example.rb +69 -0
- data/example_specs/passing/yielding_example.rb +33 -0
- data/example_specs/ruby1.9.compatibility/access_to_constants_spec.rb +85 -0
- data/features-pending/command_line/line_number_option.feature +56 -0
- data/features-pending/command_line/line_number_option_with_example_with_no_name.feature +22 -0
- data/features-pending/example_groups/example_group_with_should_methods.feature +29 -0
- data/features-pending/example_groups/implicit_docstrings.feature +59 -0
- data/features-pending/example_groups/nested_groups.feature +32 -0
- data/features-pending/expectations/expect_change.feature +65 -0
- data/features-pending/expectations/expect_error.feature +44 -0
- data/features-pending/extensions/custom_example_group.feature +19 -0
- data/features-pending/formatters/custom_formatter.feature +30 -0
- data/features-pending/heckle/heckle.feature +56 -0
- data/features-pending/interop/examples_and_tests_together.feature +80 -0
- data/features-pending/interop/rspec_output.feature +25 -0
- data/features-pending/interop/test_but_not_test_unit.feature +26 -0
- data/features-pending/interop/test_case_with_should_methods.feature +46 -0
- data/features-pending/matchers/define_diffable_matcher.feature +26 -0
- data/features-pending/matchers/define_matcher.feature +179 -0
- data/features-pending/matchers/define_matcher_with_fluent_interface.feature +27 -0
- data/features-pending/mocks/mix_stubs_and_mocks.feature +22 -0
- data/features-pending/mocks/stub_implementation.feature +26 -0
- data/features-pending/pending/pending_examples.feature +81 -0
- data/features-pending/runner/specify_line_number.feature +32 -0
- data/features/before_and_after_blocks/before_and_after_blocks.feature +169 -0
- data/features/expectations/customized_message.feature +54 -0
- data/features/matchers/define_matcher_outside_rspec.feature +39 -0
- data/features/mock_framework_integration/use_flexmock.feature +23 -0
- data/features/mock_framework_integration/use_mocha.feature +23 -0
- data/features/mock_framework_integration/use_rr.feature +23 -0
- data/features/mock_framework_integration/use_rspec.feature +23 -0
- data/features/step_definitions/running_rspec_steps.rb +35 -0
- data/features/subject/explicit_subject.feature +31 -0
- data/features/subject/implicit_subject.feature +31 -0
- data/features/support/env.rb +82 -0
- data/features/support/matchers/smart_match.rb +14 -0
- data/lib/rspec/autorun.rb +2 -0
- data/lib/rspec/core.rb +38 -0
- data/lib/rspec/core/backward_compatibility.rb +9 -0
- data/lib/rspec/core/command_line_options.rb +60 -0
- data/lib/rspec/core/configuration.rb +222 -0
- data/lib/rspec/core/deprecation.rb +47 -0
- data/lib/rspec/core/example.rb +113 -0
- data/lib/rspec/core/example_group.rb +239 -0
- data/lib/rspec/core/example_group_subject.rb +77 -0
- data/lib/rspec/core/formatters.rb +16 -0
- data/lib/rspec/core/formatters/base_formatter.rb +123 -0
- data/lib/rspec/core/formatters/base_text_formatter.rb +139 -0
- data/lib/rspec/core/formatters/documentation_formatter.rb +84 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +36 -0
- data/lib/rspec/core/kernel_extensions.rb +15 -0
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +13 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +25 -0
- data/lib/rspec/core/mocking/with_mocha.rb +22 -0
- data/lib/rspec/core/mocking/with_rr.rb +26 -0
- data/lib/rspec/core/mocking/with_rspec.rb +21 -0
- data/lib/rspec/core/rake_task.rb +88 -0
- data/lib/rspec/core/runner.rb +66 -0
- data/lib/rspec/core/shared_behaviour.rb +41 -0
- data/lib/rspec/core/shared_behaviour_kernel_extensions.rb +31 -0
- data/lib/rspec/core/version.rb +16 -0
- data/lib/rspec/core/world.rb +105 -0
- data/rspec-core.gemspec +204 -0
- data/script/console +8 -0
- data/spec/resources/example_classes.rb +67 -0
- data/spec/rspec/core/command_line_options_spec.rb +63 -0
- data/spec/rspec/core/configuration_spec.rb +171 -0
- data/spec/rspec/core/example_group_spec.rb +351 -0
- data/spec/rspec/core/example_group_subject_spec.rb +67 -0
- data/spec/rspec/core/example_spec.rb +67 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +105 -0
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +5 -0
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +29 -0
- data/spec/rspec/core/kernel_extensions_spec.rb +13 -0
- data/spec/rspec/core/mocha_spec.rb +29 -0
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +1 -0
- data/spec/rspec/core/resources/custom_example_group_runner.rb +14 -0
- data/spec/rspec/core/resources/example_classes.rb +67 -0
- data/spec/rspec/core/resources/utf8_encoded.rb +8 -0
- data/spec/rspec/core/runner_spec.rb +34 -0
- data/spec/rspec/core/shared_behaviour_spec.rb +185 -0
- data/spec/rspec/core/world_spec.rb +167 -0
- data/spec/rspec/core_spec.rb +35 -0
- data/spec/ruby_forker.rb +13 -0
- data/spec/spec_helper.rb +72 -0
- metadata +219 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'mocha/standalone'
|
2
|
+
require 'mocha/object'
|
3
|
+
|
4
|
+
module Rspec
|
5
|
+
module Core
|
6
|
+
module Mocking
|
7
|
+
module WithMocha
|
8
|
+
# Mocha::Standalone was deprecated as of Mocha 0.9.7.
|
9
|
+
begin
|
10
|
+
include Mocha::API
|
11
|
+
rescue NameError
|
12
|
+
include Mocha::Standalone
|
13
|
+
end
|
14
|
+
|
15
|
+
alias :_setup_mocks :mocha_setup
|
16
|
+
alias :_verify_mocks :mocha_verify
|
17
|
+
alias :_teardown_mocks :mocha_teardown
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rr'
|
2
|
+
|
3
|
+
Rspec::Core.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
|
4
|
+
|
5
|
+
module Rspec
|
6
|
+
module Core
|
7
|
+
module Mocking
|
8
|
+
module WithRR
|
9
|
+
include RR::Extensions::InstanceMethods
|
10
|
+
|
11
|
+
def _setup_mocks
|
12
|
+
RR::Space.instance.reset
|
13
|
+
end
|
14
|
+
|
15
|
+
def _verify_mocks
|
16
|
+
RR::Space.instance.verify_doubles
|
17
|
+
end
|
18
|
+
|
19
|
+
def _teardown_mocks
|
20
|
+
RR::Space.instance.reset
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rspec/mocks/framework'
|
2
|
+
require 'rspec/mocks/extensions'
|
3
|
+
|
4
|
+
module Rspec
|
5
|
+
module Core
|
6
|
+
module Mocking
|
7
|
+
module WithRspec
|
8
|
+
include Rspec::Mocks::ExampleMethods
|
9
|
+
def _setup_mocks
|
10
|
+
$rspec_mocks ||= Rspec::Mocks::Space.new
|
11
|
+
end
|
12
|
+
def _verify_mocks
|
13
|
+
$rspec_mocks.verify_all
|
14
|
+
end
|
15
|
+
def _teardown_mocks
|
16
|
+
$rspec_mocks.reset_all
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/tasklib'
|
5
|
+
|
6
|
+
module Rspec
|
7
|
+
module Core
|
8
|
+
|
9
|
+
class RakeTask < ::Rake::TaskLib
|
10
|
+
|
11
|
+
# Name of task. (default is :spec)
|
12
|
+
attr_accessor :name
|
13
|
+
|
14
|
+
# If true, requests that the specs be run with the warning flag set.
|
15
|
+
# E.g. warning=true implies "ruby -w" used to run the specs. Defaults to false.
|
16
|
+
attr_accessor :warning
|
17
|
+
|
18
|
+
# Glob pattern to match files. (default is 'spec/**/*_spec.rb')
|
19
|
+
attr_accessor :pattern
|
20
|
+
|
21
|
+
# Array of commandline options to pass to ruby. Defaults to [].
|
22
|
+
attr_accessor :ruby_opts
|
23
|
+
|
24
|
+
# Whether or not to fail Rake when an error occurs (typically when examples fail).
|
25
|
+
# Defaults to true.
|
26
|
+
attr_accessor :fail_on_error
|
27
|
+
|
28
|
+
# A message to print to stderr when there are failures.
|
29
|
+
attr_accessor :failure_message
|
30
|
+
|
31
|
+
# Use verbose output. If this is set to true, the task will print
|
32
|
+
# the executed spec command to stdout. Defaults to false.
|
33
|
+
attr_accessor :verbose
|
34
|
+
|
35
|
+
# Use rcov for code coverage? defaults to false
|
36
|
+
attr_accessor :rcov
|
37
|
+
|
38
|
+
# The options to pass to rcov. Defaults to blank
|
39
|
+
attr_accessor :rcov_opts
|
40
|
+
|
41
|
+
# The options to pass to ruby. Defaults to blank
|
42
|
+
attr_accessor :ruby_opts
|
43
|
+
|
44
|
+
def initialize(*args)
|
45
|
+
@name = args.shift || :spec
|
46
|
+
@pattern, @rcov_opts, @ruby_opts = nil, nil, nil
|
47
|
+
@warning, @rcov = false, false
|
48
|
+
@fail_on_error = true
|
49
|
+
|
50
|
+
yield self if block_given?
|
51
|
+
@pattern ||= 'spec/**/*_spec.rb'
|
52
|
+
define
|
53
|
+
end
|
54
|
+
|
55
|
+
def define # :nodoc:
|
56
|
+
actual_name = Hash === name ? name.keys.first : name
|
57
|
+
desc("Run all examples") unless ::Rake.application.last_comment
|
58
|
+
|
59
|
+
task name do
|
60
|
+
RakeFileUtils.send(:verbose, verbose) do
|
61
|
+
if files_to_run.empty?
|
62
|
+
puts "No examples matching #{pattern} could be found"
|
63
|
+
else
|
64
|
+
cmd_parts = [rcov ? 'rcov' : RUBY]
|
65
|
+
cmd_parts += rcov ? [rcov_opts] : [ruby_opts]
|
66
|
+
cmd_parts << "-w" if warning
|
67
|
+
cmd_parts += files_to_run.collect { |fn| %["#{fn}"] }
|
68
|
+
cmd = cmd_parts.join(" ")
|
69
|
+
puts cmd if verbose
|
70
|
+
unless system(cmd)
|
71
|
+
STDERR.puts failure_message if failure_message
|
72
|
+
raise("Command #{cmd} failed") if fail_on_error
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
81
|
+
def files_to_run # :nodoc:
|
82
|
+
FileList[ pattern ].to_a
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Rspec
|
2
|
+
module Core
|
3
|
+
|
4
|
+
class Runner
|
5
|
+
|
6
|
+
def self.installed_at_exit?
|
7
|
+
@installed_at_exit ||= false
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.autorun
|
11
|
+
return if installed_at_exit?
|
12
|
+
@installed_at_exit = true
|
13
|
+
at_exit { new.run(ARGV) ? exit(0) : exit(1) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def configuration
|
17
|
+
Rspec::Core.configuration
|
18
|
+
end
|
19
|
+
|
20
|
+
def formatter
|
21
|
+
configuration.formatter
|
22
|
+
end
|
23
|
+
|
24
|
+
def require_all_files(files)
|
25
|
+
files.each { |file| require file }
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(args = [])
|
29
|
+
cli_config = Rspec::Core::CommandLineOptions.parse(args)
|
30
|
+
|
31
|
+
require_all_files(cli_config.files_to_run)
|
32
|
+
|
33
|
+
cli_config.apply(configuration)
|
34
|
+
|
35
|
+
total_examples_to_run = Rspec::Core.world.total_examples_to_run
|
36
|
+
|
37
|
+
old_sync, formatter.output.sync = formatter.output.sync, true if formatter.output.respond_to?(:sync=)
|
38
|
+
|
39
|
+
suite_success = true
|
40
|
+
|
41
|
+
formatter_supports_sync = formatter.output.respond_to?(:sync=)
|
42
|
+
old_sync, formatter.output.sync = formatter.output.sync, true if formatter_supports_sync
|
43
|
+
|
44
|
+
formatter.start(total_examples_to_run) # start the clock
|
45
|
+
start = Time.now
|
46
|
+
|
47
|
+
Rspec::Core.world.behaviours_to_run.each do |behaviour|
|
48
|
+
suite_success &= behaviour.run(formatter)
|
49
|
+
end
|
50
|
+
|
51
|
+
formatter.start_dump(Time.now - start)
|
52
|
+
|
53
|
+
formatter.dump_failures
|
54
|
+
formatter.dump_summary
|
55
|
+
formatter.dump_pending
|
56
|
+
formatter.close
|
57
|
+
|
58
|
+
formatter.output.sync = old_sync if formatter_supports_sync
|
59
|
+
|
60
|
+
suite_success
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Rspec
|
2
|
+
module Core
|
3
|
+
module SharedBehaviour
|
4
|
+
|
5
|
+
def share_examples_for(name, &block)
|
6
|
+
ensure_shared_example_group_name_not_taken(name)
|
7
|
+
Rspec::Core.world.shared_behaviours[name] = block
|
8
|
+
end
|
9
|
+
|
10
|
+
def share_as(name, &block)
|
11
|
+
if Object.const_defined?(name)
|
12
|
+
raise NameError, "The first argument (#{name}) to share_as must be a legal name for a constant not already in use."
|
13
|
+
end
|
14
|
+
|
15
|
+
mod = Module.new do
|
16
|
+
@shared_block = block
|
17
|
+
|
18
|
+
def self.included(kls)
|
19
|
+
kls.module_eval(&@shared_block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
shared_const = Object.const_set(name, mod)
|
24
|
+
Rspec::Core.world.shared_behaviours[shared_const] = block
|
25
|
+
end
|
26
|
+
|
27
|
+
alias :shared_examples_for :share_examples_for
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def ensure_shared_example_group_name_not_taken(name)
|
32
|
+
if Rspec::Core.world.shared_behaviours.has_key?(name)
|
33
|
+
raise ArgumentError.new("Shared example group '#{name}' already exists")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
include Rspec::Core::SharedBehaviour
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Rspec
|
2
|
+
module Core
|
3
|
+
module SharedBehaviourKernelExtensions
|
4
|
+
|
5
|
+
def share_examples_for(name, &block)
|
6
|
+
Rspec::Core.world.shared_behaviours[name] = block
|
7
|
+
end
|
8
|
+
|
9
|
+
def share_as(name, &block)
|
10
|
+
if Object.const_defined?(name)
|
11
|
+
puts "name was defined as #{name.inspect}"
|
12
|
+
raise NameError, "The first argument (#{name}) to share_as must be a legal name for a constant not already in use."
|
13
|
+
end
|
14
|
+
|
15
|
+
mod = Module.new do
|
16
|
+
@shared_block = block
|
17
|
+
|
18
|
+
def self.included(kls)
|
19
|
+
kls.module_eval(&@shared_block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
shared_const = Object.const_set(name, mod)
|
24
|
+
Rspec::Core.world.shared_behaviours[shared_const] = block
|
25
|
+
end
|
26
|
+
|
27
|
+
alias :shared_examples_for :share_examples_for
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Rspec # :nodoc:
|
2
|
+
module Core # :nodoc:
|
3
|
+
module Version # :nodoc:
|
4
|
+
unless defined?(MAJOR)
|
5
|
+
MAJOR = 2
|
6
|
+
MINOR = 0
|
7
|
+
TINY = 0
|
8
|
+
PRE = 'a1'
|
9
|
+
|
10
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
11
|
+
|
12
|
+
SUMMARY = "rspec-core #{STRING}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Rspec
|
2
|
+
|
3
|
+
module Core
|
4
|
+
|
5
|
+
class World
|
6
|
+
|
7
|
+
attr_reader :behaviours
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@behaviours = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def filter
|
14
|
+
Rspec::Core.configuration.filter
|
15
|
+
end
|
16
|
+
|
17
|
+
def exclusion_filter
|
18
|
+
Rspec::Core.configuration.exclusion_filter
|
19
|
+
end
|
20
|
+
|
21
|
+
def shared_behaviours
|
22
|
+
@shared_behaviours ||= {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def behaviours_to_run
|
26
|
+
return @behaviours_to_run if @behaviours_to_run
|
27
|
+
|
28
|
+
if filter || exclusion_filter
|
29
|
+
@behaviours_to_run = filter_behaviours
|
30
|
+
|
31
|
+
if @behaviours_to_run.size == 0 && Rspec::Core.configuration.run_all_when_everything_filtered?
|
32
|
+
Rspec::Core.configuration.puts "No examples were matched by #{filter.inspect}, running all"
|
33
|
+
# reset the behaviour list to all behaviours, and add back all examples
|
34
|
+
@behaviours_to_run = @behaviours
|
35
|
+
@behaviours.each { |b| b.examples_to_run.replace(b.examples) }
|
36
|
+
else
|
37
|
+
Rspec::Core.configuration.puts "Run filtered using #{filter.inspect}"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
@behaviours_to_run = @behaviours
|
41
|
+
@behaviours.each { |b| b.examples_to_run.replace(b.examples) }
|
42
|
+
end
|
43
|
+
|
44
|
+
@behaviours_to_run
|
45
|
+
end
|
46
|
+
|
47
|
+
def total_examples_to_run
|
48
|
+
@total_examples_to_run ||= behaviours_to_run.inject(0) { |sum, b| sum += b.examples_to_run.size }
|
49
|
+
end
|
50
|
+
|
51
|
+
def filter_behaviours
|
52
|
+
behaviours.inject([]) do |list_of_behaviors, _behavior|
|
53
|
+
examples = _behavior.examples
|
54
|
+
examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter
|
55
|
+
examples = apply_inclusion_filters(examples, filter) if filter
|
56
|
+
examples.uniq!
|
57
|
+
_behavior.examples_to_run.replace(examples)
|
58
|
+
if examples.empty?
|
59
|
+
list_of_behaviors << nil
|
60
|
+
else
|
61
|
+
list_of_behaviors << _behavior
|
62
|
+
end
|
63
|
+
end.compact
|
64
|
+
end
|
65
|
+
|
66
|
+
def find(collection, type_of_filter=:positive, conditions={})
|
67
|
+
negative = type_of_filter != :positive
|
68
|
+
|
69
|
+
collection.select do |item|
|
70
|
+
# negative conditions.any?, positive conditions.all? ?????
|
71
|
+
result = conditions.all? do |filter_on, filter|
|
72
|
+
apply_condition(filter_on, filter, item.metadata)
|
73
|
+
end
|
74
|
+
negative ? !result : result
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def apply_inclusion_filters(collection, conditions={})
|
79
|
+
find(collection, :positive, conditions)
|
80
|
+
end
|
81
|
+
|
82
|
+
def apply_exclusion_filters(collection, conditions={})
|
83
|
+
find(collection, :negative, conditions)
|
84
|
+
end
|
85
|
+
|
86
|
+
def apply_condition(filter_on, filter, metadata)
|
87
|
+
return false if metadata.nil?
|
88
|
+
|
89
|
+
case filter
|
90
|
+
when Hash
|
91
|
+
filter.all? { |k, v| apply_condition(k, v, metadata[filter_on]) }
|
92
|
+
when Regexp
|
93
|
+
metadata[filter_on] =~ filter
|
94
|
+
when Proc
|
95
|
+
filter.call(metadata[filter_on]) rescue false
|
96
|
+
else
|
97
|
+
metadata[filter_on] == filter
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
data/rspec-core.gemspec
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rspec-core}
|
8
|
+
s.version = "2.0.0.a1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["David Chelimsky", "Chad Humphries"]
|
12
|
+
s.date = %q{2009-09-16}
|
13
|
+
s.default_executable = %q{rspec}
|
14
|
+
s.description = %q{RSpec Core}
|
15
|
+
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
16
|
+
s.executables = ["rspec"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.markdown"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".gitignore",
|
23
|
+
".treasure_map.rb",
|
24
|
+
"License.txt",
|
25
|
+
"README.markdown",
|
26
|
+
"Rakefile",
|
27
|
+
"TODO.markdown",
|
28
|
+
"VERSION",
|
29
|
+
"VERSION.yml",
|
30
|
+
"bin/rspec",
|
31
|
+
"cucumber.yml",
|
32
|
+
"example_specs/failing/README.txt",
|
33
|
+
"example_specs/failing/diffing_spec.rb",
|
34
|
+
"example_specs/failing/failing_implicit_docstrings_example.rb",
|
35
|
+
"example_specs/failing/failure_in_after.rb",
|
36
|
+
"example_specs/failing/failure_in_before.rb",
|
37
|
+
"example_specs/failing/mocking_example.rb",
|
38
|
+
"example_specs/failing/mocking_with_flexmock.rb",
|
39
|
+
"example_specs/failing/mocking_with_mocha.rb",
|
40
|
+
"example_specs/failing/mocking_with_rr.rb",
|
41
|
+
"example_specs/failing/partial_mock_example.rb",
|
42
|
+
"example_specs/failing/pending_example.rb",
|
43
|
+
"example_specs/failing/predicate_example.rb",
|
44
|
+
"example_specs/failing/raising_example.rb",
|
45
|
+
"example_specs/failing/spec_helper.rb",
|
46
|
+
"example_specs/failing/syntax_error_example.rb",
|
47
|
+
"example_specs/failing/team_spec.rb",
|
48
|
+
"example_specs/failing/timeout_behaviour.rb",
|
49
|
+
"example_specs/passing/custom_formatter.rb",
|
50
|
+
"example_specs/passing/custom_matchers.rb",
|
51
|
+
"example_specs/passing/dynamic_spec.rb",
|
52
|
+
"example_specs/passing/file_accessor.rb",
|
53
|
+
"example_specs/passing/file_accessor_spec.rb",
|
54
|
+
"example_specs/passing/filtered_formatter.rb",
|
55
|
+
"example_specs/passing/filtered_formatter_example.rb",
|
56
|
+
"example_specs/passing/greeter_spec.rb",
|
57
|
+
"example_specs/passing/helper_method_example.rb",
|
58
|
+
"example_specs/passing/implicit_docstrings_example.rb",
|
59
|
+
"example_specs/passing/io_processor.rb",
|
60
|
+
"example_specs/passing/io_processor_spec.rb",
|
61
|
+
"example_specs/passing/mocking_example.rb",
|
62
|
+
"example_specs/passing/multi_threaded_example_group_runner.rb",
|
63
|
+
"example_specs/passing/nested_classes_example.rb",
|
64
|
+
"example_specs/passing/options_example.rb",
|
65
|
+
"example_specs/passing/options_formatter.rb",
|
66
|
+
"example_specs/passing/partial_mock_example.rb",
|
67
|
+
"example_specs/passing/pending_example.rb",
|
68
|
+
"example_specs/passing/predicate_example.rb",
|
69
|
+
"example_specs/passing/shared_example_group_example.rb",
|
70
|
+
"example_specs/passing/shared_stack_examples.rb",
|
71
|
+
"example_specs/passing/simple_matcher_example.rb",
|
72
|
+
"example_specs/passing/spec_helper.rb",
|
73
|
+
"example_specs/passing/stack.rb",
|
74
|
+
"example_specs/passing/stack_spec.rb",
|
75
|
+
"example_specs/passing/stack_spec_with_nested_example_groups.rb",
|
76
|
+
"example_specs/passing/stubbing_example.rb",
|
77
|
+
"example_specs/passing/yielding_example.rb",
|
78
|
+
"example_specs/ruby1.9.compatibility/access_to_constants_spec.rb",
|
79
|
+
"features-pending/command_line/line_number_option.feature",
|
80
|
+
"features-pending/command_line/line_number_option_with_example_with_no_name.feature",
|
81
|
+
"features-pending/example_groups/example_group_with_should_methods.feature",
|
82
|
+
"features-pending/example_groups/implicit_docstrings.feature",
|
83
|
+
"features-pending/example_groups/nested_groups.feature",
|
84
|
+
"features-pending/expectations/expect_change.feature",
|
85
|
+
"features-pending/expectations/expect_error.feature",
|
86
|
+
"features-pending/extensions/custom_example_group.feature",
|
87
|
+
"features-pending/formatters/custom_formatter.feature",
|
88
|
+
"features-pending/heckle/heckle.feature",
|
89
|
+
"features-pending/interop/examples_and_tests_together.feature",
|
90
|
+
"features-pending/interop/rspec_output.feature",
|
91
|
+
"features-pending/interop/test_but_not_test_unit.feature",
|
92
|
+
"features-pending/interop/test_case_with_should_methods.feature",
|
93
|
+
"features-pending/matchers/define_diffable_matcher.feature",
|
94
|
+
"features-pending/matchers/define_matcher.feature",
|
95
|
+
"features-pending/matchers/define_matcher_with_fluent_interface.feature",
|
96
|
+
"features-pending/mocks/mix_stubs_and_mocks.feature",
|
97
|
+
"features-pending/mocks/stub_implementation.feature",
|
98
|
+
"features-pending/pending/pending_examples.feature",
|
99
|
+
"features-pending/runner/specify_line_number.feature",
|
100
|
+
"features/before_and_after_blocks/before_and_after_blocks.feature",
|
101
|
+
"features/expectations/customized_message.feature",
|
102
|
+
"features/matchers/define_matcher_outside_rspec.feature",
|
103
|
+
"features/mock_framework_integration/use_flexmock.feature",
|
104
|
+
"features/mock_framework_integration/use_mocha.feature",
|
105
|
+
"features/mock_framework_integration/use_rr.feature",
|
106
|
+
"features/mock_framework_integration/use_rspec.feature",
|
107
|
+
"features/step_definitions/running_rspec_steps.rb",
|
108
|
+
"features/subject/explicit_subject.feature",
|
109
|
+
"features/subject/implicit_subject.feature",
|
110
|
+
"features/support/env.rb",
|
111
|
+
"features/support/matchers/smart_match.rb",
|
112
|
+
"lib/rspec/autorun.rb",
|
113
|
+
"lib/rspec/core.rb",
|
114
|
+
"lib/rspec/core/backward_compatibility.rb",
|
115
|
+
"lib/rspec/core/command_line_options.rb",
|
116
|
+
"lib/rspec/core/configuration.rb",
|
117
|
+
"lib/rspec/core/deprecation.rb",
|
118
|
+
"lib/rspec/core/example.rb",
|
119
|
+
"lib/rspec/core/example_group.rb",
|
120
|
+
"lib/rspec/core/example_group_subject.rb",
|
121
|
+
"lib/rspec/core/formatters.rb",
|
122
|
+
"lib/rspec/core/formatters/base_formatter.rb",
|
123
|
+
"lib/rspec/core/formatters/base_text_formatter.rb",
|
124
|
+
"lib/rspec/core/formatters/documentation_formatter.rb",
|
125
|
+
"lib/rspec/core/formatters/progress_formatter.rb",
|
126
|
+
"lib/rspec/core/kernel_extensions.rb",
|
127
|
+
"lib/rspec/core/mocking/with_absolutely_nothing.rb",
|
128
|
+
"lib/rspec/core/mocking/with_flexmock.rb",
|
129
|
+
"lib/rspec/core/mocking/with_mocha.rb",
|
130
|
+
"lib/rspec/core/mocking/with_rr.rb",
|
131
|
+
"lib/rspec/core/mocking/with_rspec.rb",
|
132
|
+
"lib/rspec/core/rake_task.rb",
|
133
|
+
"lib/rspec/core/runner.rb",
|
134
|
+
"lib/rspec/core/shared_behaviour.rb",
|
135
|
+
"lib/rspec/core/shared_behaviour_kernel_extensions.rb",
|
136
|
+
"lib/rspec/core/world.rb",
|
137
|
+
"lib/rspec/core/version.rb",
|
138
|
+
"rspec-core.gemspec",
|
139
|
+
"script/console",
|
140
|
+
"spec/resources/example_classes.rb",
|
141
|
+
"spec/rspec/core/command_line_options_spec.rb",
|
142
|
+
"spec/rspec/core/configuration_spec.rb",
|
143
|
+
"spec/rspec/core/example_group_spec.rb",
|
144
|
+
"spec/rspec/core/example_group_subject_spec.rb",
|
145
|
+
"spec/rspec/core/example_spec.rb",
|
146
|
+
"spec/rspec/core/formatters/base_formatter_spec.rb",
|
147
|
+
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
|
148
|
+
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
149
|
+
"spec/rspec/core/kernel_extensions_spec.rb",
|
150
|
+
"spec/rspec/core/mocha_spec.rb",
|
151
|
+
"spec/rspec/core/resources/a_bar.rb",
|
152
|
+
"spec/rspec/core/resources/a_foo.rb",
|
153
|
+
"spec/rspec/core/resources/a_spec.rb",
|
154
|
+
"spec/rspec/core/resources/custom_example_group_runner.rb",
|
155
|
+
"spec/rspec/core/resources/example_classes.rb",
|
156
|
+
"spec/rspec/core/resources/utf8_encoded.rb",
|
157
|
+
"spec/rspec/core/runner_spec.rb",
|
158
|
+
"spec/rspec/core/shared_behaviour_spec.rb",
|
159
|
+
"spec/rspec/core/world_spec.rb",
|
160
|
+
"spec/rspec/core_spec.rb",
|
161
|
+
"spec/ruby_forker.rb",
|
162
|
+
"spec/spec_helper.rb"
|
163
|
+
]
|
164
|
+
s.homepage = %q{http://github.com/rspec/core}
|
165
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
166
|
+
s.require_paths = ["lib"]
|
167
|
+
s.rubygems_version = %q{1.3.5}
|
168
|
+
s.summary = %q{RSpec Core}
|
169
|
+
s.test_files = [
|
170
|
+
"spec/resources/example_classes.rb",
|
171
|
+
"spec/rspec/core/command_line_options_spec.rb",
|
172
|
+
"spec/rspec/core/configuration_spec.rb",
|
173
|
+
"spec/rspec/core/example_group_spec.rb",
|
174
|
+
"spec/rspec/core/example_group_subject_spec.rb",
|
175
|
+
"spec/rspec/core/example_spec.rb",
|
176
|
+
"spec/rspec/core/formatters/base_formatter_spec.rb",
|
177
|
+
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
|
178
|
+
"spec/rspec/core/formatters/progress_formatter_spec.rb",
|
179
|
+
"spec/rspec/core/kernel_extensions_spec.rb",
|
180
|
+
"spec/rspec/core/mocha_spec.rb",
|
181
|
+
"spec/rspec/core/resources/a_bar.rb",
|
182
|
+
"spec/rspec/core/resources/a_foo.rb",
|
183
|
+
"spec/rspec/core/resources/a_spec.rb",
|
184
|
+
"spec/rspec/core/resources/custom_example_group_runner.rb",
|
185
|
+
"spec/rspec/core/resources/example_classes.rb",
|
186
|
+
"spec/rspec/core/resources/utf8_encoded.rb",
|
187
|
+
"spec/rspec/core/runner_spec.rb",
|
188
|
+
"spec/rspec/core/shared_behaviour_spec.rb",
|
189
|
+
"spec/rspec/core/world_spec.rb",
|
190
|
+
"spec/rspec/core_spec.rb",
|
191
|
+
"spec/ruby_forker.rb",
|
192
|
+
"spec/spec_helper.rb"
|
193
|
+
]
|
194
|
+
|
195
|
+
if s.respond_to? :specification_version then
|
196
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
197
|
+
s.specification_version = 3
|
198
|
+
|
199
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
200
|
+
else
|
201
|
+
end
|
202
|
+
else
|
203
|
+
end
|
204
|
+
end
|