rspec-core 2.8.0 → 2.9.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/.document +5 -0
  2. data/.yardopts +3 -0
  3. data/Changelog.md +492 -0
  4. data/README.md +1 -1
  5. data/features/mock_framework_integration/use_flexmock.feature +2 -2
  6. data/features/step_definitions/additional_cli_steps.rb +2 -2
  7. data/features/subject/attribute_of_subject.feature +4 -2
  8. data/features/subject/explicit_subject.feature +6 -2
  9. data/features/subject/implicit_receiver.feature +1 -1
  10. data/features/subject/implicit_subject.feature +40 -7
  11. data/lib/autotest/rspec2.rb +1 -1
  12. data/lib/rspec/core.rb +1 -1
  13. data/lib/rspec/core/configuration.rb +53 -5
  14. data/lib/rspec/core/configuration_options.rb +5 -2
  15. data/lib/rspec/core/drb_options.rb +3 -1
  16. data/lib/rspec/core/filter_manager.rb +1 -1
  17. data/lib/rspec/core/formatters/base_text_formatter.rb +1 -5
  18. data/lib/rspec/core/formatters/documentation_formatter.rb +4 -8
  19. data/lib/rspec/core/formatters/helpers.rb +15 -0
  20. data/lib/rspec/core/hooks.rb +3 -1
  21. data/lib/rspec/core/metadata.rb +6 -11
  22. data/lib/rspec/core/runner.rb +4 -14
  23. data/lib/rspec/core/version.rb +1 -1
  24. data/lib/rspec/core/world.rb +7 -7
  25. data/spec/autotest/rspec_spec.rb +1 -1
  26. data/spec/rspec/core/configuration_options_spec.rb +8 -5
  27. data/spec/rspec/core/configuration_spec.rb +38 -10
  28. data/spec/rspec/core/example_group_spec.rb +16 -0
  29. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +23 -1
  30. data/spec/rspec/core/formatters/helpers_spec.rb +20 -0
  31. data/spec/rspec/core/metadata_spec.rb +3 -4
  32. data/spec/rspec/core/shared_example_group_spec.rb +2 -2
  33. data/spec/rspec/core/world_spec.rb +11 -1
  34. metadata +166 -19
  35. data/lib/rspec/monkey.rb +0 -1
  36. data/lib/rspec/monkey/spork/test_framework/rspec.rb +0 -10
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Core
3
3
  module Version
4
- STRING = '2.8.0'
4
+ STRING = '2.9.0.rc2'
5
5
  end
6
6
  end
7
7
  end
@@ -4,12 +4,13 @@ module RSpec
4
4
 
5
5
  include RSpec::Core::Hooks
6
6
 
7
- attr_reader :example_groups, :filtered_examples, :wants_to_quit
8
- attr_writer :wants_to_quit
7
+ attr_reader :example_groups, :shared_example_groups, :filtered_examples
8
+ attr_accessor :wants_to_quit
9
9
 
10
10
  def initialize(configuration=RSpec.configuration)
11
11
  @configuration = configuration
12
12
  @example_groups = [].extend(Extensions::Ordered)
13
+ @shared_example_groups = {}
13
14
  @filtered_examples = Hash.new { |hash,group|
14
15
  hash[group] = begin
15
16
  examples = group.examples.dup
@@ -22,6 +23,7 @@ module RSpec
22
23
 
23
24
  def reset
24
25
  example_groups.clear
26
+ shared_example_groups.clear
25
27
  end
26
28
 
27
29
  def filter_manager
@@ -45,12 +47,10 @@ module RSpec
45
47
  @configuration.configure_group(group)
46
48
  end
47
49
 
48
- def shared_example_groups
49
- @shared_example_groups ||= {}
50
- end
51
-
52
50
  def example_count
53
- example_groups.collect {|g| g.descendants}.flatten.inject(0) { |sum, g| sum += g.filtered_examples.size }
51
+ example_groups.collect {|g| g.descendants}.flatten.inject(0) do |sum, g|
52
+ sum += g.filtered_examples.size
53
+ end
54
54
  end
55
55
 
56
56
  def preceding_declaration_line(filter_line)
@@ -30,7 +30,7 @@ describe Autotest::Rspec2 do
30
30
 
31
31
  it "makes the appropriate test command" do
32
32
  actual_command = rspec_autotest.make_test_cmd(@files_to_test)
33
- expected_command = /#{ruby_cmd}.*#{spec_cmd} (.*)/
33
+ expected_command = /#{ruby_cmd}.*'#{spec_cmd}' (.*)/
34
34
 
35
35
  actual_command.should match(expected_command)
36
36
 
@@ -74,13 +74,9 @@ describe RSpec::Core::ConfigurationOptions do
74
74
  ["--pattern", "foo/bar", :pattern, "foo/bar"],
75
75
  ["--failure-exit-code", "37", :failure_exit_code, 37],
76
76
  ["--default_path", "behavior", :default_path, "behavior"],
77
- ["--drb", nil, :drb, true],
78
77
  ["--order", "rand", :order, "rand"],
79
78
  ["--seed", "37", :order, "rand:37"],
80
- ["--drb-port", "37", :drb_port, 37],
81
- ["--backtrace", nil, :full_backtrace, true],
82
- ["--profile", nil, :profile_examples, true],
83
- ["--tty", nil, :tty, true]
79
+ ["--drb-port", "37", :drb_port, 37]
84
80
  ].each do |cli_option, cli_value, config_key, config_value|
85
81
  it "forces #{config_key}" do
86
82
  opts = config_options_object(*[cli_option, cli_value].compact)
@@ -305,6 +301,13 @@ describe RSpec::Core::ConfigurationOptions do
305
301
  end
306
302
  end
307
303
 
304
+ describe "#filter_manager" do
305
+ it "returns the same object as RSpec::configuration.filter_manager" do
306
+ config_options_object.filter_manager.
307
+ should be(RSpec::configuration.filter_manager)
308
+ end
309
+ end
310
+
308
311
  describe "sources: ~/.rspec, ./.rspec, custom, CLI, and SPEC_OPTS" do
309
312
  before(:each) do
310
313
  FileUtils.mkpath(File.expand_path("~"))
@@ -713,20 +713,16 @@ module RSpec::Core
713
713
  end
714
714
 
715
715
  describe "the default :if filter" do
716
- it "does not exclude a spec with no :if metadata" do
717
- config.exclusion_filter[:if].call(nil, {}).should be_false
716
+ it "does not exclude a spec with { :if => true } metadata" do
717
+ config.exclusion_filter[:if].call(true).should be_false
718
718
  end
719
719
 
720
- it "does not exclude a spec with { :if => true } metadata" do
721
- config.exclusion_filter[:if].call(true, {:if => true}).should be_false
720
+ it "excludes a spec with { :if => false } metadata" do
721
+ config.exclusion_filter[:if].call(false).should be_true
722
722
  end
723
723
 
724
- it "excludes a spec with { :if => false } metadata" do
725
- config.exclusion_filter[:if].call(false, {:if => false}).should be_true
726
- end
727
-
728
- it "excludes a spec with { :if => nil } metadata" do
729
- config.exclusion_filter[:if].call(false, {:if => nil}).should be_true
724
+ it "excludes a spec with { :if => nil } metadata" do
725
+ config.exclusion_filter[:if].call(nil).should be_true
730
726
  end
731
727
  end
732
728
 
@@ -1005,6 +1001,38 @@ module RSpec::Core
1005
1001
  group.included_modules.should include(mod1)
1006
1002
  group.included_modules.should include(mod2)
1007
1003
  end
1004
+
1005
+ module IncludeOrExtendMeOnce
1006
+ def self.included(host)
1007
+ raise "included again" if host.instance_methods.include?(:foobar)
1008
+ host.class_eval { def foobar; end }
1009
+ end
1010
+
1011
+ def self.extended(host)
1012
+ raise "extended again" if host.respond_to?(:foobar)
1013
+ def host.foobar; end
1014
+ end
1015
+ end
1016
+
1017
+ it "doesn't include a module when already included in ancestor" do
1018
+ config.include(IncludeOrExtendMeOnce, :foo => :bar)
1019
+
1020
+ group = ExampleGroup.describe("group", :foo => :bar)
1021
+ child = group.describe("child")
1022
+
1023
+ config.configure_group(group)
1024
+ config.configure_group(child)
1025
+ end
1026
+
1027
+ it "doesn't extend when ancestor is already extended with same module" do
1028
+ config.extend(IncludeOrExtendMeOnce, :foo => :bar)
1029
+
1030
+ group = ExampleGroup.describe("group", :foo => :bar)
1031
+ child = group.describe("child")
1032
+
1033
+ config.configure_group(group)
1034
+ config.configure_group(child)
1035
+ end
1008
1036
  end
1009
1037
 
1010
1038
  describe "#alias_example_to" do
@@ -293,6 +293,22 @@ module RSpec::Core
293
293
  group.run.should be_true
294
294
  end
295
295
  end
296
+
297
+ context "and metadata redefinition after `described_class` call" do
298
+ it "is the redefined level constant" do
299
+ group = ExampleGroup.describe(String) do
300
+ described_class
301
+ metadata[:example_group][:described_class] = Object
302
+ describe :symbol do
303
+ example "described_class is Object" do
304
+ described_class.should eq(Object)
305
+ end
306
+ end
307
+ end
308
+
309
+ group.run.should be_true
310
+ end
311
+ end
296
312
  end
297
313
 
298
314
  context "in a nested group" do
@@ -28,7 +28,6 @@ module RSpec::Core::Formatters
28
28
  end
29
29
 
30
30
  it "represents nested group using hierarchy tree" do
31
-
32
31
  output = StringIO.new
33
32
  RSpec.configuration.stub(:color_enabled?) { false }
34
33
 
@@ -60,6 +59,29 @@ root
60
59
  context 2
61
60
  nested example 2.1
62
61
  nested example 2.2
62
+ ")
63
+ end
64
+
65
+ it "strips whitespace for each row" do
66
+ output = StringIO.new
67
+ RSpec.configuration.stub(:color_enabled?) { false }
68
+
69
+ formatter = RSpec::Core::Formatters::DocumentationFormatter.new(output)
70
+
71
+ group = RSpec::Core::ExampleGroup.describe(" root ")
72
+ context1 = group.describe(" nested ")
73
+ context1.example(" example 1 ") {}
74
+ context1.example(" example 2 ", :pending => true){}
75
+ context1.example(" example 3 ") { fail }
76
+
77
+ group.run(RSpec::Core::Reporter.new(formatter))
78
+
79
+ output.string.should eql("
80
+ root
81
+ nested
82
+ example 1
83
+ example 2 (PENDING: No reason given)
84
+ example 3 (FAILED - 1)
63
85
  ")
64
86
  end
65
87
  end
@@ -4,6 +4,26 @@ require 'rspec/core/formatters/helpers'
4
4
  describe RSpec::Core::Formatters::Helpers do
5
5
  let(:helper) { Object.new.extend(RSpec::Core::Formatters::Helpers) }
6
6
 
7
+ describe "format duration" do
8
+ context '> 60 and < 120' do
9
+ it "returns 'x minute xx seconds' formatted string" do
10
+ helper.format_duration(70.14).should eq("1 minute 10.14 seconds")
11
+ end
12
+ end
13
+
14
+ context '> 120' do
15
+ it "returns 'x minutes xx seconds' formatted string" do
16
+ helper.format_duration(135.14).should eq("2 minutes 15.14 seconds")
17
+ end
18
+ end
19
+
20
+ context '< 60' do
21
+ it "returns 'xx seconds' formatted string" do
22
+ helper.format_duration(45.5).should eq("45.5 seconds")
23
+ end
24
+ end
25
+ end
26
+
7
27
  describe "format seconds" do
8
28
  context "sub second times" do
9
29
  it "returns 5 digits of precision" do
@@ -126,10 +126,9 @@ module RSpec
126
126
  example_metadata.filter_applies?(:if, lambda { |v| !v }).should be_false
127
127
  end
128
128
 
129
- it "passes the metadata hash as the second argument if a given proc expects 2 args" do
130
- passed_metadata = nil
131
- example_metadata.filter_applies?(:if, lambda { |v, m| passed_metadata = m })
132
- passed_metadata.should eq(example_metadata)
129
+ it "matches a proc with an arity of 2" do
130
+ example_metadata[:foo] = nil
131
+ example_metadata.filter_applies?(:foo, lambda { |v, m| m == example_metadata }).should be_true
133
132
  end
134
133
 
135
134
  context "with an Array" do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module RSpec::Core
4
4
  describe SharedExampleGroup do
5
-
5
+
6
6
  ExampleModule = Module.new
7
7
  ExampleClass = Class.new
8
8
 
@@ -19,7 +19,7 @@ module RSpec::Core
19
19
  group.send(method_name, 'shared group') {}
20
20
  end.should raise_error(ArgumentError, "Shared example group 'shared group' already exists")
21
21
  end
22
-
22
+
23
23
  ["name", :name, ExampleModule, ExampleClass].each do |object|
24
24
  type = object.class.name.downcase
25
25
  context "given a #{type}" do
@@ -9,6 +9,16 @@ module RSpec::Core
9
9
  let(:configuration) { RSpec::Core::Configuration.new }
10
10
  let(:world) { RSpec::Core::World.new(configuration) }
11
11
 
12
+ describe '#reset' do
13
+ it 'clears #example_groups and #shared_example_groups' do
14
+ world.example_groups << :example_group
15
+ world.shared_example_groups[:shared] = :example_group
16
+ world.reset
17
+ world.example_groups.should be_empty
18
+ world.shared_example_groups.should be_empty
19
+ end
20
+ end
21
+
12
22
  describe "#example_groups" do
13
23
  it "contains all registered example groups" do
14
24
  group = RSpec::Core::ExampleGroup.describe("group"){}
@@ -64,7 +74,7 @@ module RSpec::Core
64
74
  context "with two exaples and the second example is registre first" do
65
75
  let(:second_group_declaration_line) { second_group.metadata[:example_group][:line_number] }
66
76
 
67
- before do
77
+ before do
68
78
  world.register(second_group)
69
79
  world.register(group)
70
80
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
5
- prerelease:
4
+ hash: -2242269716
5
+ prerelease: 6
6
6
  segments:
7
7
  - 2
8
- - 8
8
+ - 9
9
9
  - 0
10
- version: 2.8.0
10
+ - rc
11
+ - 2
12
+ version: 2.9.0.rc2
11
13
  platform: ruby
12
14
  authors:
13
15
  - Steven Baker
@@ -17,9 +19,152 @@ autorequire:
17
19
  bindir: exe
18
20
  cert_chain: []
19
21
 
20
- date: 2012-01-05 00:00:00 Z
21
- dependencies: []
22
-
22
+ date: 2012-03-12 00:00:00 Z
23
+ dependencies:
24
+ - !ruby/object:Gem::Dependency
25
+ name: cucumber
26
+ prerelease: false
27
+ requirement: &id001 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ hash: 1
33
+ segments:
34
+ - 1
35
+ - 1
36
+ - 9
37
+ version: 1.1.9
38
+ type: :development
39
+ version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
41
+ name: aruba
42
+ prerelease: false
43
+ requirement: &id002 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ hash: 25
49
+ segments:
50
+ - 0
51
+ - 4
52
+ - 11
53
+ version: 0.4.11
54
+ type: :development
55
+ version_requirements: *id002
56
+ - !ruby/object:Gem::Dependency
57
+ name: ZenTest
58
+ prerelease: false
59
+ requirement: &id003 !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - "="
63
+ - !ruby/object:Gem::Version
64
+ hash: 35
65
+ segments:
66
+ - 4
67
+ - 6
68
+ - 2
69
+ version: 4.6.2
70
+ type: :development
71
+ version_requirements: *id003
72
+ - !ruby/object:Gem::Dependency
73
+ name: nokogiri
74
+ prerelease: false
75
+ requirement: &id004 !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - "="
79
+ - !ruby/object:Gem::Version
80
+ hash: 7
81
+ segments:
82
+ - 1
83
+ - 5
84
+ - 2
85
+ version: 1.5.2
86
+ type: :development
87
+ version_requirements: *id004
88
+ - !ruby/object:Gem::Dependency
89
+ name: fakefs
90
+ prerelease: false
91
+ requirement: &id005 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - "="
95
+ - !ruby/object:Gem::Version
96
+ hash: 15
97
+ segments:
98
+ - 0
99
+ - 4
100
+ - 0
101
+ version: 0.4.0
102
+ type: :development
103
+ version_requirements: *id005
104
+ - !ruby/object:Gem::Dependency
105
+ name: syntax
106
+ prerelease: false
107
+ requirement: &id006 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - "="
111
+ - !ruby/object:Gem::Version
112
+ hash: 23
113
+ segments:
114
+ - 1
115
+ - 0
116
+ - 0
117
+ version: 1.0.0
118
+ type: :development
119
+ version_requirements: *id006
120
+ - !ruby/object:Gem::Dependency
121
+ name: mocha
122
+ prerelease: false
123
+ requirement: &id007 !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ~>
127
+ - !ruby/object:Gem::Version
128
+ hash: 61
129
+ segments:
130
+ - 0
131
+ - 10
132
+ - 5
133
+ version: 0.10.5
134
+ type: :development
135
+ version_requirements: *id007
136
+ - !ruby/object:Gem::Dependency
137
+ name: rr
138
+ prerelease: false
139
+ requirement: &id008 !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ~>
143
+ - !ruby/object:Gem::Version
144
+ hash: 31
145
+ segments:
146
+ - 1
147
+ - 0
148
+ - 4
149
+ version: 1.0.4
150
+ type: :development
151
+ version_requirements: *id008
152
+ - !ruby/object:Gem::Dependency
153
+ name: flexmock
154
+ prerelease: false
155
+ requirement: &id009 !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ~>
159
+ - !ruby/object:Gem::Version
160
+ hash: 59
161
+ segments:
162
+ - 0
163
+ - 9
164
+ - 0
165
+ version: 0.9.0
166
+ type: :development
167
+ version_requirements: *id009
23
168
  description: BDD for Ruby. RSpec runner and example groups.
24
169
  email: rspec-users@rubyforge.org
25
170
  executables:
@@ -27,9 +172,8 @@ executables:
27
172
  - rspec
28
173
  extensions: []
29
174
 
30
- extra_rdoc_files:
31
- - README.md
32
- - License.txt
175
+ extra_rdoc_files: []
176
+
33
177
  files:
34
178
  - lib/autotest/discover.rb
35
179
  - lib/autotest/rspec2.rb
@@ -81,10 +225,11 @@ files:
81
225
  - lib/rspec/core/subject.rb
82
226
  - lib/rspec/core/version.rb
83
227
  - lib/rspec/core/world.rb
84
- - lib/rspec/monkey.rb
85
- - lib/rspec/monkey/spork/test_framework/rspec.rb
86
- - License.txt
87
228
  - README.md
229
+ - License.txt
230
+ - Changelog.md
231
+ - .yardopts
232
+ - .document
88
233
  - features/Autotest.md
89
234
  - features/README.md
90
235
  - features/Upgrade.md
@@ -218,19 +363,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
363
  required_rubygems_version: !ruby/object:Gem::Requirement
219
364
  none: false
220
365
  requirements:
221
- - - ">="
366
+ - - ">"
222
367
  - !ruby/object:Gem::Version
223
- hash: 3
368
+ hash: 25
224
369
  segments:
225
- - 0
226
- version: "0"
370
+ - 1
371
+ - 3
372
+ - 1
373
+ version: 1.3.1
227
374
  requirements: []
228
375
 
229
376
  rubyforge_project: rspec
230
- rubygems_version: 1.8.11
377
+ rubygems_version: 1.8.15
231
378
  signing_key:
232
379
  specification_version: 3
233
- summary: rspec-core-2.8.0
380
+ summary: rspec-core-2.9.0.rc2
234
381
  test_files:
235
382
  - features/Autotest.md
236
383
  - features/README.md