rspec-core 2.0.0.beta.22 → 2.6.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.
- data/.gitignore +1 -0
- data/.rspec +0 -1
- data/.travis.yml +7 -0
- data/Gemfile +46 -20
- data/Guardfile +5 -0
- data/License.txt +2 -1
- data/{README.markdown → README.md} +23 -5
- data/Rakefile +58 -31
- data/bin/autospec +13 -0
- data/bin/rspec +24 -2
- data/cucumber.yml +1 -1
- data/features/.nav +57 -0
- data/features/Autotest.md +38 -0
- data/features/Changelog.md +269 -0
- data/features/README.md +17 -0
- data/features/Upgrade.md +320 -0
- data/features/command_line/README.md +28 -0
- data/features/command_line/configure.feature +18 -15
- data/features/command_line/example_name_option.feature +37 -23
- data/features/command_line/exit_status.feature +16 -31
- data/features/command_line/format_option.feature +73 -0
- data/features/command_line/line_number_appended_to_path.feature +25 -27
- data/features/command_line/line_number_option.feature +11 -10
- data/features/command_line/rake_task.feature +68 -0
- data/features/command_line/tag.feature +90 -0
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +8 -10
- data/features/configuration/fail_fast.feature +77 -0
- data/features/configuration/read_options_from_file.feature +42 -26
- data/features/example_groups/basic_structure.feature +55 -0
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +56 -41
- data/features/expectation_framework_integration/configure_expectation_framework.feature +73 -0
- data/features/filtering/exclusion_filters.feature +69 -9
- data/features/filtering/if_and_unless.feature +168 -0
- data/features/filtering/inclusion_filters.feature +58 -26
- data/features/filtering/run_all_when_everything_filtered.feature +46 -0
- data/features/formatters/custom_formatter.feature +17 -13
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +40 -0
- data/features/helper_methods/let.feature +50 -0
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +99 -69
- data/features/hooks/before_and_after_hooks.feature +74 -40
- data/features/hooks/filtering.feature +227 -0
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +17 -0
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +106 -0
- data/features/mock_framework_integration/use_flexmock.feature +84 -11
- data/features/mock_framework_integration/use_mocha.feature +85 -11
- data/features/mock_framework_integration/use_rr.feature +86 -11
- data/features/mock_framework_integration/use_rspec.feature +85 -11
- data/features/pending/pending_examples.feature +143 -5
- data/features/spec_files/arbitrary_file_suffix.feature +2 -2
- data/features/step_definitions/additional_cli_steps.rb +30 -0
- data/features/subject/attribute_of_subject.feature +93 -15
- data/features/subject/explicit_subject.feature +28 -17
- data/features/subject/implicit_receiver.feature +29 -0
- data/features/subject/implicit_subject.feature +9 -10
- data/features/support/env.rb +6 -1
- data/lib/autotest/discover.rb +1 -0
- data/lib/autotest/rspec2.rb +15 -11
- data/lib/rspec/autorun.rb +2 -0
- data/lib/rspec/core/backward_compatibility.rb +33 -4
- data/lib/rspec/core/command_line.rb +4 -28
- data/lib/rspec/core/command_line_configuration.rb +16 -16
- data/lib/rspec/core/configuration.rb +279 -89
- data/lib/rspec/core/configuration_options.rb +46 -35
- data/lib/rspec/core/deprecation.rb +1 -1
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/example.rb +63 -39
- data/lib/rspec/core/example_group.rb +109 -59
- data/lib/rspec/core/expecting/with_rspec.rb +11 -0
- data/lib/rspec/core/expecting/with_stdlib.rb +9 -0
- data/lib/rspec/core/extensions/kernel.rb +1 -1
- data/lib/rspec/core/extensions/object.rb +1 -3
- data/lib/rspec/core/formatters/base_formatter.rb +22 -11
- data/lib/rspec/core/formatters/base_text_formatter.rb +46 -30
- data/lib/rspec/core/formatters/documentation_formatter.rb +4 -2
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/formatters/html_formatter.rb +146 -41
- data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
- data/lib/rspec/core/formatters/text_mate_formatter.rb +3 -1
- data/lib/rspec/core/hooks.rb +55 -17
- data/lib/rspec/core/metadata.rb +75 -64
- data/lib/rspec/core/metadata_hash_builder.rb +93 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
- data/lib/rspec/core/mocking/with_mocha.rb +2 -0
- data/lib/rspec/core/mocking/with_rr.rb +2 -0
- data/lib/rspec/core/mocking/with_rspec.rb +3 -1
- data/lib/rspec/core/option_parser.rb +48 -5
- data/lib/rspec/core/pending.rb +22 -4
- data/lib/rspec/core/rake_task.rb +64 -28
- data/lib/rspec/core/reporter.rb +3 -2
- data/lib/rspec/core/ruby_project.rb +2 -2
- data/lib/rspec/core/runner.rb +50 -6
- data/lib/rspec/core/shared_context.rb +16 -0
- data/lib/rspec/core/shared_example_group.rb +19 -4
- data/lib/rspec/core/subject.rb +92 -65
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +83 -25
- data/lib/rspec/core.rb +40 -24
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +4 -25
- data/script/FullBuildRakeFile +63 -0
- data/script/cucumber +1 -0
- data/script/full_build +1 -0
- data/script/spec +1 -0
- data/spec/autotest/discover_spec.rb +19 -0
- data/spec/autotest/failed_results_re_spec.rb +25 -9
- data/spec/autotest/rspec_spec.rb +32 -41
- data/spec/rspec/core/command_line_spec.rb +62 -7
- data/spec/rspec/core/configuration_options_spec.rb +184 -148
- data/spec/rspec/core/configuration_spec.rb +406 -108
- data/spec/rspec/core/deprecations_spec.rb +38 -1
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +366 -127
- data/spec/rspec/core/example_spec.rb +125 -45
- data/spec/rspec/core/formatters/base_formatter_spec.rb +61 -1
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +39 -5
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +7 -6
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +199 -81
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +199 -83
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +199 -81
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +206 -81
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +206 -61
- data/spec/rspec/core/formatters/html_formatter_spec.rb +17 -9
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +199 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +199 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +199 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +206 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +206 -81
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +22 -7
- data/spec/rspec/core/hooks_filtering_spec.rb +128 -5
- data/spec/rspec/core/hooks_spec.rb +90 -4
- data/spec/rspec/core/metadata_spec.rb +176 -163
- data/spec/rspec/core/option_parser_spec.rb +73 -6
- data/spec/rspec/core/pending_example_spec.rb +137 -35
- data/spec/rspec/core/rake_task_spec.rb +62 -29
- data/spec/rspec/core/reporter_spec.rb +20 -4
- data/spec/rspec/core/resources/formatter_specs.rb +25 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +60 -10
- data/spec/rspec/core/shared_context_spec.rb +30 -0
- data/spec/rspec/core/shared_example_group_spec.rb +59 -23
- data/spec/rspec/core/subject_spec.rb +136 -0
- data/spec/rspec/core/world_spec.rb +211 -68
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +41 -23
- data/spec/support/matchers.rb +44 -13
- data/spec/support/shared_example_groups.rb +41 -0
- data/spec/support/spec_files.rb +44 -0
- data/spec.txt +1126 -0
- metadata +99 -168
- data/.treasure_map.rb +0 -23
- data/History.md +0 -30
- data/Upgrade.markdown +0 -150
- data/autotest/discover.rb +0 -2
- data/features/README.markdown +0 -12
- data/features/example_groups/describe_aliases.feature +0 -25
- data/features/example_groups/nested_groups.feature +0 -44
- data/features/hooks/described_class.feature +0 -14
- data/features/hooks/halt.feature +0 -26
- data/lib/rspec/core/around_proxy.rb +0 -14
- data/lib/rspec/core/formatters.rb +0 -8
- data/spec/ruby_forker.rb +0 -13
- data/specs.watchr +0 -59
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
Feature: implicit subject
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
If the first argument to the outermost example group is a class, an instance
|
|
4
|
+
of that class is exposed to each example via the subject() method.
|
|
5
|
+
|
|
7
6
|
Scenario: subject in top level group
|
|
8
7
|
Given a file named "top_level_subject_spec.rb" with:
|
|
9
8
|
"""
|
|
10
9
|
describe Array, "when first created" do
|
|
11
10
|
it "should be empty" do
|
|
12
|
-
subject.should
|
|
11
|
+
subject.should eq([])
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
14
|
"""
|
|
16
|
-
When I run
|
|
17
|
-
Then the
|
|
15
|
+
When I run `rspec ./top_level_subject_spec.rb`
|
|
16
|
+
Then the examples should all pass
|
|
18
17
|
|
|
19
18
|
Scenario: subject in a nested group
|
|
20
19
|
Given a file named "nested_subject_spec.rb" with:
|
|
@@ -22,10 +21,10 @@ Feature: implicit subject
|
|
|
22
21
|
describe Array do
|
|
23
22
|
describe "when first created" do
|
|
24
23
|
it "should be empty" do
|
|
25
|
-
subject.should
|
|
24
|
+
subject.should eq([])
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
"""
|
|
30
|
-
When I run
|
|
31
|
-
Then the
|
|
29
|
+
When I run `rspec nested_subject_spec.rb`
|
|
30
|
+
Then the examples should all pass
|
data/features/support/env.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Autotest.add_discovery { "rspec2" } if File.exist?("./.rspec")
|
data/lib/autotest/rspec2.rb
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
require 'autotest'
|
|
2
|
+
require 'rspec/core/deprecation'
|
|
2
3
|
|
|
3
4
|
class RSpecCommandError < StandardError; end
|
|
4
5
|
|
|
5
6
|
class Autotest::Rspec2 < Autotest
|
|
6
7
|
|
|
7
|
-
SPEC_PROGRAM = File.expand_path(
|
|
8
|
+
SPEC_PROGRAM = File.expand_path('../../../bin/rspec', __FILE__)
|
|
8
9
|
|
|
9
10
|
def initialize
|
|
10
|
-
super
|
|
11
|
+
super()
|
|
11
12
|
clear_mappings
|
|
12
13
|
setup_rspec_project_mappings
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
# Example for Ruby 1.8: http://rubular.com/r/AOXNVDrZpx
|
|
16
|
+
# Example for Ruby 1.9: http://rubular.com/r/85ag5AZ2jP
|
|
17
|
+
self.failed_results_re = /^\s*\d+\).*\n\s+(?:\e\[\d*m)?Failure.*(\n(?:\e\[\d*m)?\s+#\s(.*)?:\d+(?::.*)?(?:\e\[\d*m)?)+$/m
|
|
14
18
|
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
|
|
15
19
|
end
|
|
16
20
|
|
|
@@ -38,11 +42,7 @@ class Autotest::Rspec2 < Autotest
|
|
|
38
42
|
|
|
39
43
|
def make_test_cmd(files_to_test)
|
|
40
44
|
files_to_test.empty? ? '' :
|
|
41
|
-
"#{ruby}
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def require_rubygems
|
|
45
|
-
using_bundler? ? "" : defined?(:Gem) ? "-rrubygems " : ""
|
|
45
|
+
"#{prefix}#{ruby}#{suffix} -S #{SPEC_PROGRAM} --tty #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}"
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def normalize(files_to_test)
|
|
@@ -52,12 +52,16 @@ class Autotest::Rspec2 < Autotest
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
def
|
|
56
|
-
using_bundler? ? "
|
|
55
|
+
def suffix
|
|
56
|
+
using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def using_bundler?
|
|
60
|
-
|
|
60
|
+
prefix =~ /bundle exec/
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def gemfile?
|
|
64
|
+
File.exist?('./Gemfile')
|
|
61
65
|
end
|
|
62
66
|
|
|
63
67
|
end
|
|
@@ -9,21 +9,50 @@ module RSpec
|
|
|
9
9
|
DEPRECATION WARNING: you are using a deprecated constant that will
|
|
10
10
|
be removed from a future version of RSpec.
|
|
11
11
|
|
|
12
|
+
#{caller(0)[2]}
|
|
13
|
+
|
|
12
14
|
* #{name} is deprecated.
|
|
13
15
|
* RSpec is the new top-level module in RSpec-2
|
|
14
|
-
|
|
15
|
-
#{caller(0)[1]}
|
|
16
|
-
*****************************************************************
|
|
16
|
+
***************************************************************
|
|
17
17
|
WARNING
|
|
18
18
|
RSpec
|
|
19
19
|
else
|
|
20
|
-
|
|
20
|
+
begin
|
|
21
|
+
super
|
|
22
|
+
rescue Exception => e
|
|
23
|
+
e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
|
|
24
|
+
raise e
|
|
25
|
+
end
|
|
21
26
|
end
|
|
22
27
|
end
|
|
23
28
|
end
|
|
29
|
+
end
|
|
24
30
|
|
|
31
|
+
module Runner
|
|
32
|
+
def self.configure(&block)
|
|
33
|
+
RSpec.deprecate("Spec::Runner.configure", "RSpec.configure")
|
|
34
|
+
RSpec.configure(&block)
|
|
35
|
+
end
|
|
25
36
|
end
|
|
26
37
|
|
|
38
|
+
module Rake
|
|
39
|
+
def self.const_missing(name)
|
|
40
|
+
case name
|
|
41
|
+
when :SpecTask
|
|
42
|
+
RSpec.deprecate("Spec::Rake::SpecTask", "RSpec::Core::RakeTask")
|
|
43
|
+
require 'rspec/core/rake_task'
|
|
44
|
+
RSpec::Core::RakeTask
|
|
45
|
+
else
|
|
46
|
+
begin
|
|
47
|
+
super
|
|
48
|
+
rescue Exception => e
|
|
49
|
+
e.backtrace.reject! {|l| l =~ Regexp.compile(__FILE__) }
|
|
50
|
+
raise e
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
27
56
|
end
|
|
28
57
|
|
|
29
58
|
Object.extend(RSpec::Core::ConstMissing)
|
|
@@ -12,44 +12,20 @@ module RSpec
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def run(err, out)
|
|
15
|
-
@options.configure(@configuration)
|
|
16
15
|
@configuration.error_stream = err
|
|
17
16
|
@configuration.output_stream ||= out
|
|
17
|
+
@options.configure(@configuration)
|
|
18
18
|
@configuration.load_spec_files
|
|
19
|
-
@
|
|
20
|
-
@world.announce_inclusion_filter
|
|
21
|
-
@world.announce_exclusion_filter
|
|
19
|
+
@world.announce_filters
|
|
22
20
|
|
|
23
|
-
@configuration.reporter.report(example_count) do |reporter|
|
|
21
|
+
@configuration.reporter.report(@world.example_count) do |reporter|
|
|
24
22
|
begin
|
|
25
23
|
@configuration.run_hook(:before, :suite)
|
|
26
|
-
example_groups.
|
|
24
|
+
@world.example_groups.map {|g| g.run(reporter)}.all? ? 0 : 1
|
|
27
25
|
ensure
|
|
28
26
|
@configuration.run_hook(:after, :suite)
|
|
29
27
|
end
|
|
30
28
|
end
|
|
31
|
-
|
|
32
|
-
example_groups.success?
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def example_count
|
|
38
|
-
@world.example_count
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
module ExampleGroups
|
|
42
|
-
def run_examples(reporter)
|
|
43
|
-
@success = self.inject(true) {|success, group| success &= group.run(reporter)}
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def success?
|
|
47
|
-
@success ||= false
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def example_groups
|
|
52
|
-
@world.example_groups.extend(ExampleGroups)
|
|
53
29
|
end
|
|
54
30
|
end
|
|
55
31
|
end
|
|
@@ -16,7 +16,7 @@ module RSpec
|
|
|
16
16
|
"#{@command}" is not valid a valid argument to "rspec --configure".
|
|
17
17
|
Supported options are:
|
|
18
18
|
|
|
19
|
-
rspec --configure autotest # generates
|
|
19
|
+
rspec --configure autotest # generates .rspec file
|
|
20
20
|
|
|
21
21
|
#{"*"*50}
|
|
22
22
|
MESSAGE
|
|
@@ -26,26 +26,26 @@ MESSAGE
|
|
|
26
26
|
class Autotest
|
|
27
27
|
class << self
|
|
28
28
|
def generate
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
puts "autotest/discover.rb has been added"
|
|
29
|
+
create_dot_rspec_file
|
|
30
|
+
remove_autotest_dir_if_present
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
file << 'Autotest.add_discovery { "rspec2" }'
|
|
33
|
+
def create_dot_rspec_file
|
|
34
|
+
puts "Autotest loads RSpec's Autotest subclass when there is a .rspec file in the project's root directory."
|
|
35
|
+
if File.exist?('./.rspec')
|
|
36
|
+
puts ".rspec file already exists, so nothing was changed."
|
|
37
|
+
else
|
|
38
|
+
FileUtils.touch('./.rspec')
|
|
39
|
+
puts ".rspec file did not exist, so it was created."
|
|
42
40
|
end
|
|
43
41
|
end
|
|
44
42
|
|
|
45
|
-
def
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
def remove_autotest_dir_if_present
|
|
44
|
+
if discover_file_exists?
|
|
45
|
+
print "Delete obsolete autotest/discover.rb [y/n]? "
|
|
46
|
+
exit if gets !~ /y/i
|
|
47
|
+
FileUtils.rm_rf(discover_file_path)
|
|
48
|
+
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def discover_file_exists?
|