rspec-core 2.5.0 → 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/.travis.yml +7 -0
- data/Gemfile +12 -14
- data/README.md +4 -1
- data/Rakefile +29 -12
- data/cucumber.yml +1 -1
- data/features/.nav +15 -9
- data/features/Autotest.md +26 -32
- data/features/Changelog.md +62 -2
- data/features/Upgrade.md +35 -2
- data/features/command_line/README.md +22 -0
- data/features/command_line/configure.feature +2 -2
- data/features/command_line/example_name_option.feature +10 -10
- data/features/command_line/exit_status.feature +4 -4
- data/features/command_line/format_option.feature +4 -4
- data/features/command_line/line_number_appended_to_path.feature +11 -11
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/rake_task.feature +3 -3
- data/features/command_line/tag.feature +30 -14
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/fail_fast.feature +3 -3
- data/features/configuration/read_options_from_file.feature +4 -4
- data/features/example_groups/basic_structure.feature +11 -15
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +21 -17
- data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
- data/features/filtering/exclusion_filters.feature +28 -4
- data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
- data/features/filtering/inclusion_filters.feature +26 -3
- data/features/filtering/run_all_when_everything_filtered.feature +2 -2
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +2 -2
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +18 -11
- data/features/hooks/before_and_after_hooks.feature +15 -19
- data/features/hooks/filtering.feature +160 -124
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +2 -2
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +83 -10
- data/features/mock_framework_integration/use_mocha.feature +84 -10
- data/features/mock_framework_integration/use_rr.feature +85 -10
- data/features/mock_framework_integration/use_rspec.feature +84 -10
- data/features/pending/pending_examples.feature +8 -8
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +11 -1
- data/features/subject/attribute_of_subject.feature +24 -4
- data/features/subject/explicit_subject.feature +5 -5
- data/features/subject/implicit_receiver.feature +2 -2
- data/features/subject/implicit_subject.feature +2 -2
- data/features/support/env.rb +6 -1
- data/lib/autotest/rspec2.rb +2 -51
- data/lib/rspec/core/backward_compatibility.rb +12 -2
- data/lib/rspec/core/command_line.rb +2 -5
- data/lib/rspec/core/configuration.rb +70 -38
- data/lib/rspec/core/configuration_options.rb +6 -23
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/example.rb +29 -21
- data/lib/rspec/core/example_group.rb +40 -8
- data/lib/rspec/core/extensions/object.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +6 -0
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/hooks.rb +14 -4
- data/lib/rspec/core/metadata.rb +1 -1
- 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 +9 -2
- data/lib/rspec/core/pending.rb +10 -3
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/runner.rb +38 -13
- data/lib/rspec/core/shared_example_group.rb +18 -4
- data/lib/rspec/core/subject.rb +4 -6
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +70 -18
- data/lib/rspec/core.rb +29 -0
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +3 -5
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/autotest/rspec_spec.rb +4 -126
- data/spec/rspec/core/command_line_spec.rb +36 -2
- data/spec/rspec/core/configuration_spec.rb +150 -70
- data/spec/rspec/core/deprecations_spec.rb +21 -0
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +213 -56
- data/spec/rspec/core/example_spec.rb +110 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/hooks_spec.rb +86 -0
- data/spec/rspec/core/metadata_spec.rb +7 -7
- data/spec/rspec/core/option_parser_spec.rb +26 -15
- data/spec/rspec/core/pending_example_spec.rb +12 -51
- data/spec/rspec/core/reporter_spec.rb +19 -3
- data/spec/rspec/core/resources/formatter_specs.rb +7 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +42 -10
- data/spec/rspec/core/shared_example_group_spec.rb +57 -21
- data/spec/rspec/core/subject_spec.rb +32 -11
- data/spec/rspec/core/world_spec.rb +147 -15
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +22 -2
- 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 +34 -15
- data/spec/ruby_forker.rb +0 -13
data/spec/spec_helper.rb
CHANGED
|
@@ -15,7 +15,6 @@ def sandboxed(&block)
|
|
|
15
15
|
@orig_config = RSpec.configuration
|
|
16
16
|
@orig_world = RSpec.world
|
|
17
17
|
new_config = RSpec::Core::Configuration.new
|
|
18
|
-
new_config.include(RSpec::Matchers)
|
|
19
18
|
new_world = RSpec::Core::World.new(new_config)
|
|
20
19
|
RSpec.instance_variable_set(:@configuration, new_config)
|
|
21
20
|
RSpec.instance_variable_set(:@world, new_world)
|
|
@@ -51,6 +50,27 @@ def in_editor?
|
|
|
51
50
|
ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
|
|
52
51
|
end
|
|
53
52
|
|
|
53
|
+
class << RSpec
|
|
54
|
+
alias_method :original_warn_about_deprecated_configure, :warn_about_deprecated_configure
|
|
55
|
+
|
|
56
|
+
def warn_about_deprecated_configure
|
|
57
|
+
# no-op: in our specs we don't want to see the warning.
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
alias_method :null_warn_about_deprecated_configure, :warn_about_deprecated_configure
|
|
61
|
+
|
|
62
|
+
def allowing_configure_warning
|
|
63
|
+
(class << self; self; end).class_eval do
|
|
64
|
+
alias_method :warn_about_deprecated_configure, :original_warn_about_deprecated_configure
|
|
65
|
+
begin
|
|
66
|
+
yield
|
|
67
|
+
ensure
|
|
68
|
+
alias_method :warn_about_deprecated_configure, :null_warn_about_deprecated_configure
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
54
74
|
RSpec.configure do |c|
|
|
55
75
|
c.color_enabled = !in_editor?
|
|
56
76
|
c.filter_run :focus => true
|
|
@@ -58,7 +78,7 @@ RSpec.configure do |c|
|
|
|
58
78
|
c.filter_run_excluding :ruby => lambda {|version|
|
|
59
79
|
case version.to_s
|
|
60
80
|
when "!jruby"
|
|
61
|
-
RUBY_ENGINE
|
|
81
|
+
RUBY_ENGINE == "jruby"
|
|
62
82
|
when /^> (.*)/
|
|
63
83
|
!(RUBY_VERSION.to_s > $1)
|
|
64
84
|
else
|
data/spec/support/matchers.rb
CHANGED
|
@@ -20,25 +20,56 @@ RSpec::Matchers.define :map_specs do |specs|
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
RSpec::Matchers.define :
|
|
24
|
-
match do |
|
|
25
|
-
|
|
26
|
-
@object = object
|
|
27
|
-
object.respond_to?(method) && actual_arity == @expected_arity
|
|
23
|
+
RSpec::Matchers.define :be_pending_with do |message|
|
|
24
|
+
match do |example|
|
|
25
|
+
example.metadata[:pending] && example.metadata[:execution_result][:pending_message] == message
|
|
28
26
|
end
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
failure_message_for_should do |example|
|
|
29
|
+
"expected example to pending with #{message.inspect}, got #{example.metadata[:execution_result][:pending_message].inspect}"
|
|
32
30
|
end
|
|
31
|
+
end
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
RSpec::Matchers.define :fail_with do |exception_klass|
|
|
34
|
+
match do |example|
|
|
35
|
+
failure_reason(example, exception_klass).nil?
|
|
36
|
+
end
|
|
36
37
|
|
|
37
|
-
failure_message_for_should do
|
|
38
|
-
"
|
|
38
|
+
failure_message_for_should do |example|
|
|
39
|
+
"expected example to fail with a #{exception_klass} exception, but #{failure_reason(example, exception_klass)}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def failure_reason(example, exception_klass)
|
|
43
|
+
result = example.metadata[:execution_result]
|
|
44
|
+
case
|
|
45
|
+
when example.metadata[:pending] then "was pending"
|
|
46
|
+
when result[:status] != 'failed' then result[:status]
|
|
47
|
+
when !result[:exception].is_a?(exception_klass) then "failed with a #{result[:exception].class}"
|
|
48
|
+
else nil
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
RSpec::Matchers.define :pass do
|
|
54
|
+
match do |example|
|
|
55
|
+
failure_reason(example).nil?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
failure_message_for_should do |example|
|
|
59
|
+
"expected example to pass, but #{failure_reason(example)}"
|
|
39
60
|
end
|
|
40
61
|
|
|
41
|
-
def
|
|
42
|
-
|
|
62
|
+
def failure_reason(example)
|
|
63
|
+
result = example.metadata[:execution_result]
|
|
64
|
+
case
|
|
65
|
+
when example.metadata[:pending] then "was pending"
|
|
66
|
+
when result[:status] != 'passed' then result[:status]
|
|
67
|
+
else nil
|
|
68
|
+
end
|
|
43
69
|
end
|
|
44
70
|
end
|
|
71
|
+
|
|
72
|
+
RSpec::Matchers.module_eval do
|
|
73
|
+
alias have_failed_with fail_with
|
|
74
|
+
alias have_passed pass
|
|
75
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
shared_examples_for "metadata hash builder" do
|
|
2
|
+
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to true" do
|
|
3
|
+
let(:hash) { metadata_hash(:foo, :bar, :bazz => 23) }
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'treats symbols as metadata keys with a true value' do
|
|
10
|
+
hash[:foo].should == true
|
|
11
|
+
hash[:bar].should == true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'still processes hash values normally' do
|
|
15
|
+
hash[:bazz].should == 23
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to false" do
|
|
20
|
+
let(:warning_receiver) { Kernel }
|
|
21
|
+
|
|
22
|
+
before(:each) do
|
|
23
|
+
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = false }
|
|
24
|
+
warning_receiver.stub(:warn)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'prints a deprecation warning about any symbols given as arguments' do
|
|
28
|
+
warning_receiver.should_receive(:warn).with(/In RSpec 3, these symbols will be treated as metadata keys/)
|
|
29
|
+
metadata_hash(:foo, :bar, :key => 'value')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'does not treat symbols as metadata keys' do
|
|
33
|
+
metadata_hash(:foo, :bar, :key => 'value').should_not include(:foo, :bar)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'does not print a warning if there are no symbol arguments' do
|
|
37
|
+
warning_receiver.should_not_receive(:warn)
|
|
38
|
+
metadata_hash(:foo => 23, :bar => 17)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
shared_context "spec files" do
|
|
2
|
+
def failing_spec_filename
|
|
3
|
+
@failing_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_failing_spec.rb"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def passing_spec_filename
|
|
7
|
+
@passing_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_passing_spec.rb"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create_passing_spec_file
|
|
11
|
+
File.open(passing_spec_filename, 'w') do |f|
|
|
12
|
+
f.write %q{
|
|
13
|
+
describe "passing spec" do
|
|
14
|
+
it "passes" do
|
|
15
|
+
1.should eq(1)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_failing_spec_file
|
|
23
|
+
File.open(failing_spec_filename, 'w') do |f|
|
|
24
|
+
f.write %q{
|
|
25
|
+
describe "failing spec" do
|
|
26
|
+
it "fails" do
|
|
27
|
+
1.should eq(2)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
before(:all) do
|
|
35
|
+
create_passing_spec_file
|
|
36
|
+
create_failing_spec_file
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
after(:all) do
|
|
40
|
+
File.delete(passing_spec_filename)
|
|
41
|
+
File.delete(failing_spec_filename)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|