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.
Files changed (171) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +0 -1
  3. data/.travis.yml +7 -0
  4. data/Gemfile +46 -20
  5. data/Guardfile +5 -0
  6. data/License.txt +2 -1
  7. data/{README.markdown → README.md} +23 -5
  8. data/Rakefile +58 -31
  9. data/bin/autospec +13 -0
  10. data/bin/rspec +24 -2
  11. data/cucumber.yml +1 -1
  12. data/features/.nav +57 -0
  13. data/features/Autotest.md +38 -0
  14. data/features/Changelog.md +269 -0
  15. data/features/README.md +17 -0
  16. data/features/Upgrade.md +320 -0
  17. data/features/command_line/README.md +28 -0
  18. data/features/command_line/configure.feature +18 -15
  19. data/features/command_line/example_name_option.feature +37 -23
  20. data/features/command_line/exit_status.feature +16 -31
  21. data/features/command_line/format_option.feature +73 -0
  22. data/features/command_line/line_number_appended_to_path.feature +25 -27
  23. data/features/command_line/line_number_option.feature +11 -10
  24. data/features/command_line/rake_task.feature +68 -0
  25. data/features/command_line/tag.feature +90 -0
  26. data/features/configuration/alias_example_to.feature +48 -0
  27. data/features/configuration/custom_settings.feature +8 -10
  28. data/features/configuration/fail_fast.feature +77 -0
  29. data/features/configuration/read_options_from_file.feature +42 -26
  30. data/features/example_groups/basic_structure.feature +55 -0
  31. data/features/example_groups/shared_context.feature +74 -0
  32. data/features/example_groups/shared_example_group.feature +56 -41
  33. data/features/expectation_framework_integration/configure_expectation_framework.feature +73 -0
  34. data/features/filtering/exclusion_filters.feature +69 -9
  35. data/features/filtering/if_and_unless.feature +168 -0
  36. data/features/filtering/inclusion_filters.feature +58 -26
  37. data/features/filtering/run_all_when_everything_filtered.feature +46 -0
  38. data/features/formatters/custom_formatter.feature +17 -13
  39. data/features/formatters/text_formatter.feature +43 -0
  40. data/features/helper_methods/arbitrary_methods.feature +40 -0
  41. data/features/helper_methods/let.feature +50 -0
  42. data/features/helper_methods/modules.feature +149 -0
  43. data/features/hooks/around_hooks.feature +99 -69
  44. data/features/hooks/before_and_after_hooks.feature +74 -40
  45. data/features/hooks/filtering.feature +227 -0
  46. data/features/metadata/current_example.feature +17 -0
  47. data/features/metadata/described_class.feature +17 -0
  48. data/features/metadata/user_defined.feature +111 -0
  49. data/features/mock_framework_integration/use_any_framework.feature +106 -0
  50. data/features/mock_framework_integration/use_flexmock.feature +84 -11
  51. data/features/mock_framework_integration/use_mocha.feature +85 -11
  52. data/features/mock_framework_integration/use_rr.feature +86 -11
  53. data/features/mock_framework_integration/use_rspec.feature +85 -11
  54. data/features/pending/pending_examples.feature +143 -5
  55. data/features/spec_files/arbitrary_file_suffix.feature +2 -2
  56. data/features/step_definitions/additional_cli_steps.rb +30 -0
  57. data/features/subject/attribute_of_subject.feature +93 -15
  58. data/features/subject/explicit_subject.feature +28 -17
  59. data/features/subject/implicit_receiver.feature +29 -0
  60. data/features/subject/implicit_subject.feature +9 -10
  61. data/features/support/env.rb +6 -1
  62. data/lib/autotest/discover.rb +1 -0
  63. data/lib/autotest/rspec2.rb +15 -11
  64. data/lib/rspec/autorun.rb +2 -0
  65. data/lib/rspec/core/backward_compatibility.rb +33 -4
  66. data/lib/rspec/core/command_line.rb +4 -28
  67. data/lib/rspec/core/command_line_configuration.rb +16 -16
  68. data/lib/rspec/core/configuration.rb +279 -89
  69. data/lib/rspec/core/configuration_options.rb +46 -35
  70. data/lib/rspec/core/deprecation.rb +1 -1
  71. data/lib/rspec/core/drb_command_line.rb +5 -11
  72. data/lib/rspec/core/example.rb +63 -39
  73. data/lib/rspec/core/example_group.rb +109 -59
  74. data/lib/rspec/core/expecting/with_rspec.rb +11 -0
  75. data/lib/rspec/core/expecting/with_stdlib.rb +9 -0
  76. data/lib/rspec/core/extensions/kernel.rb +1 -1
  77. data/lib/rspec/core/extensions/object.rb +1 -3
  78. data/lib/rspec/core/formatters/base_formatter.rb +22 -11
  79. data/lib/rspec/core/formatters/base_text_formatter.rb +46 -30
  80. data/lib/rspec/core/formatters/documentation_formatter.rb +4 -2
  81. data/lib/rspec/core/formatters/helpers.rb +0 -4
  82. data/lib/rspec/core/formatters/html_formatter.rb +146 -41
  83. data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
  84. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
  85. data/lib/rspec/core/formatters/text_mate_formatter.rb +3 -1
  86. data/lib/rspec/core/hooks.rb +55 -17
  87. data/lib/rspec/core/metadata.rb +75 -64
  88. data/lib/rspec/core/metadata_hash_builder.rb +93 -0
  89. data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
  90. data/lib/rspec/core/mocking/with_mocha.rb +2 -0
  91. data/lib/rspec/core/mocking/with_rr.rb +2 -0
  92. data/lib/rspec/core/mocking/with_rspec.rb +3 -1
  93. data/lib/rspec/core/option_parser.rb +48 -5
  94. data/lib/rspec/core/pending.rb +22 -4
  95. data/lib/rspec/core/rake_task.rb +64 -28
  96. data/lib/rspec/core/reporter.rb +3 -2
  97. data/lib/rspec/core/ruby_project.rb +2 -2
  98. data/lib/rspec/core/runner.rb +50 -6
  99. data/lib/rspec/core/shared_context.rb +16 -0
  100. data/lib/rspec/core/shared_example_group.rb +19 -4
  101. data/lib/rspec/core/subject.rb +92 -65
  102. data/lib/rspec/core/version.rb +1 -1
  103. data/lib/rspec/core/world.rb +83 -25
  104. data/lib/rspec/core.rb +40 -24
  105. data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
  106. data/rspec-core.gemspec +4 -25
  107. data/script/FullBuildRakeFile +63 -0
  108. data/script/cucumber +1 -0
  109. data/script/full_build +1 -0
  110. data/script/spec +1 -0
  111. data/spec/autotest/discover_spec.rb +19 -0
  112. data/spec/autotest/failed_results_re_spec.rb +25 -9
  113. data/spec/autotest/rspec_spec.rb +32 -41
  114. data/spec/rspec/core/command_line_spec.rb +62 -7
  115. data/spec/rspec/core/configuration_options_spec.rb +184 -148
  116. data/spec/rspec/core/configuration_spec.rb +406 -108
  117. data/spec/rspec/core/deprecations_spec.rb +38 -1
  118. data/spec/rspec/core/drb_command_line_spec.rb +21 -56
  119. data/spec/rspec/core/example_group_spec.rb +366 -127
  120. data/spec/rspec/core/example_spec.rb +125 -45
  121. data/spec/rspec/core/formatters/base_formatter_spec.rb +61 -1
  122. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +39 -5
  123. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +7 -6
  124. data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
  125. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +199 -81
  126. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +199 -83
  127. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +199 -81
  128. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +206 -81
  129. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +206 -61
  130. data/spec/rspec/core/formatters/html_formatter_spec.rb +17 -9
  131. data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -1
  132. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +199 -81
  133. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +199 -81
  134. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +199 -81
  135. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +206 -81
  136. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +206 -81
  137. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +22 -7
  138. data/spec/rspec/core/hooks_filtering_spec.rb +128 -5
  139. data/spec/rspec/core/hooks_spec.rb +90 -4
  140. data/spec/rspec/core/metadata_spec.rb +176 -163
  141. data/spec/rspec/core/option_parser_spec.rb +73 -6
  142. data/spec/rspec/core/pending_example_spec.rb +137 -35
  143. data/spec/rspec/core/rake_task_spec.rb +62 -29
  144. data/spec/rspec/core/reporter_spec.rb +20 -4
  145. data/spec/rspec/core/resources/formatter_specs.rb +25 -1
  146. data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
  147. data/spec/rspec/core/runner_spec.rb +60 -10
  148. data/spec/rspec/core/shared_context_spec.rb +30 -0
  149. data/spec/rspec/core/shared_example_group_spec.rb +59 -23
  150. data/spec/rspec/core/subject_spec.rb +136 -0
  151. data/spec/rspec/core/world_spec.rb +211 -68
  152. data/spec/rspec/core_spec.rb +28 -0
  153. data/spec/spec_helper.rb +41 -23
  154. data/spec/support/matchers.rb +44 -13
  155. data/spec/support/shared_example_groups.rb +41 -0
  156. data/spec/support/spec_files.rb +44 -0
  157. data/spec.txt +1126 -0
  158. metadata +99 -168
  159. data/.treasure_map.rb +0 -23
  160. data/History.md +0 -30
  161. data/Upgrade.markdown +0 -150
  162. data/autotest/discover.rb +0 -2
  163. data/features/README.markdown +0 -12
  164. data/features/example_groups/describe_aliases.feature +0 -25
  165. data/features/example_groups/nested_groups.feature +0 -44
  166. data/features/hooks/described_class.feature +0 -14
  167. data/features/hooks/halt.feature +0 -26
  168. data/lib/rspec/core/around_proxy.rb +0 -14
  169. data/lib/rspec/core/formatters.rb +0 -8
  170. data/spec/ruby_forker.rb +0 -13
  171. data/specs.watchr +0 -59
@@ -1,20 +1,19 @@
1
1
  Feature: implicit subject
2
2
 
3
- The first argument to the outermost example group block is
4
- made available to each example as an implicit subject of
5
- that example.
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 "rspec ./top_level_subject_spec.rb"
17
- Then the output should contain "1 example, 0 failures"
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 "rspec ./nested_subject_spec.rb"
31
- Then the output should contain "1 example, 0 failures"
29
+ When I run `rspec nested_subject_spec.rb`
30
+ Then the examples should all pass
@@ -1 +1,6 @@
1
- require 'aruba'
1
+ require 'aruba/cucumber'
2
+
3
+ Before do
4
+ @aruba_timeout_seconds = 3
5
+ end
6
+
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" } if File.exist?("./.rspec")
@@ -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(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'rspec'))
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
- self.failed_results_re = /^\s*\d\)\s(.*?$\n.*?$).*?#\s(.*?):/m
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} #{require_rubygems}#{SPEC_PROGRAM} #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}"
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 ruby
56
- using_bundler? ? "bundle exec" : super
55
+ def suffix
56
+ using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
57
57
  end
58
58
 
59
59
  def using_bundler?
60
- File.exists?('./Gemfile')
60
+ prefix =~ /bundle exec/
61
+ end
62
+
63
+ def gemfile?
64
+ File.exist?('./Gemfile')
61
65
  end
62
66
 
63
67
  end
@@ -0,0 +1,2 @@
1
+ require 'rspec/core'
2
+ RSpec::Core::Runner.autorun
@@ -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
- super(name)
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
- @configuration.configure_mock_framework
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.run_examples(reporter)
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 configuration to run autotest with rspec
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
- create_autotest_directory
30
- create_discover_file
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 create_autotest_directory
35
- Dir.mkdir('autotest') unless File.exist?('autotest')
36
- end
37
-
38
- def create_discover_file
39
- optionally_remove_discover_file if discover_file_exists?
40
- File.open(discover_file_path, 'w') do |file|
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 optionally_remove_discover_file
46
- print "Discover file already exists, overwrite [y/N]? "
47
- exit if gets !~ /y/i
48
- FileUtils.rm_rf(discover_file_path)
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?