rspec-core 2.6.0 → 2.6.2.rc

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/Rakefile CHANGED
@@ -2,6 +2,20 @@ require "bundler"
2
2
  Bundler.setup
3
3
  Bundler::GemHelper.install_tasks
4
4
 
5
+ task :build => :raise_if_psych_is_defined
6
+
7
+ task :raise_if_psych_is_defined do
8
+ if defined?(Psych)
9
+ raise <<-MSG
10
+ ===============================================================================
11
+ Gems compiled in Ruby environments with Psych loaded are incompatible with Ruby
12
+ environments that don't have Psych loaded. Try building this gem in Ruby 1.8.7
13
+ instead.
14
+ ===============================================================================
15
+ MSG
16
+ end
17
+ end
18
+
5
19
  require "rake"
6
20
  require "yaml"
7
21
 
@@ -10,6 +24,7 @@ require "rspec/core/rake_task"
10
24
  require "rspec/core/version"
11
25
 
12
26
  cucumber_loaded = false
27
+
13
28
  begin
14
29
  require "cucumber/rake/task"
15
30
 
@@ -1,3 +1,19 @@
1
+ ### 2.6.2 / 2011-05-20
2
+
3
+ [full changelog](http://github.com/rspec/rspec-core/compare/v2.6.1...v2.6.2)
4
+
5
+ * Bug fixes
6
+ * Warn rather than raise when HOME env var is not defined
7
+ * Properly merge command-line exclusions with default :if and :unless (joshcooper)
8
+
9
+ ### 2.6.1 / 2011-05-19
10
+
11
+ [full changelog](http://github.com/rspec/rspec-core/compare/v2.6.0...v2.6.1)
12
+
13
+ * Bug fixes
14
+ * Don't extend nil when filters are nil
15
+ * `require 'rspec/autorun'` when running rcov.
16
+
1
17
  ### 2.6.0 / 2011-05-12
2
18
 
3
19
  [full changelog](http://github.com/rspec/rspec-core/compare/v2.5.1...v2.6.0)
@@ -26,6 +26,8 @@ require 'rspec/core/example_group'
26
26
  require 'rspec/core/version'
27
27
  require 'rspec/core/errors'
28
28
 
29
+ require 'rspec/autorun' if $0.split(File::SEPARATOR).last == 'rcov'
30
+
29
31
  module RSpec
30
32
  autoload :Matchers, 'rspec/matchers'
31
33
 
@@ -60,6 +62,13 @@ module RSpec
60
62
  @configuration ||= RSpec::Core::Configuration.new
61
63
  end
62
64
 
65
+ # Yields the global configuration object
66
+ #
67
+ # == Examples
68
+ #
69
+ # RSpec.configure do |config|
70
+ # config.format = 'documentation'
71
+ # end
63
72
  def self.configure
64
73
  warn_about_deprecated_configure if RSpec.world.example_groups.any?
65
74
  yield configuration if block_given?
@@ -13,7 +13,7 @@ be removed from a future version of RSpec.
13
13
 
14
14
  * #{name} is deprecated.
15
15
  * RSpec is the new top-level module in RSpec-2
16
- ***************************************************************
16
+ *****************************************************************
17
17
  WARNING
18
18
  RSpec
19
19
  else
@@ -349,10 +349,17 @@ EOM
349
349
  settings[:exclusion_filter] = filter
350
350
  end
351
351
 
352
+ def exclusion_filter
353
+ settings[:exclusion_filter] || {}
354
+ end
355
+
352
356
  def inclusion_filter=(filter)
353
357
  settings[:inclusion_filter] = filter
354
358
  end
355
359
 
360
+ def inclusion_filter
361
+ settings[:inclusion_filter] || {}
362
+ end
356
363
  def filter_run_including(*args)
357
364
  force_overwrite = if args.last.is_a?(Hash) || args.last.is_a?(Symbol)
358
365
  false
@@ -362,7 +369,7 @@ EOM
362
369
 
363
370
  options = build_metadata_hash_from(args)
364
371
 
365
- if inclusion_filter and inclusion_filter[:line_number] || inclusion_filter[:full_description]
372
+ if inclusion_filter[:line_number] || inclusion_filter[:full_description]
366
373
  warn "Filtering by #{options.inspect} is not possible since " \
367
374
  "you are already filtering by #{inclusion_filter.inspect}"
368
375
  else
@@ -2,9 +2,6 @@ module RSpec
2
2
  module Core
3
3
 
4
4
  class ConfigurationOptions
5
- LOCAL_OPTIONS_FILE = ".rspec"
6
- GLOBAL_OPTIONS_FILE = File.join(File.expand_path("~"), ".rspec")
7
-
8
5
  attr_reader :options
9
6
 
10
7
  def initialize(args)
@@ -15,15 +12,16 @@ module RSpec
15
12
  keys = options.keys
16
13
  keys.unshift(:requires) if keys.delete(:requires)
17
14
  keys.unshift(:libs) if keys.delete(:libs)
15
+
18
16
  formatters = options[:formatters] if keys.delete(:formatters)
17
+
18
+ config.exclusion_filter.merge! options[:exclusion_filter] if keys.delete(:exclusion_filter)
19
+
19
20
  keys.each do |key|
20
21
  config.send("#{key}=", options[key]) if config.respond_to?("#{key}=")
21
22
  end
22
- if formatters
23
- formatters.each do |pair|
24
- config.add_formatter(*pair)
25
- end
26
- end
23
+
24
+ formatters.each {|pair| config.add_formatter(*pair) } if formatters
27
25
  end
28
26
 
29
27
  def drb_argv
@@ -79,11 +77,11 @@ module RSpec
79
77
  end
80
78
 
81
79
  def local_options
82
- @local_options ||= options_from(LOCAL_OPTIONS_FILE)
80
+ @local_options ||= options_from(local_options_file)
83
81
  end
84
82
 
85
83
  def global_options
86
- @global_options ||= options_from(GLOBAL_OPTIONS_FILE)
84
+ @global_options ||= options_from(global_options_file)
87
85
  end
88
86
 
89
87
  def options_from(path)
@@ -91,7 +89,7 @@ module RSpec
91
89
  end
92
90
 
93
91
  def args_from_options_file(path)
94
- return [] unless File.exist?(path)
92
+ return [] unless path && File.exist?(path)
95
93
  config_string = options_file_as_erb_string(path)
96
94
  config_string.split(/\n+/).map {|l| l.split}.flatten
97
95
  end
@@ -104,6 +102,20 @@ module RSpec
104
102
  def custom_options_file
105
103
  command_line_options[:custom_options_file]
106
104
  end
105
+
106
+ def local_options_file
107
+ ".rspec"
108
+ end
109
+
110
+ def global_options_file
111
+ begin
112
+ File.join(File.expand_path("~"), ".rspec")
113
+ rescue ArgumentError
114
+ warn "Unable to find ~/.rspec because the HOME environment variable is not set"
115
+ nil
116
+ end
117
+ end
118
+
107
119
  end
108
120
  end
109
121
  end
@@ -11,11 +11,11 @@ module RSpec::Core
11
11
  begin
12
12
  yield self
13
13
  ensure
14
- conclude
14
+ finish
15
15
  end
16
16
  end
17
17
 
18
- def conclude
18
+ def finish
19
19
  begin
20
20
  stop
21
21
  notify :start_dump
@@ -27,7 +27,7 @@ module RSpec::Core
27
27
  end
28
28
  end
29
29
 
30
- alias_method :abort, :conclude
30
+ alias_method :abort, :finish
31
31
 
32
32
  def start(expected_example_count)
33
33
  @start = Time.now
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Core # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.6.0'
4
+ STRING = '2.6.2.rc'
5
5
  end
6
6
  end
7
7
  end
@@ -34,8 +34,8 @@ module RSpec
34
34
  @filtered_examples = Hash.new { |hash,group|
35
35
  hash[group] = begin
36
36
  examples = group.examples.dup
37
- examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter
38
- examples = apply_inclusion_filters(examples, inclusion_filter) if inclusion_filter
37
+ examples = apply_exclusion_filters(examples, exclusion_filter)
38
+ examples = apply_inclusion_filters(examples, inclusion_filter)
39
39
  examples.uniq
40
40
  end
41
41
  }
@@ -106,13 +106,13 @@ module RSpec
106
106
  example_groups.clear
107
107
  if filter_announcements.empty?
108
108
  reporter.message("No examples found.")
109
- elsif inclusion_filter
109
+ elsif !inclusion_filter.empty?
110
110
  message = "No examples matched #{inclusion_filter.description}."
111
111
  if @configuration.run_all_when_everything_filtered?
112
112
  message << " Running all."
113
113
  end
114
114
  reporter.message(message)
115
- elsif exclusion_filter
115
+ elsif !exclusion_filter.empty?
116
116
  reporter.message(
117
117
  "No examples were matched. Perhaps #{exclusion_filter.description} is excluding everything?")
118
118
  end
@@ -122,7 +122,7 @@ module RSpec
122
122
  end
123
123
 
124
124
  def announce_inclusion_filter(announcements)
125
- if inclusion_filter
125
+ unless inclusion_filter.empty?
126
126
  announcements << "including #{inclusion_filter.description}"
127
127
  end
128
128
  end
@@ -139,8 +139,8 @@ module RSpec
139
139
 
140
140
  private
141
141
 
142
- def apply?(predicate, conditions)
143
- lambda {|example| example.metadata.apply?(predicate, conditions)}
142
+ def apply?(predicate, filter)
143
+ lambda {|example| filter.empty? || example.metadata.apply?(predicate, filter)}
144
144
  end
145
145
 
146
146
  def declaration_line_numbers
@@ -14,6 +14,17 @@ describe RSpec::Core::ConfigurationOptions do
14
14
  config_options_object(*args).options
15
15
  end
16
16
 
17
+ it "warns when HOME env var is not set" do
18
+ begin
19
+ orig_home = ENV.delete("HOME")
20
+ coo = RSpec::Core::ConfigurationOptions.new([])
21
+ coo.should_receive(:warn)
22
+ coo.parse_options
23
+ ensure
24
+ ENV["HOME"] = orig_home
25
+ end
26
+ end
27
+
17
28
  describe "#configure" do
18
29
  it "sends libs before requires" do
19
30
  opts = config_options_object(*%w[--require a/path -I a/lib])
@@ -30,6 +41,13 @@ describe RSpec::Core::ConfigurationOptions do
30
41
  config.should_receive(:add_formatter).ordered
31
42
  opts.configure(config)
32
43
  end
44
+
45
+ it "merges the :exclusion_filter option with the default exclusion_filter" do
46
+ opts = config_options_object(*%w[--tag ~slow])
47
+ config = RSpec::Core::Configuration.new
48
+ opts.configure(config)
49
+ config.exclusion_filter.should have_key(:slow)
50
+ end
33
51
  end
34
52
 
35
53
  describe "-c, --color, and --colour" do
@@ -279,23 +297,16 @@ describe RSpec::Core::ConfigurationOptions do
279
297
 
280
298
  before do
281
299
  @orig_spec_opts = ENV["SPEC_OPTS"]
282
- @orig_global_options_file = RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE
283
- @orig_local_options_file = RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE
284
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :GLOBAL_OPTIONS_FILE
285
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :LOCAL_OPTIONS_FILE
286
- RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE = global_options_file
287
- RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE = local_options_file
288
- FileUtils.rm local_options_file if File.exist? local_options_file
289
- FileUtils.rm global_options_file if File.exist? global_options_file
290
- FileUtils.rm custom_options_file if File.exist? custom_options_file
300
+ RSpec::Core::ConfigurationOptions::send :public, :global_options_file
301
+ RSpec::Core::ConfigurationOptions::send :public, :local_options_file
302
+ RSpec::Core::ConfigurationOptions::any_instance.stub(:global_options_file) { global_options_file }
303
+ RSpec::Core::ConfigurationOptions::any_instance.stub(:local_options_file) { local_options_file }
291
304
  end
292
305
 
293
306
  after do
294
307
  ENV["SPEC_OPTS"] = @orig_spec_opts
295
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :GLOBAL_OPTIONS_FILE
296
- RSpec::Core::ConfigurationOptions::__send__ :remove_const, :LOCAL_OPTIONS_FILE
297
- RSpec::Core::ConfigurationOptions::GLOBAL_OPTIONS_FILE = @orig_global_options_file
298
- RSpec::Core::ConfigurationOptions::LOCAL_OPTIONS_FILE = @orig_local_options_file
308
+ RSpec::Core::ConfigurationOptions::send :private, :global_options_file
309
+ RSpec::Core::ConfigurationOptions::send :private, :local_options_file
299
310
  end
300
311
 
301
312
  def write_options(scope, options)
@@ -527,7 +527,20 @@ module RSpec::Core
527
527
  end
528
528
  end
529
529
 
530
+ describe "#inclusion_filter" do
531
+ it "returns {} even if set to nil" do
532
+ config.inclusion_filter = nil
533
+ config.inclusion_filter.should eq({})
534
+ end
535
+ end
536
+
537
+
530
538
  describe "#exclusion_filter" do
539
+ it "returns {} even if set to nil" do
540
+ config.exclusion_filter = nil
541
+ config.exclusion_filter.should eq({})
542
+ end
543
+
531
544
  describe "the default :if filter" do
532
545
  it "does not exclude a spec with no :if metadata" do
533
546
  config.exclusion_filter[:if].call(nil, {}).should be_false
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
4
+ hash: 7712002
5
+ prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 6
9
- - 0
10
- version: 2.6.0
9
+ - 2
10
+ - rc
11
+ version: 2.6.2.rc
11
12
  platform: ruby
12
13
  authors:
13
14
  - Chad Humphries
@@ -16,7 +17,7 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2011-05-12 00:00:00 -05:00
20
+ date: 2011-05-20 00:00:00 -04:00
20
21
  default_executable:
21
22
  dependencies: []
22
23
 
@@ -229,19 +230,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
230
  required_rubygems_version: !ruby/object:Gem::Requirement
230
231
  none: false
231
232
  requirements:
232
- - - ">="
233
+ - - ">"
233
234
  - !ruby/object:Gem::Version
234
- hash: 3
235
+ hash: 25
235
236
  segments:
236
- - 0
237
- version: "0"
237
+ - 1
238
+ - 3
239
+ - 1
240
+ version: 1.3.1
238
241
  requirements: []
239
242
 
240
243
  rubyforge_project: rspec
241
244
  rubygems_version: 1.6.2
242
245
  signing_key:
243
246
  specification_version: 3
244
- summary: rspec-core-2.6.0
247
+ summary: rspec-core-2.6.2.rc
245
248
  test_files:
246
249
  - features/Autotest.md
247
250
  - features/Changelog.md