rspec-core 2.0.0.a6 → 2.0.0.a7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,9 +1,8 @@
1
- require 'rubygems'
2
1
  gem "jeweler", ">= 1.4.0"
3
2
  require 'rake'
4
3
  require 'yaml'
5
4
 
6
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__),'lib'))
5
+ $:.unshift File.expand_path('../lib', __FILE__)
7
6
 
8
7
  require 'rake/rdoctask'
9
8
  require 'rspec/core/rake_task'
@@ -15,7 +14,7 @@ begin
15
14
  Jeweler::Tasks.new do |gem|
16
15
  gem.name = "rspec-core"
17
16
  gem.version = Rspec::Core::Version::STRING
18
- gem.summary = Rspec::Core::Version::SUMMARY
17
+ gem.summary = "rspec-core-#{Rspec::Core::Version::STRING}"
19
18
  gem.description = 'Rspec runner and example group classes'
20
19
  gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
21
20
  gem.homepage = "http://github.com/rspec/core"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.0.a7
@@ -7,7 +7,9 @@ Feature: custom formatters
7
7
  Scenario: specdoc format
8
8
  Given a file named "custom_formatter.rb" with:
9
9
  """
10
- require 'spec/runner/formatter/base_formatter'
10
+ require "rspec/expectations"
11
+ require "spec/runner/formatter/base_formatter"
12
+
11
13
  class CustomFormatter < Spec::Runner::Formatter::BaseFormatter
12
14
  def initialize(options, output)
13
15
  @output = output
@@ -18,13 +20,13 @@ Feature: custom formatters
18
20
  end
19
21
  """
20
22
  And a file named "simple_example_spec.rb" with:
21
- """
23
+ """
22
24
  describe "my group" do
23
25
  specify "my example" do
24
26
  end
25
27
  end
26
- """
28
+ """
27
29
 
28
- When I run "spec simple_example_spec.rb --require custom_formatter.rb --format CustomFormatter"
30
+ When I run "rspec simple_example_spec.rb --require custom_formatter.rb --format CustomFormatter"
29
31
  Then the exit code should be 0
30
32
  And the stdout should match "example: my example"
@@ -6,6 +6,8 @@ Feature: line number option
6
6
  Scenario: standard examples
7
7
  Given a file named "example_spec.rb" with:
8
8
  """
9
+ require "rspec/expectations"
10
+
9
11
  describe 9 do
10
12
 
11
13
  it "should be > 8" do
@@ -18,7 +20,7 @@ Feature: line number option
18
20
 
19
21
  end
20
22
  """
21
- When I run "spec example_spec.rb --line 3 --format doc"
23
+ When I run "spec example_spec.rb --line 5 --format doc"
22
24
  Then the stdout should match "1 example, 0 failures"
23
25
  Then the stdout should match "should be > 8"
24
26
  But the stdout should not match "should be < 10"
@@ -26,6 +28,8 @@ Feature: line number option
26
28
  Scenario: one liner
27
29
  Given a file named "example_spec.rb" with:
28
30
  """
31
+ require "rspec/expectations"
32
+
29
33
  describe 9 do
30
34
 
31
35
  it { should be > 8 }
@@ -34,7 +38,7 @@ Feature: line number option
34
38
 
35
39
  end
36
40
  """
37
- When I run "spec example_spec.rb --line 3 --format doc"
41
+ When I run "spec example_spec.rb --line 5 --format doc"
38
42
  Then the stdout should match "1 example, 0 failures"
39
43
  Then the stdout should match "should be > 8"
40
44
  But the stdout should not match "should be < 10"
@@ -13,9 +13,8 @@ Feature: spec/spec.opts
13
13
  Scenario: color set in Rspec.configure
14
14
  Given a file named "spec/spec_helper.rb" with:
15
15
  """
16
- Rspec.configure do |c|
17
- c.color_enabled = true
18
- end
16
+ require "rspec/expectations"
17
+ Rspec.configure {|c| c.color_enabled = true }
19
18
  """
20
19
  And a file named "spec/example_spec.rb" with:
21
20
  """
@@ -38,6 +37,8 @@ Feature: spec/spec.opts
38
37
  """
39
38
  And a file named "spec/example_spec.rb" with:
40
39
  """
40
+ require "rspec/expectations"
41
+
41
42
  describe "color_enabled" do
42
43
  context "when set with Rspec.configure" do
43
44
  it "is true" do
@@ -49,20 +50,21 @@ Feature: spec/spec.opts
49
50
  When I run "rspec spec/example_spec.rb"
50
51
  Then the stdout should match "1 example, 0 failures"
51
52
 
53
+ @wip
52
54
  Scenario: formatter set in both (spec.opts wins)
53
55
  Given a file named "spec/spec.opts" with:
54
56
  """
55
57
  --formatter documentation
56
58
  """
57
-
58
59
  And a file named "spec/spec_helper.rb" with:
59
60
  """
60
- Rspec.configure do |c|
61
- c.formatter = 'pretty'
62
- end
61
+ require "rspec/expectations"
62
+ Rspec.configure {|c| c.formatter = 'progress'}
63
63
  """
64
64
  And a file named "spec/example_spec.rb" with:
65
65
  """
66
+ require "spec_helper"
67
+
66
68
  describe "formatter" do
67
69
  context "when set with Rspec.configure and in spec.opts" do
68
70
  it "takes the value set in spec.opts" do
@@ -7,7 +7,9 @@ Feature: Nested example groups
7
7
  Scenario: Using context
8
8
  Given a file named "context_instead_of_describe_spec.rb" with:
9
9
  """
10
- context "Using context" do
10
+ require "rspec/expectations"
11
+
12
+ describe "Using context" do
11
13
  context "with nested context" do
12
14
  it "should do this" do
13
15
  true.should be_true
@@ -31,6 +31,8 @@ Feature: before and after hooks
31
31
  Scenario: define before(:each) block in example group
32
32
  Given a file named "before_each_in_example_group_spec.rb" with:
33
33
  """
34
+ require "rspec/expectations"
35
+
34
36
  class Thing
35
37
  def widgets
36
38
  @widgets ||= []
@@ -63,6 +65,8 @@ Feature: before and after hooks
63
65
  Scenario: define before(:all) block in example group
64
66
  Given a file named "before_all_in_example_group_spec.rb" with:
65
67
  """
68
+ require "rspec/expectations"
69
+
66
70
  class Thing
67
71
  def widgets
68
72
  @widgets ||= []
@@ -96,6 +100,8 @@ Feature: before and after hooks
96
100
  Scenario: define before and after blocks in configuration
97
101
  Given a file named "befores_in_configuration_spec.rb" with:
98
102
  """
103
+ require "rspec/expectations"
104
+
99
105
  Rspec.configure do |config|
100
106
  config.before(:suite) do
101
107
  $before_suite = "before suite"
@@ -133,6 +139,8 @@ Feature: before and after hooks
133
139
  Scenario: before/after blocks are run in order
134
140
  Given a file named "ensure_block_order_spec.rb" with:
135
141
  """
142
+ require "rspec/expectations"
143
+
136
144
  Rspec.configure do |config|
137
145
  config.before(:suite) do
138
146
  puts "before suite"
@@ -62,9 +62,6 @@ class RspecWorld
62
62
  $LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
63
63
  $LOAD_PATH.unshift(File.expand_path('../../../../rspec-expectations/lib', __FILE__))
64
64
  $LOAD_PATH.unshift(File.expand_path('../../../../rspec-mocks/lib', __FILE__))
65
- require 'rspec/core'
66
- require 'rspec/expectations'
67
- Rspec::Core::ExampleGroup.__send__(:include, Rspec::Matchers)
68
65
  CONTENT
69
66
  end
70
67
  cmd = "-rrubygems -rload_paths.rb #{rspec_libs} #{args}"
@@ -51,6 +51,10 @@ module Rspec
51
51
  options[:full_backtrace] = true
52
52
  end
53
53
 
54
+ opts.on('-d', '--debug', 'Enable debugging') do |o|
55
+ options[:debug] = true
56
+ end
57
+
54
58
  opts.on_tail('-h', '--help', "You're looking at it.") do
55
59
  puts opts
56
60
  exit
@@ -99,6 +99,24 @@ module Rspec
99
99
  @options[:backtrace_clean_patterns].clear
100
100
  end
101
101
 
102
+ def debug=(bool)
103
+ return unless bool
104
+ begin
105
+ require 'ruby-debug'
106
+ rescue LoadError
107
+ raise <<-EOM
108
+
109
+ #{'*'*50}
110
+ You must install ruby-debug to run rspec with the --debug option.
111
+
112
+ If you have ruby-debug installed as a ruby gem, then you need to either
113
+ require 'rubygems' or configure the RUBYOPT environment variable with
114
+ the value 'rubygems'.
115
+ #{'*'*50}
116
+ EOM
117
+ end
118
+ end
119
+
102
120
  def color_enabled?
103
121
  options[:color_enabled]
104
122
  end
@@ -148,7 +166,7 @@ module Rspec
148
166
  options[:files_to_run] = files.flatten.inject([]) do |result, file|
149
167
  if File.directory?(file)
150
168
  filename_pattern.split(",").each do |pattern|
151
- result += Dir[File.expand_path("#{file}/#{pattern.strip}")]
169
+ result += Dir["#{file}/#{pattern.strip}"]
152
170
  end
153
171
  else
154
172
  path, line_number = file.split(':')
@@ -11,7 +11,7 @@ module Rspec
11
11
  attr_accessor :running_example
12
12
 
13
13
  def self.inherited(klass)
14
- super
14
+ super(klass)
15
15
  Rspec::Core.configuration.autorun!
16
16
  Rspec::Core.world.example_groups << klass
17
17
  end
@@ -62,10 +62,15 @@ module Rspec
62
62
  self.superclass.respond_to?(:metadata) ? self.superclass.metadata : nil
63
63
  end
64
64
 
65
+ def self.configuration
66
+ @configuration
67
+ end
68
+
65
69
  def self.set_it_up(*args)
70
+ @configuration = args.shift
66
71
  @metadata = Rspec::Core::Metadata.process(superclass_metadata, *args)
67
72
 
68
- Rspec::Core.configuration.find_modules(self).each do |include_or_extend, mod, opts|
73
+ configuration.find_modules(self).each do |include_or_extend, mod, opts|
69
74
  if include_or_extend == :extend
70
75
  send(:extend, mod) unless extended_modules.include?(mod)
71
76
  else
@@ -116,6 +121,7 @@ module Rspec
116
121
  def self._build(klass, given_caller, args, &example_group_block)
117
122
  args << {} unless args.last.is_a?(Hash)
118
123
  args.last.update(:example_group_block => example_group_block, :caller => given_caller)
124
+ args.unshift Rspec::Core.configuration unless args.first.is_a?(Rspec::Core::Configuration)
119
125
  klass.set_it_up(*args)
120
126
  klass.module_eval(&example_group_block) if example_group_block
121
127
  klass
@@ -153,26 +159,26 @@ module Rspec
153
159
  if superclass.respond_to?(:before_all_ivars)
154
160
  superclass.before_all_ivars.each { |ivar, val| running_example.instance_variable_set(ivar, val) }
155
161
  end
156
- Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_example.instance_eval(&blk) }
162
+ configuration.find_advice(:before, :all, self).each { |blk| running_example.instance_eval(&blk) }
157
163
 
158
164
  before_alls.each { |blk| running_example.instance_eval(&blk) }
159
165
  running_example.instance_variables.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
160
166
  end
161
167
 
162
168
  def self.eval_before_eachs(running_example)
163
- Rspec::Core.configuration.find_advice(:before, :each, self).each { |blk| running_example.instance_eval(&blk) }
169
+ configuration.find_advice(:before, :each, self).each { |blk| running_example.instance_eval(&blk) }
164
170
  before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_example.instance_eval(&blk) } }
165
171
  end
166
172
 
167
173
  def self.eval_after_alls(running_example)
168
174
  after_alls.each { |blk| running_example.instance_eval(&blk) }
169
- Rspec::Core.configuration.find_advice(:after, :all, self).each { |blk| running_example.instance_eval(&blk) }
175
+ configuration.find_advice(:after, :all, self).each { |blk| running_example.instance_eval(&blk) }
170
176
  before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
171
177
  end
172
178
 
173
179
  def self.eval_after_eachs(running_example)
174
180
  after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example.instance_eval(&blk) } }
175
- Rspec::Core.configuration.find_advice(:after, :each, self).each { |blk| running_example.instance_eval(&blk) }
181
+ configuration.find_advice(:after, :each, self).each { |blk| running_example.instance_eval(&blk) }
176
182
  end
177
183
 
178
184
  def self.run(reporter)
@@ -2,6 +2,14 @@ module Rspec
2
2
  module Core
3
3
  module KernelExtensions
4
4
 
5
+ unless respond_to?(:debugger)
6
+ # Start a debugging session if ruby-debug is loaded with the -u/--debugger option
7
+ def debugger(steps=1)
8
+ # If not then just comment and proceed
9
+ $stderr.puts "debugger statement ignored, use -d or --debug option on rspec to enable debugging"
10
+ end
11
+ end
12
+
5
13
  def describe(*args, &example_group_block)
6
14
  args << {} unless args.last.is_a?(Hash)
7
15
  args.last.update :caller => caller(1)
@@ -45,7 +45,7 @@ module Rspec
45
45
  @fail_on_error = true
46
46
 
47
47
  yield self if block_given?
48
- @pattern ||= 'spec/**/*_spec.rb'
48
+ @pattern ||= './spec/**/*_spec.rb'
49
49
  define
50
50
  end
51
51
 
@@ -1,16 +1,7 @@
1
1
  module Rspec # :nodoc:
2
2
  module Core # :nodoc:
3
3
  module Version # :nodoc:
4
- unless defined?(MAJOR)
5
- MAJOR = 2
6
- MINOR = 0
7
- TINY = 0
8
- PRE = 'a6'
9
-
10
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
11
-
12
- SUMMARY = "rspec-core " + STRING
13
- end
4
+ STRING = File.read(File.expand_path('../../../../VERSION', __FILE__))
14
5
  end
15
6
  end
16
7
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-core}
8
- s.version = "2.0.0.a6"
8
+ s.version = "2.0.0.a7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Humphries", "David Chelimsky"]
12
- s.date = %q{2010-02-15}
12
+ s.date = %q{2010-02-20}
13
13
  s.default_executable = %q{rspec}
14
14
  s.description = %q{Rspec runner and example group classes}
15
15
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "README.markdown",
26
26
  "Rakefile",
27
27
  "TODO.markdown",
28
+ "VERSION",
28
29
  "bin/rspec",
29
30
  "cucumber.yml",
30
31
  "example_specs/failing/README.txt",
@@ -97,12 +98,9 @@ Gem::Specification.new do |s|
97
98
  "features/configuration/spec_opts.feature",
98
99
  "features/example_groups/describe_aliases.feature",
99
100
  "features/example_groups/nested_groups.feature",
100
- "features/expectations/customized_message.feature",
101
101
  "features/hooks/around_hook.feature",
102
102
  "features/hooks/before_and_after_hooks.feature",
103
103
  "features/hooks/halt.feature",
104
- "features/matchers/define_matcher.feature",
105
- "features/matchers/define_matcher_outside_rspec.feature",
106
104
  "features/mock_framework_integration/use_flexmock.feature",
107
105
  "features/mock_framework_integration/use_mocha.feature",
108
106
  "features/mock_framework_integration/use_rr.feature",
@@ -178,7 +176,7 @@ Gem::Specification.new do |s|
178
176
  s.require_paths = ["lib"]
179
177
  s.rubyforge_project = %q{rspec}
180
178
  s.rubygems_version = %q{1.3.5}
181
- s.summary = %q{rspec-core 2.0.0.a6}
179
+ s.summary = %q{rspec-core-2.0.0.a7}
182
180
  s.test_files = [
183
181
  "spec/rspec/core/command_line_options_spec.rb",
184
182
  "spec/rspec/core/configuration_spec.rb",
@@ -211,17 +209,17 @@ Gem::Specification.new do |s|
211
209
  s.specification_version = 3
212
210
 
213
211
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
214
- s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.a6"])
215
- s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
212
+ s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.a7"])
213
+ s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.a7"])
216
214
  s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
217
215
  else
218
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a6"])
219
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
216
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a7"])
217
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a7"])
220
218
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
221
219
  end
222
220
  else
223
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a6"])
224
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
221
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.a7"])
222
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a7"])
225
223
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
226
224
  end
227
225
  end
@@ -121,5 +121,12 @@ describe Rspec::Core::CommandLineOptions do
121
121
  end
122
122
  end
123
123
 
124
+ describe "--debug (-d)" do
125
+ it "sets debug on config" do
126
+ options_from_args("--debug").should include(:debug => true)
127
+ options_from_args("-d").should include(:debug => true)
128
+ end
129
+ end
130
+
124
131
  end
125
132
 
@@ -1,220 +1,236 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rspec::Core::Configuration do
3
+ module Rspec::Core
4
4
 
5
- context "setting the mock framework" do
5
+ describe Configuration do
6
6
 
7
- it "requires and includes the rspec adapter when the mock_framework is :rspec" do
8
- config = Rspec::Core::Configuration.new
9
- config.should_receive(:require).with('rspec/core/mocking/with_rspec')
10
- Rspec::Core::ExampleGroup.should_receive(:send)
11
- config.mock_framework = :rspec
12
- end
13
-
14
- it "supports mock_with for backward compatibility with rspec-1.x" do
15
- config = Rspec::Core::Configuration.new
16
- config.stub!(:require)
17
- Rspec::Core::ExampleGroup.stub!(:send)
18
- config.mock_with :rspec
19
- end
20
-
21
- it "includes the null adapter when the mock_framework is not :rspec, :mocha, or :rr" do
22
- config = Rspec::Core::Configuration.new
23
- Rspec::Core::ExampleGroup.should_receive(:send).with(:include, Rspec::Core::Mocking::WithAbsolutelyNothing)
24
- config.mock_framework = :crazy_new_mocking_framework_ive_not_yet_heard_of
25
- end
26
-
27
- pending "includes the rspec adapter when the mock_framework is not set" do
28
- config = Rspec::Core::Configuration.new
29
- Rspec::Core::ExampleGroup.stub!(:send)
30
- config.mock_framework.should == :rspec
31
- end
32
-
33
- end
34
-
35
- context "setting the files to run" do
36
-
37
- before do
38
- @config = Rspec::Core::Configuration.new
39
- end
40
-
41
- it "should load files not following pattern if named explicitly" do
42
- file = File.expand_path(File.dirname(__FILE__) + "/resources/a_bar.rb")
43
- @config.files_or_directories_to_run = file
44
- @config.files_to_run.should include(file)
45
- end
46
-
47
- describe "with default --pattern" do
48
-
49
- it "should load files named _spec.rb" do
50
- dir = File.expand_path(File.dirname(__FILE__) + "/resources/")
51
- @config.files_or_directories_to_run = dir
52
- @config.files_to_run.should == ["#{dir}/a_spec.rb"]
53
- end
54
-
55
- end
7
+ let(:config) { Configuration.new }
56
8
 
57
- describe "with explicit pattern (single)" do
9
+ context "setting the mock framework" do
58
10
 
59
- before do
60
- @config.filename_pattern = "**/*_foo.rb"
11
+ it "requires and includes the rspec adapter when the mock_framework is :rspec" do
12
+ config.should_receive(:require).with('rspec/core/mocking/with_rspec')
13
+ ExampleGroup.should_receive(:send)
14
+ config.mock_framework = :rspec
61
15
  end
62
16
 
63
- it "should load files following pattern" do
64
- file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
65
- @config.files_or_directories_to_run = file
66
- @config.files_to_run.should include(file)
17
+ it "supports mock_with for backward compatibility with rspec-1.x" do
18
+ config.stub!(:require)
19
+ ExampleGroup.stub!(:send)
20
+ config.mock_with :rspec
67
21
  end
68
-
69
- it "should load files in directories following pattern" do
70
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
71
- @config.files_or_directories_to_run = dir
72
- @config.files_to_run.should include("#{dir}/a_foo.rb")
22
+
23
+ it "includes the null adapter when the mock_framework is not :rspec, :mocha, or :rr" do
24
+ ExampleGroup.should_receive(:send).with(:include, Mocking::WithAbsolutelyNothing)
25
+ config.mock_framework = :crazy_new_mocking_framework_ive_not_yet_heard_of
73
26
  end
74
27
 
75
- it "should not load files in directories not following pattern" do
76
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
77
- @config.files_or_directories_to_run = dir
78
- @config.files_to_run.should_not include("#{dir}/a_bar.rb")
28
+ pending "includes the rspec adapter when the mock_framework is not set" do
29
+ ExampleGroup.stub!(:send)
30
+ config.mock_framework.should == :rspec
79
31
  end
80
32
 
81
- end
33
+ end
34
+
35
+ context "setting the files to run" do
36
+
37
+ it "should load files not following pattern if named explicitly" do
38
+ file = "./spec/rspec/core/resources/a_bar.rb"
39
+ config.files_or_directories_to_run = file
40
+ config.files_to_run.should == [file]
41
+ end
82
42
 
83
- context "with explicit pattern (comma,separated,values)" do
43
+ describe "with default --pattern" do
84
44
 
85
- before do
86
- @config.filename_pattern = "**/*_foo.rb,**/*_bar.rb"
87
- end
45
+ it "should load files named _spec.rb" do
46
+ dir = "./spec/rspec/core/resources"
47
+ config.files_or_directories_to_run = dir
48
+ config.files_to_run.should == ["#{dir}/a_spec.rb"]
49
+ end
88
50
 
89
- it "should support comma separated values" do
90
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
91
- @config.files_or_directories_to_run = dir
92
- @config.files_to_run.should include("#{dir}/a_foo.rb")
93
- @config.files_to_run.should include("#{dir}/a_bar.rb")
94
51
  end
95
52
 
96
- it "should support comma separated values with spaces" do
97
- dir = File.expand_path(File.dirname(__FILE__) + "/resources")
98
- @config.files_or_directories_to_run = dir
99
- @config.files_to_run.should include("#{dir}/a_foo.rb")
100
- @config.files_to_run.should include("#{dir}/a_bar.rb")
53
+ describe "with explicit pattern (single)" do
54
+
55
+ before do
56
+ config.filename_pattern = "**/*_foo.rb"
57
+ end
58
+
59
+ it "should load files following pattern" do
60
+ file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
61
+ config.files_or_directories_to_run = file
62
+ config.files_to_run.should include(file)
63
+ end
64
+
65
+ it "should load files in directories following pattern" do
66
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
67
+ config.files_or_directories_to_run = dir
68
+ config.files_to_run.should include("#{dir}/a_foo.rb")
69
+ end
70
+
71
+ it "should not load files in directories not following pattern" do
72
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
73
+ config.files_or_directories_to_run = dir
74
+ config.files_to_run.should_not include("#{dir}/a_bar.rb")
75
+ end
76
+
101
77
  end
102
78
 
103
- end
79
+ context "with explicit pattern (comma,separated,values)" do
80
+
81
+ before do
82
+ config.filename_pattern = "**/*_foo.rb,**/*_bar.rb"
83
+ end
84
+
85
+ it "should support comma separated values" do
86
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
87
+ config.files_or_directories_to_run = dir
88
+ config.files_to_run.should include("#{dir}/a_foo.rb")
89
+ config.files_to_run.should include("#{dir}/a_bar.rb")
90
+ end
104
91
 
105
- context "with line number" do
92
+ it "should support comma separated values with spaces" do
93
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
94
+ config.files_or_directories_to_run = dir
95
+ config.files_to_run.should include("#{dir}/a_foo.rb")
96
+ config.files_to_run.should include("#{dir}/a_bar.rb")
97
+ end
106
98
 
107
- it "assigns the line number as the filter" do
108
- @config.files_or_directories_to_run = "path/to/a_spec.rb:37"
109
- @config.filter.should == {:line_number => 37}
110
99
  end
111
100
 
112
- end
101
+ context "with line number" do
113
102
 
114
- context "with full_description" do
103
+ it "assigns the line number as the filter" do
104
+ config.files_or_directories_to_run = "path/to/a_spec.rb:37"
105
+ config.filter.should == {:line_number => 37}
106
+ end
115
107
 
116
- it "assigns the example name as the filter on description" do
117
- @config.full_description = "foo"
118
- @config.filter.should == {:full_description => /foo/}
119
108
  end
120
109
 
121
- end
110
+ context "with full_description" do
122
111
 
123
- end
124
-
125
- describe "include" do
112
+ it "assigns the example name as the filter on description" do
113
+ config.full_description = "foo"
114
+ config.filter.should == {:full_description => /foo/}
115
+ end
126
116
 
127
- module InstanceLevelMethods
128
- def you_call_this_a_blt?
129
- "egad man, where's the mayo?!?!?"
130
117
  end
131
- end
132
118
 
133
- it "should include the given module into each matching example group" do
134
- Rspec::Core.configuration.include(InstanceLevelMethods, :magic_key => :include)
135
-
136
- group = Rspec::Core::ExampleGroup.create('does like, stuff and junk', :magic_key => :include) { }
137
- group.should_not respond_to(:you_call_this_a_blt?)
138
- group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
139
119
  end
120
+
121
+ describe "include" do
140
122
 
141
- end
142
-
143
- describe "extend" do
123
+ module InstanceLevelMethods
124
+ def you_call_this_a_blt?
125
+ "egad man, where's the mayo?!?!?"
126
+ end
127
+ end
144
128
 
145
- module ThatThingISentYou
129
+ context "with no filter" do
130
+ it "includes the given module into each example group" do
131
+ config.include(InstanceLevelMethods)
132
+
133
+ group = ExampleGroup.create(config, 'does like, stuff and junk', :magic_key => :include) { }
134
+ group.should_not respond_to(:you_call_this_a_blt?)
135
+ group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
136
+ end
137
+
138
+ end
146
139
 
147
- def that_thing
140
+ context "with a filter" do
141
+ it "includes the given module into each matching example group" do
142
+ config.include(InstanceLevelMethods, :magic_key => :include)
143
+
144
+ group = ExampleGroup.create(config, 'does like, stuff and junk', :magic_key => :include) { }
145
+ group.should_not respond_to(:you_call_this_a_blt?)
146
+ group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
147
+ end
148
148
  end
149
149
 
150
150
  end
151
151
 
152
- it "should extend the given module into each matching example group" do
153
- Rspec::Core.configuration.extend(ThatThingISentYou, :magic_key => :extend)
154
- group = Rspec::Core::ExampleGroup.create(ThatThingISentYou, :magic_key => :extend) { }
155
- group.should respond_to(:that_thing)
156
- end
152
+ describe "extend" do
157
153
 
158
- end
154
+ module ThatThingISentYou
155
+ def that_thing
156
+ end
157
+ end
159
158
 
160
- describe "run_all_when_everything_filtered" do
159
+ it "should extend the given module into each matching example group" do
160
+ config.extend(ThatThingISentYou, :magic_key => :extend)
161
+ group = ExampleGroup.create(config, ThatThingISentYou, :magic_key => :extend) { }
162
+ group.should respond_to(:that_thing)
163
+ end
161
164
 
162
- it "defaults to false" do
163
- Rspec::Core::Configuration.new.run_all_when_everything_filtered.should == false
164
165
  end
165
166
 
166
- it "can be queried with question method" do
167
- config = Rspec::Core::Configuration.new
168
- config.run_all_when_everything_filtered = true
169
- config.run_all_when_everything_filtered?.should == true
170
- end
171
- end
172
-
173
- describe 'formatter=' do
174
-
175
- it "sets formatter_to_use based on name" do
176
- config = Rspec::Core::Configuration.new
177
- config.formatter = :documentation
178
- config.formatter.should be_an_instance_of(Rspec::Core::Formatters::DocumentationFormatter)
179
- config.formatter = 'documentation'
180
- config.formatter.should be_an_instance_of(Rspec::Core::Formatters::DocumentationFormatter)
167
+ describe "run_all_when_everything_filtered" do
168
+
169
+ it "defaults to false" do
170
+ config.run_all_when_everything_filtered.should == false
171
+ end
172
+
173
+ it "can be queried with question method" do
174
+ config.run_all_when_everything_filtered = true
175
+ config.run_all_when_everything_filtered?.should == true
176
+ end
181
177
  end
182
178
 
183
- it "raises ArgumentError if formatter is unknown" do
184
- config = Rspec::Core::Configuration.new
185
- lambda { config.formatter = :progresss }.should raise_error(ArgumentError)
179
+ describe 'formatter=' do
180
+
181
+ it "sets formatter_to_use based on name" do
182
+ config.formatter = :documentation
183
+ config.formatter.should be_an_instance_of(Formatters::DocumentationFormatter)
184
+ config.formatter = 'documentation'
185
+ config.formatter.should be_an_instance_of(Formatters::DocumentationFormatter)
186
+ end
187
+
188
+ it "raises ArgumentError if formatter is unknown" do
189
+ lambda { config.formatter = :progresss }.should raise_error(ArgumentError)
190
+ end
191
+
186
192
  end
187
-
188
- end
189
193
 
190
- describe "line_number=" do
191
- it "sets the line number" do
192
- config = Rspec::Core::Configuration.new
193
- config.line_number = '37'
194
- config.filter.should == {:line_number => 37}
194
+ describe "line_number=" do
195
+ it "sets the line number" do
196
+ config.line_number = '37'
197
+ config.filter.should == {:line_number => 37}
198
+ end
199
+
200
+ it "overrides :focused" do
201
+ config.filter_run :focused => true
202
+ config.line_number = '37'
203
+ config.filter.should == {:line_number => 37}
204
+ end
205
+
206
+ it "prevents :focused" do
207
+ config.line_number = '37'
208
+ config.filter_run :focused => true
209
+ config.filter.should == {:line_number => 37}
210
+ end
195
211
  end
196
-
197
- it "overrides :focused" do
198
- config = Rspec::Core::Configuration.new
199
- config.filter_run :focused => true
200
- config.line_number = '37'
201
- config.filter.should == {:line_number => 37}
212
+
213
+ describe "full_backtrace=" do
214
+ it "clears the backtrace clean patterns" do
215
+ config.full_backtrace = true
216
+ config.options[:backtrace_clean_patterns].should == []
217
+ end
202
218
  end
203
-
204
- it "prevents :focused" do
205
- config = Rspec::Core::Configuration.new
206
- config.line_number = '37'
207
- config.filter_run :focused => true
208
- config.filter.should == {:line_number => 37}
219
+
220
+ describe "debug=true" do
221
+ it "requires 'ruby-debug'" do
222
+ config.should_receive(:require).with('ruby-debug')
223
+ config.debug = true
224
+ end
209
225
  end
210
- end
211
226
 
212
- describe "full_backtrace=" do
213
- it "clears the backtrace clean patterns" do
214
- config = Rspec::Core::Configuration.new
215
- config.full_backtrace = true
216
- config.options[:backtrace_clean_patterns].should == []
227
+ describe "debug=false" do
228
+ it "does not require 'ruby-debug'" do
229
+ config.should_not_receive(:require).with('ruby-debug')
230
+ config.debug = false
231
+ end
217
232
  end
233
+
218
234
  end
219
235
 
220
236
  end
@@ -1,7 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
2
2
  require 'rspec/core'
3
3
 
4
- require 'rubygems'
5
4
  $LOAD_PATH << File.expand_path('../../../rspec-expectations/lib', __FILE__)
6
5
  $LOAD_PATH << File.expand_path('../../../rspec-mocks/lib', __FILE__)
7
6
  require 'rspec/expectations'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.a6
4
+ version: 2.0.0.a7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Humphries
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-15 00:00:00 -04:00
13
+ date: 2010-02-20 00:00:00 -06:00
14
14
  default_executable: rspec
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 2.0.0.a6
24
+ version: 2.0.0.a7
25
25
  version:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec-mocks
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 2.0.0.a6
34
+ version: 2.0.0.a7
35
35
  version:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
@@ -59,6 +59,7 @@ files:
59
59
  - README.markdown
60
60
  - Rakefile
61
61
  - TODO.markdown
62
+ - VERSION
62
63
  - bin/rspec
63
64
  - cucumber.yml
64
65
  - example_specs/failing/README.txt
@@ -131,12 +132,9 @@ files:
131
132
  - features/configuration/spec_opts.feature
132
133
  - features/example_groups/describe_aliases.feature
133
134
  - features/example_groups/nested_groups.feature
134
- - features/expectations/customized_message.feature
135
135
  - features/hooks/around_hook.feature
136
136
  - features/hooks/before_and_after_hooks.feature
137
137
  - features/hooks/halt.feature
138
- - features/matchers/define_matcher.feature
139
- - features/matchers/define_matcher_outside_rspec.feature
140
138
  - features/mock_framework_integration/use_flexmock.feature
141
139
  - features/mock_framework_integration/use_mocha.feature
142
140
  - features/mock_framework_integration/use_rr.feature
@@ -233,7 +231,7 @@ rubyforge_project: rspec
233
231
  rubygems_version: 1.3.5
234
232
  signing_key:
235
233
  specification_version: 3
236
- summary: rspec-core 2.0.0.a6
234
+ summary: rspec-core-2.0.0.a7
237
235
  test_files:
238
236
  - spec/rspec/core/command_line_options_spec.rb
239
237
  - spec/rspec/core/configuration_spec.rb
@@ -1,54 +0,0 @@
1
- Feature: customized message
2
-
3
- In order to get the feedback I want
4
- As an RSpec user
5
- I want to customize the failure message per example
6
-
7
- Scenario: one additional method
8
- Given a file named "node_spec.rb" with:
9
- """
10
- class Node
11
- def initialize(state=:waiting)
12
- @state = state
13
- end
14
- def state
15
- @state
16
- end
17
- def waiting?
18
- @state == :waiting
19
- end
20
- def started?
21
- @state == :started
22
- end
23
- def start
24
- @state = :started
25
- end
26
- end
27
-
28
- describe "a new Node" do
29
- it "should be waiting" do
30
- node = Node.new(:started) #start w/ started to trigger failure
31
- node.should be_waiting, "node.state: #{node.state} (first example)"
32
- end
33
-
34
- it "should not be started" do
35
- node = Node.new(:started) #start w/ started to trigger failure
36
- node.should_not be_started, "node.state: #{node.state} (second example)"
37
- end
38
- end
39
-
40
- describe "node.start" do
41
- it "should change the state" do
42
- node = Node.new(:started) #start w/ started to trigger failure
43
- lambda {node.start}.should change{node.state}, "expected a change"
44
- end
45
- end
46
-
47
- """
48
- When I run "rspec node_spec.rb --format n"
49
- Then the stdout should match "3 examples, 3 failures"
50
- And the stdout should not match "to return true, got false"
51
- And the stdout should not match "to return false, got true"
52
- And the stdout should match "node.state: started (first example)"
53
- And the stdout should match "node.state: started (second example)"
54
- And the stdout should match "expected a change"
@@ -1,193 +0,0 @@
1
- Feature: define matcher
2
-
3
- In order to express my domain clearly in my code examples
4
- As an RSpec user
5
- I want a shortcut to define custom matchers
6
-
7
- Scenario: define a matcher with default messages
8
- Given a file named "matcher_with_default_message_spec.rb" with:
9
- """
10
- require 'rspec/expectations'
11
-
12
- Rspec::Matchers.define :be_a_multiple_of do |expected|
13
- match do |actual|
14
- actual % expected == 0
15
- end
16
- end
17
-
18
- describe 9 do
19
- it {should be_a_multiple_of(3)}
20
- end
21
-
22
- describe 9 do
23
- it {should_not be_a_multiple_of(4)}
24
- end
25
-
26
- # fail intentionally to generate expected output
27
- describe 9 do
28
- it {should be_a_multiple_of(4)}
29
- end
30
-
31
- # fail intentionally to generate expected output
32
- describe 9 do
33
- it {should_not be_a_multiple_of(3)}
34
- end
35
-
36
- """
37
- When I run "rspec matcher_with_default_message_spec.rb --format specdoc"
38
- Then the exit code should be 256
39
-
40
- And the stdout should match "should be a multiple of 3"
41
- And the stdout should match "should not be a multiple of 4"
42
- And the stdout should match "Failure/Error: it {should be_a_multiple_of(4)}"
43
- And the stdout should match "Failure/Error: it {should_not be_a_multiple_of(3)}"
44
-
45
- And the stdout should match "4 examples, 2 failures"
46
- And the stdout should match "expected 9 to be a multiple of 4"
47
- And the stdout should match "expected 9 not to be a multiple of 3"
48
-
49
- Scenario: overriding the failure_message_for_should
50
- Given a file named "matcher_with_failure_message_spec.rb" with:
51
- """
52
- require 'rspec/expectations'
53
-
54
- Rspec::Matchers.define :be_a_multiple_of do |expected|
55
- match do |actual|
56
- actual % expected == 0
57
- end
58
- failure_message_for_should do |actual|
59
- "expected that #{actual} would be a multiple of #{expected}"
60
- end
61
- end
62
-
63
- # fail intentionally to generate expected output
64
- describe 9 do
65
- it {should be_a_multiple_of(4)}
66
- end
67
- """
68
- When I run "rspec matcher_with_failure_message_spec.rb"
69
- Then the exit code should be 256
70
- And the stdout should match "1 example, 1 failure"
71
- And the stdout should match "expected that 9 would be a multiple of 4"
72
-
73
- Scenario: overriding the failure_message_for_should_not
74
- Given a file named "matcher_with_failure_for_message_spec.rb" with:
75
- """
76
- require 'rspec/expectations'
77
-
78
- Rspec::Matchers.define :be_a_multiple_of do |expected|
79
- match do |actual|
80
- actual % expected == 0
81
- end
82
- failure_message_for_should_not do |actual|
83
- "expected that #{actual} would not be a multiple of #{expected}"
84
- end
85
- end
86
-
87
- # fail intentionally to generate expected output
88
- describe 9 do
89
- it {should_not be_a_multiple_of(3)}
90
- end
91
- """
92
- When I run "rspec matcher_with_failure_for_message_spec.rb"
93
- Then the exit code should be 256
94
- And the stdout should match "1 example, 1 failure"
95
- And the stdout should match "expected that 9 would not be a multiple of 3"
96
-
97
- Scenario: overriding the description
98
- Given a file named "matcher_overriding_description_spec.rb" with:
99
- """
100
- require 'rspec/expectations'
101
-
102
- Rspec::Matchers.define :be_a_multiple_of do |expected|
103
- match do |actual|
104
- actual % expected == 0
105
- end
106
- description do
107
- "be multiple of #{expected}"
108
- end
109
- end
110
-
111
- describe 9 do
112
- it {should be_a_multiple_of(3)}
113
- end
114
-
115
- describe 9 do
116
- it {should_not be_a_multiple_of(4)}
117
- end
118
- """
119
- When I run "rspec matcher_overriding_description_spec.rb --format specdoc"
120
- Then the exit code should be 0
121
- And the stdout should match "2 examples, 0 failures"
122
- And the stdout should match "should be multiple of 3"
123
- And the stdout should match "should not be multiple of 4"
124
-
125
- Scenario: with no args
126
- Given a file named "matcher_with_no_args_spec.rb" with:
127
- """
128
- require 'rspec/expectations'
129
-
130
- Rspec::Matchers.define :have_7_fingers do
131
- match do |thing|
132
- thing.fingers.length == 7
133
- end
134
- end
135
-
136
- class Thing
137
- def fingers; (1..7).collect {"finger"}; end
138
- end
139
-
140
- describe Thing do
141
- it {should have_7_fingers}
142
- end
143
- """
144
- When I run "rspec matcher_with_no_args_spec.rb --format specdoc"
145
- Then the exit code should be 0
146
- And the stdout should match "1 example, 0 failures"
147
- And the stdout should match "should have 7 fingers"
148
-
149
- Scenario: with multiple args
150
- Given a file named "matcher_with_multiple_args_spec.rb" with:
151
- """
152
- require 'rspec/expectations'
153
-
154
- Rspec::Matchers.define :be_the_sum_of do |a,b,c,d|
155
- match do |sum|
156
- a + b + c + d == sum
157
- end
158
- end
159
-
160
- describe 10 do
161
- it {should be_the_sum_of(1,2,3,4)}
162
- end
163
- """
164
- When I run "rspec matcher_with_multiple_args_spec.rb --format specdoc"
165
- Then the exit code should be 0
166
- And the stdout should match "1 example, 0 failures"
167
- And the stdout should match "should be the sum of 1, 2, 3, and 4"
168
-
169
- Scenario: with helper methods
170
- Given a file named "matcher_with_internal_helper_spec.rb" with:
171
- """
172
- require 'rspec/expectations'
173
-
174
- Rspec::Matchers.define :have_same_elements_as do |sample|
175
- match do |actual|
176
- similar?(sample, actual)
177
- end
178
-
179
- def similar?(a, b)
180
- a.sort == b.sort
181
- end
182
- end
183
-
184
- describe "these two arrays" do
185
- specify "should be similar" do
186
- [1,2,3].should have_same_elements_as([2,3,1])
187
- end
188
- end
189
- """
190
- When I run "rspec matcher_with_internal_helper_spec.rb"
191
- Then the exit code should be 0
192
- And the stdout should match "1 example, 0 failures"
193
-
@@ -1,38 +0,0 @@
1
- Feature: define matcher outside rspec
2
-
3
- In order to express my domain clearly in my code examples
4
- As a non-rspec user
5
- I want a shortcut to define custom matchers
6
-
7
- Scenario: define a matcher with default messages
8
- Given a file named "test_multiples.rb" with:
9
- """
10
- require 'test/unit'
11
- require 'rspec/expectations'
12
-
13
- Rspec::Matchers.define :be_a_multiple_of do |expected|
14
- match do |actual|
15
- actual % expected == 0
16
- end
17
- end
18
-
19
- class Test::Unit::TestCase
20
- include Rspec::Matchers
21
- end
22
-
23
- class TestMultiples < Test::Unit::TestCase
24
-
25
- def test_9_should_be_a_multiple_of_3
26
- 9.should be_a_multiple_of(3)
27
- end
28
-
29
- def test_9_should_be_a_multiple_of_4
30
- 9.should be_a_multiple_of(4)
31
- end
32
-
33
- end
34
- """
35
- When I run "ruby test_multiples.rb"
36
- Then the exit code should be 256
37
- And the stdout should match "expected 9 to be a multiple of 4"
38
- And the stdout should match "2 tests, 0 assertions, 0 failures, 1 errors"