rspec-core 2.8.0.rc1 → 2.8.0.rc2

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 (73) hide show
  1. data/License.txt +24 -0
  2. data/README.md +197 -37
  3. data/features/command_line/format_option.feature +3 -3
  4. data/features/command_line/init.feature +18 -0
  5. data/features/example_groups/shared_examples.feature +1 -1
  6. data/features/hooks/around_hooks.feature +4 -4
  7. data/features/pending/pending_examples.feature +5 -5
  8. data/features/support/env.rb +8 -1
  9. data/lib/autotest/rspec2.rb +2 -6
  10. data/lib/rspec/core.rb +48 -158
  11. data/lib/rspec/core/backward_compatibility.rb +2 -0
  12. data/lib/rspec/core/command_line.rb +4 -0
  13. data/lib/rspec/core/configuration.rb +201 -106
  14. data/lib/rspec/core/configuration_options.rb +2 -1
  15. data/lib/rspec/core/deprecation.rb +2 -3
  16. data/lib/rspec/core/drb_options.rb +69 -58
  17. data/lib/rspec/core/dsl.rb +12 -0
  18. data/lib/rspec/core/example.rb +53 -18
  19. data/lib/rspec/core/example_group.rb +144 -54
  20. data/lib/rspec/core/extensions.rb +4 -4
  21. data/lib/rspec/core/extensions/instance_eval_with_args.rb +5 -0
  22. data/lib/rspec/core/extensions/kernel.rb +1 -1
  23. data/lib/rspec/core/extensions/module_eval_with_args.rb +4 -0
  24. data/lib/rspec/core/extensions/ordered.rb +7 -2
  25. data/lib/rspec/core/filter_manager.rb +69 -36
  26. data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
  27. data/lib/rspec/core/formatters/html_formatter.rb +10 -4
  28. data/lib/rspec/core/hooks.rb +93 -34
  29. data/lib/rspec/core/let.rb +62 -61
  30. data/lib/rspec/core/metadata.rb +103 -80
  31. data/lib/rspec/core/metadata_hash_builder.rb +4 -0
  32. data/lib/rspec/core/option_parser.rb +42 -44
  33. data/lib/rspec/core/pending.rb +25 -3
  34. data/lib/rspec/core/project_initializer.rb +62 -0
  35. data/lib/rspec/core/rake_task.rb +7 -13
  36. data/lib/rspec/core/runner.rb +2 -2
  37. data/lib/rspec/core/shared_context.rb +1 -1
  38. data/lib/rspec/core/shared_example_group.rb +11 -5
  39. data/lib/rspec/core/subject.rb +3 -3
  40. data/lib/rspec/core/version.rb +1 -1
  41. data/lib/rspec/monkey.rb +1 -1
  42. data/lib/rspec/monkey/spork/test_framework/rspec.rb +2 -0
  43. data/spec/command_line/order_spec.rb +19 -13
  44. data/spec/rspec/core/command_line_spec.rb +1 -5
  45. data/spec/rspec/core/configuration_options_spec.rb +22 -27
  46. data/spec/rspec/core/configuration_spec.rb +32 -14
  47. data/spec/rspec/core/drb_command_line_spec.rb +20 -37
  48. data/spec/rspec/core/drb_options_spec.rb +51 -3
  49. data/spec/rspec/core/example_group_spec.rb +101 -84
  50. data/spec/rspec/core/example_spec.rb +14 -0
  51. data/spec/rspec/core/filter_manager_spec.rb +114 -33
  52. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +17 -69
  53. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +14 -4
  54. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +14 -4
  55. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +14 -4
  56. data/spec/rspec/core/formatters/html_formatter_spec.rb +1 -1
  57. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +20 -72
  58. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +24 -14
  59. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -19
  60. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +29 -19
  61. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -2
  62. data/spec/rspec/core/metadata_spec.rb +77 -45
  63. data/spec/rspec/core/option_parser_spec.rb +5 -0
  64. data/spec/rspec/core/pending_example_spec.rb +44 -12
  65. data/spec/rspec/core/project_initializer_spec.rb +130 -0
  66. data/spec/rspec/core/rake_task_spec.rb +1 -1
  67. data/spec/spec_helper.rb +2 -0
  68. data/spec/support/matchers.rb +2 -12
  69. metadata +18 -16
  70. data/features/command_line/configure.feature +0 -22
  71. data/lib/rspec/core/command_line_configuration.rb +0 -62
  72. data/lib/rspec/core/errors.rb +0 -13
  73. data/spec/rspec/core/command_line_configuration_spec.rb +0 -26
@@ -109,6 +109,11 @@ module RSpec::Core
109
109
  options = Parser.parse!([option, 'foo:false', option, 'bar:true', option, 'foo:true'])
110
110
  options[:inclusion_filter].should eq(:foo => true, :bar => true)
111
111
  end
112
+
113
+ it "treats 'any_string' as 'any_string'" do
114
+ options = Parser.parse!([option, 'foo:any_string'])
115
+ options[:inclusion_filter].should eq(:foo => 'any_string')
116
+ end
112
117
  end
113
118
 
114
119
  context "with ~" do
@@ -1,14 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "an example" do
4
+ matcher :be_pending_with do |message|
5
+ match do |example|
6
+ example.pending? && example.metadata[:execution_result][:pending_message] == message
7
+ end
8
+
9
+ failure_message_for_should do |example|
10
+ "expected: example pending with #{message.inspect}\n got: #{example.metadata[:execution_result][:pending_message].inspect}"
11
+ end
12
+ end
13
+
14
+ context "declared pending with metadata" do
15
+ it "uses the value assigned to :pending as the message" do
16
+ group = RSpec::Core::ExampleGroup.describe('group') do
17
+ example "example", :pending => 'just because' do
18
+ end
19
+ end
20
+ example = group.examples.first
21
+ example.run(group.new, stub.as_null_object)
22
+ example.should be_pending_with('just because')
23
+ end
24
+
25
+ it "sets the message to 'No reason given' if :pending => true" do
26
+ group = RSpec::Core::ExampleGroup.describe('group') do
27
+ example "example", :pending => true do
28
+ end
29
+ end
30
+ example = group.examples.first
31
+ example.run(group.new, stub.as_null_object)
32
+ example.should be_pending_with('No reason given')
33
+ end
34
+ end
35
+
4
36
  context "with no block" do
5
- it "is listed as pending with 'Not Yet Implemented'" do
37
+ it "is listed as pending with 'Not yet implemented'" do
6
38
  group = RSpec::Core::ExampleGroup.describe('group') do
7
39
  it "has no block"
8
40
  end
9
41
  example = group.examples.first
10
42
  example.run(group.new, stub.as_null_object)
11
- example.should be_pending_with('Not Yet Implemented')
43
+ example.should be_pending_with('Not yet implemented')
12
44
  end
13
45
  end
14
46
 
@@ -21,7 +53,7 @@ describe "an example" do
21
53
  end
22
54
  example = group.examples.first
23
55
  example.run(group.new, stub.as_null_object)
24
- example.should be_pending_with(RSpec::Core::Pending::DEFAULT_MESSAGE)
56
+ example.should be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
25
57
  end
26
58
  end
27
59
 
@@ -94,7 +126,7 @@ describe "an example" do
94
126
  end
95
127
 
96
128
  it "is listed as pending with the default message when no message is given" do
97
- run_example.should be_pending_with(RSpec::Core::Pending::DEFAULT_MESSAGE)
129
+ run_example.should be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
98
130
  end
99
131
  end
100
132
 
@@ -104,7 +136,7 @@ describe "an example" do
104
136
  end
105
137
 
106
138
  it "is listed as pending with the default message when no message is given" do
107
- run_example(:if => true).should be_pending_with(RSpec::Core::Pending::DEFAULT_MESSAGE)
139
+ run_example(:if => true).should be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
108
140
  end
109
141
  end
110
142
 
@@ -128,7 +160,7 @@ describe "an example" do
128
160
  end
129
161
 
130
162
  it "is listed as pending with the default message when no message is given" do
131
- run_example(:unless => false).should be_pending_with(RSpec::Core::Pending::DEFAULT_MESSAGE)
163
+ run_example(:unless => false).should be_pending_with(RSpec::Core::Pending::NO_REASON_GIVEN)
132
164
  end
133
165
  end
134
166
  end
@@ -150,15 +182,15 @@ describe "an example" do
150
182
 
151
183
  context "when given no options" do
152
184
  it "fails with a PendingExampleFixedError" do
153
- run_example("just because").should fail_with(RSpec::Core::PendingExampleFixedError)
154
- run_example.should fail_with(RSpec::Core::PendingExampleFixedError)
185
+ run_example("just because").should fail_with(RSpec::Core::Pending::PendingExampleFixedError)
186
+ run_example.should fail_with(RSpec::Core::Pending::PendingExampleFixedError)
155
187
  end
156
188
  end
157
189
 
158
190
  context "when given a truthy :if option" do
159
191
  it "fails with a PendingExampleFixedError" do
160
- run_example("just because", :if => true).should fail_with(RSpec::Core::PendingExampleFixedError)
161
- run_example( :if => true).should fail_with(RSpec::Core::PendingExampleFixedError)
192
+ run_example("just because", :if => true).should fail_with(RSpec::Core::Pending::PendingExampleFixedError)
193
+ run_example( :if => true).should fail_with(RSpec::Core::Pending::PendingExampleFixedError)
162
194
  end
163
195
  end
164
196
 
@@ -178,8 +210,8 @@ describe "an example" do
178
210
 
179
211
  context "when given a falsey :unless option" do
180
212
  it "fails with a PendingExampleFixedError" do
181
- run_example("just because", :unless => false).should fail_with(RSpec::Core::PendingExampleFixedError)
182
- run_example( :unless => false).should fail_with(RSpec::Core::PendingExampleFixedError)
213
+ run_example("just because", :unless => false).should fail_with(RSpec::Core::Pending::PendingExampleFixedError)
214
+ run_example( :unless => false).should fail_with(RSpec::Core::Pending::PendingExampleFixedError)
183
215
  end
184
216
  end
185
217
  end
@@ -0,0 +1,130 @@
1
+ require "spec_helper"
2
+
3
+ module RSpec::Core
4
+ describe ProjectInitializer, :fakefs do
5
+ describe "#run" do
6
+ context "with no args" do
7
+ let(:command_line_config) { ProjectInitializer.new }
8
+
9
+ before do
10
+ command_line_config.stub(:warn)
11
+ command_line_config.stub(:puts)
12
+ command_line_config.stub(:gets => 'no')
13
+ end
14
+
15
+ context "with no .rspec file" do
16
+ it "says it's creating .rspec " do
17
+ command_line_config.should_receive(:puts).with(/create\s+\.rspec/)
18
+ command_line_config.run
19
+ end
20
+
21
+ it "generates a .rspec" do
22
+ command_line_config.run
23
+ File.read('.rspec').should eq('')
24
+ end
25
+ end
26
+
27
+ context "with a .rspec file" do
28
+ it "says .rspec exists" do
29
+ FileUtils.touch('.rspec')
30
+ command_line_config.should_receive(:puts).with(/exist\s+\.rspec/)
31
+ command_line_config.run
32
+ end
33
+
34
+ it "doesn't create a new one" do
35
+ File.open('.rspec', 'w') {|f| f << '--color'}
36
+ command_line_config.run
37
+ File.read('.rspec').should eq('--color')
38
+ end
39
+ end
40
+
41
+ context "with no spec/spec_helper.rb file" do
42
+ it "says it's creating spec/spec_helper.rb " do
43
+ command_line_config.should_receive(:puts).with(/create\s+spec\/spec_helper.rb/)
44
+ command_line_config.run
45
+ end
46
+
47
+ it "generates a spec/spec_helper.rb" do
48
+ command_line_config.run
49
+ File.read('spec/spec_helper.rb').should eq('')
50
+ end
51
+ end
52
+
53
+ context "with a spec/spec_helper.rb file" do
54
+ before { FileUtils.mkdir('spec') }
55
+
56
+ it "says spec/spec_helper.rb exists" do
57
+ FileUtils.touch('spec/spec_helper.rb')
58
+ command_line_config.should_receive(:puts).with(/exist\s+spec\/spec_helper.rb/)
59
+ command_line_config.run
60
+ end
61
+
62
+ it "doesn't create a new one" do
63
+ random_content = "content #{rand}"
64
+ File.open('spec/spec_helper.rb', 'w') {|f| f << random_content}
65
+ command_line_config.run
66
+ File.read('spec/spec_helper.rb').should eq(random_content)
67
+ end
68
+ end
69
+
70
+ context "with autotest/discover.rb" do
71
+ before do
72
+ FileUtils.mkdir('autotest')
73
+ FileUtils.touch 'autotest/discover.rb'
74
+ end
75
+
76
+ it "asks whether to delete the file" do
77
+ command_line_config.should_receive(:puts).with(/delete/)
78
+ command_line_config.run
79
+ end
80
+
81
+ it "removes it if confirmed" do
82
+ command_line_config.stub(:gets => 'yes')
83
+ command_line_config.run
84
+ File.exist?('autotest/discover.rb').should be_false
85
+ end
86
+
87
+ it "leaves it if not confirmed" do
88
+ command_line_config.stub(:gets => 'no')
89
+ command_line_config.run
90
+ File.exist?('autotest/discover.rb').should be_true
91
+ end
92
+ end
93
+
94
+ context "with lib/tasks/rspec.rake" do
95
+ before do
96
+ FileUtils.mkdir_p('lib/tasks')
97
+ FileUtils.touch 'lib/tasks/rspec.rake'
98
+ end
99
+
100
+ it "asks whether to delete the file" do
101
+ command_line_config.should_receive(:puts).with(/delete/)
102
+ command_line_config.run
103
+ end
104
+
105
+ it "removes it if confirmed" do
106
+ command_line_config.stub(:gets => 'yes')
107
+ command_line_config.run
108
+ File.exist?('lib/tasks/rspec.rake').should be_false
109
+ end
110
+
111
+ it "leaves it if not confirmed" do
112
+ command_line_config.stub(:gets => 'no')
113
+ command_line_config.run
114
+ File.exist?('lib/tasks/rspec.rake').should be_true
115
+ end
116
+ end
117
+ end
118
+
119
+ context "given an arg" do
120
+ it "warns if arg received (no longer necessary)" do
121
+ config = ProjectInitializer.new("another_arg")
122
+ config.stub(:puts)
123
+ config.stub(:gets => 'no')
124
+ config.should_receive(:warn).with(/no longer.*another_arg was ignored/)
125
+ config.run
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
@@ -75,7 +75,7 @@ module RSpec::Core
75
75
  context "with rcov=false (default)" do
76
76
  it "adds the rspec_opts" do
77
77
  task.rspec_opts = "-Ifoo"
78
- spec_command.should =~ /rspec -Ifoo/
78
+ spec_command.should =~ /rspec.*-Ifoo/
79
79
  end
80
80
  end
81
81
  end
@@ -18,6 +18,7 @@ Spork.prefork do
18
18
  require 'rspec/autorun'
19
19
  require 'autotest/rspec2'
20
20
  require 'aruba/api'
21
+ require 'fakefs/spec_helpers'
21
22
 
22
23
  Dir['./spec/support/**/*.rb'].map {|f| require f}
23
24
 
@@ -78,6 +79,7 @@ Spork.prefork do
78
79
  c.color = !in_editor?
79
80
  c.filter_run :focus
80
81
  c.filter_run :foo
82
+ c.include FakeFS::SpecHelpers, :fakefs
81
83
  c.run_all_when_everything_filtered = true
82
84
  c.filter_run_excluding :ruby => lambda {|version|
83
85
  case version.to_s
@@ -20,16 +20,6 @@ RSpec::Matchers.define :map_specs do |specs|
20
20
  end
21
21
  end
22
22
 
23
- RSpec::Matchers.define :be_pending_with do |message|
24
- match do |example|
25
- example.metadata[:pending] && example.metadata[:execution_result][:pending_message] == message
26
- end
27
-
28
- failure_message_for_should do |example|
29
- "expected example to pending with #{message.inspect}, got #{example.metadata[:execution_result][:pending_message].inspect}"
30
- end
31
- end
32
-
33
23
  RSpec::Matchers.define :fail_with do |exception_klass|
34
24
  match do |example|
35
25
  failure_reason(example, exception_klass).nil?
@@ -70,6 +60,6 @@ RSpec::Matchers.define :pass do
70
60
  end
71
61
 
72
62
  RSpec::Matchers.module_eval do
73
- alias have_failed_with fail_with
74
- alias have_passed pass
63
+ alias_method :have_failed_with, :fail_with
64
+ alias_method :have_passed, :pass
75
65
  end
metadata CHANGED
@@ -1,28 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424215
4
+ hash: 15424209
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 8
9
9
  - 0
10
10
  - rc
11
- - 1
12
- version: 2.8.0.rc1
11
+ - 2
12
+ version: 2.8.0.rc2
13
13
  platform: ruby
14
14
  authors:
15
- - Chad Humphries
15
+ - Steven Baker
16
16
  - David Chelimsky
17
+ - Chad Humphries
17
18
  autorequire:
18
19
  bindir: exe
19
20
  cert_chain: []
20
21
 
21
- date: 2011-11-06 00:00:00 Z
22
+ date: 2011-12-20 00:00:00 Z
22
23
  dependencies: []
23
24
 
24
25
  description: BDD for Ruby. RSpec runner and example groups.
25
- email: rspec-users@rubyforge.org;
26
+ email: rspec-users@rubyforge.org
26
27
  executables:
27
28
  - autospec
28
29
  - rspec
@@ -30,6 +31,7 @@ extensions: []
30
31
 
31
32
  extra_rdoc_files:
32
33
  - README.md
34
+ - License.txt
33
35
  files:
34
36
  - lib/autotest/discover.rb
35
37
  - lib/autotest/rspec2.rb
@@ -37,14 +39,12 @@ files:
37
39
  - lib/rspec/core.rb
38
40
  - lib/rspec/core/backward_compatibility.rb
39
41
  - lib/rspec/core/command_line.rb
40
- - lib/rspec/core/command_line_configuration.rb
41
42
  - lib/rspec/core/configuration.rb
42
43
  - lib/rspec/core/configuration_options.rb
43
44
  - lib/rspec/core/deprecation.rb
44
45
  - lib/rspec/core/drb_command_line.rb
45
46
  - lib/rspec/core/drb_options.rb
46
47
  - lib/rspec/core/dsl.rb
47
- - lib/rspec/core/errors.rb
48
48
  - lib/rspec/core/example.rb
49
49
  - lib/rspec/core/example_group.rb
50
50
  - lib/rspec/core/extensions.rb
@@ -73,6 +73,7 @@ files:
73
73
  - lib/rspec/core/mocking/with_rspec.rb
74
74
  - lib/rspec/core/option_parser.rb
75
75
  - lib/rspec/core/pending.rb
76
+ - lib/rspec/core/project_initializer.rb
76
77
  - lib/rspec/core/rake_task.rb
77
78
  - lib/rspec/core/reporter.rb
78
79
  - lib/rspec/core/ruby_project.rb
@@ -84,15 +85,16 @@ files:
84
85
  - lib/rspec/core/world.rb
85
86
  - lib/rspec/monkey.rb
86
87
  - lib/rspec/monkey/spork/test_framework/rspec.rb
88
+ - License.txt
87
89
  - README.md
88
90
  - features/Autotest.md
89
91
  - features/README.md
90
92
  - features/Upgrade.md
91
93
  - features/command_line/README.md
92
- - features/command_line/configure.feature
93
94
  - features/command_line/example_name_option.feature
94
95
  - features/command_line/exit_status.feature
95
96
  - features/command_line/format_option.feature
97
+ - features/command_line/init.feature
96
98
  - features/command_line/line_number_appended_to_path.feature
97
99
  - features/command_line/line_number_option.feature
98
100
  - features/command_line/order.feature
@@ -141,7 +143,6 @@ files:
141
143
  - spec/autotest/failed_results_re_spec.rb
142
144
  - spec/autotest/rspec_spec.rb
143
145
  - spec/command_line/order_spec.rb
144
- - spec/rspec/core/command_line_configuration_spec.rb
145
146
  - spec/rspec/core/command_line_spec.rb
146
147
  - spec/rspec/core/command_line_spec_output.txt
147
148
  - spec/rspec/core/configuration_options_spec.rb
@@ -175,6 +176,7 @@ files:
175
176
  - spec/rspec/core/metadata_spec.rb
176
177
  - spec/rspec/core/option_parser_spec.rb
177
178
  - spec/rspec/core/pending_example_spec.rb
179
+ - spec/rspec/core/project_initializer_spec.rb
178
180
  - spec/rspec/core/rake_task_spec.rb
179
181
  - spec/rspec/core/reporter_spec.rb
180
182
  - spec/rspec/core/resources/a_bar.rb
@@ -198,9 +200,9 @@ files:
198
200
  - spec/support/spec_files.rb
199
201
  - exe/autospec
200
202
  - exe/rspec
201
- homepage: http://github.com/rspec
202
- licenses: []
203
-
203
+ homepage: http://github.com/rspec/rspec-core
204
+ licenses:
205
+ - MIT
204
206
  post_install_message:
205
207
  rdoc_options:
206
208
  - --charset=UTF-8
@@ -232,16 +234,16 @@ rubyforge_project: rspec
232
234
  rubygems_version: 1.8.11
233
235
  signing_key:
234
236
  specification_version: 3
235
- summary: rspec-core-2.8.0.rc1
237
+ summary: rspec-core-2.8.0.rc2
236
238
  test_files:
237
239
  - features/Autotest.md
238
240
  - features/README.md
239
241
  - features/Upgrade.md
240
242
  - features/command_line/README.md
241
- - features/command_line/configure.feature
242
243
  - features/command_line/example_name_option.feature
243
244
  - features/command_line/exit_status.feature
244
245
  - features/command_line/format_option.feature
246
+ - features/command_line/init.feature
245
247
  - features/command_line/line_number_appended_to_path.feature
246
248
  - features/command_line/line_number_option.feature
247
249
  - features/command_line/order.feature
@@ -290,7 +292,6 @@ test_files:
290
292
  - spec/autotest/failed_results_re_spec.rb
291
293
  - spec/autotest/rspec_spec.rb
292
294
  - spec/command_line/order_spec.rb
293
- - spec/rspec/core/command_line_configuration_spec.rb
294
295
  - spec/rspec/core/command_line_spec.rb
295
296
  - spec/rspec/core/command_line_spec_output.txt
296
297
  - spec/rspec/core/configuration_options_spec.rb
@@ -324,6 +325,7 @@ test_files:
324
325
  - spec/rspec/core/metadata_spec.rb
325
326
  - spec/rspec/core/option_parser_spec.rb
326
327
  - spec/rspec/core/pending_example_spec.rb
328
+ - spec/rspec/core/project_initializer_spec.rb
327
329
  - spec/rspec/core/rake_task_spec.rb
328
330
  - spec/rspec/core/reporter_spec.rb
329
331
  - spec/rspec/core/resources/a_bar.rb