rspec 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,4 +1,13 @@
1
- = RSpec Changelog
1
+ == Version 1.0.3
2
+ Bug fixes.
3
+
4
+ * Fixed [#11104] Website uses old specify notation
5
+ * Applied [#11101] StringHelpers.starts_with?(prefix) assumes a string parameter for _prefix_
6
+ * Removed 'rescue nil' which was hiding errors in controller examples.
7
+ * Fixed [#11075] controller specs fail when using mocha without integrated_views
8
+ * Fixed problem with redirect_to failing incorrectly against edge rails.
9
+ * Fixed [#11082] RspecResourceGenerator should be RspecScaffoldGenerator
10
+ * Fixed [#10959] Focused Examples do not work for Behaviour defined with constant with modules
2
11
 
3
12
  == Version 1.0.2
4
13
  This is just to align the version numbers in rspec and rspec_on_rails.
@@ -38,6 +47,7 @@ backwards compatibility changes in the API are expected after this release.
38
47
  * Fixed [#10747] Helper methods defined in shared specs are not visible when shared spec is used
39
48
  * Fixed [#10748] Shared descriptions in separate files causes 'already exists' error
40
49
  * Applied [#10698] Running with --drb executes specs twice (patch from Ruy Asan)
50
+ * Fixed [#10871] 0.9.4 - Focussed spec runner fails to run specs in descriptions with type and string when there is no leading space in the string
41
51
 
42
52
  == Version 0.9.4
43
53
  This release introduces massive improvements to Spec::Ui - the user interface functional testing
@@ -103,6 +103,6 @@
103
103
  # * RSpec should be able to access TestCase methods
104
104
  # * RSpec should be able to accept included modules
105
105
 
106
- Finished in 0.026261 seconds
106
+ Finished in 0.024365 seconds
107
107
 
108
108
  77 examples, 0 failures, 2 not implemented
data/Rakefile CHANGED
@@ -156,10 +156,19 @@ desc "Creates a tag in svn"
156
156
  task :tag do
157
157
  from = `svn info #{File.dirname(__FILE__)}`.match(/URL: (.*)\/rspec/n)[1]
158
158
  to = from.gsub(/trunk/, "tags/#{Spec::VERSION::TAG}")
159
+ current = from.gsub(/trunk/, "tags/CURRENT")
159
160
  tag_cmd = "svn cp #{from} #{to} -m \"Tag release #{Spec::VERSION::FULL_VERSION}\""
161
+ remove_current_cmd = "svn rm #{current}"
162
+ commit_current_cmd = "svn ci #{current} -m \"Remove tags/CURRENT\""
163
+ create_current_cmd = "svn cp #{to} #{current} -m \"Copy #{Spec::VERSION::TAG} to tags/CURRENT\""
160
164
  raise "Can't tag to the same place: #{tag_cmd}" if to == from
161
165
  puts "Creating tag in SVN"
162
166
  `#{tag_cmd}`
167
+ puts "Removing CURRENT"
168
+ `#{remove_current_cmd}`
169
+ `#{commit_current_cmd}`
170
+ puts "Re-Creating CURRENT"
171
+ `#{create_current_cmd}`
163
172
  raise "Tagging failed" unless $? == 0
164
173
  end
165
174
 
@@ -1,5 +1,6 @@
1
1
  module Spec
2
2
  module DSL
3
+ # See http://rspec.rubyforge.org/documentation/before_and_after.html
3
4
  module BehaviourCallbacks
4
5
  def prepend_before(*args, &block)
5
6
  scope, options = scope_and_options(*args)
@@ -7,12 +7,38 @@ module Spec
7
7
  attr_writer :behaviour
8
8
  attr_accessor :description
9
9
 
10
+ # RSpec runs every example in a new instance of Object, mixing in
11
+ # the behaviour necessary to run examples. Because this behaviour gets
12
+ # mixed in, it can get mixed in to an instance of any class at all.
13
+ #
14
+ # This is something that you would hardly ever use, but there is one
15
+ # common use case for it - inheriting from Test::Unit::TestCase. RSpec's
16
+ # Rails plugin uses this feature to provide access to all of the features
17
+ # that are available for Test::Unit within RSpec examples.
10
18
  def inherit(klass)
11
19
  raise ArgumentError.new("Shared behaviours cannot inherit from classes") if @behaviour.shared?
12
20
  @behaviour_superclass = klass
13
21
  derive_execution_context_class_from_behaviour_superclass
14
22
  end
15
23
 
24
+ # You can pass this one or many modules. Each module will subsequently
25
+ # be included in the each object in which an example is run. Use this
26
+ # to provide global helper methods to your examples.
27
+ #
28
+ # == Example
29
+ #
30
+ # module HelperMethods
31
+ # def helper_method
32
+ # ...
33
+ # end
34
+ # end
35
+ #
36
+ # describe Thing do
37
+ # include HelperMethods
38
+ # it "should do stuff" do
39
+ # helper_method
40
+ # end
41
+ # end
16
42
  def include(*mods)
17
43
  mods.each do |mod|
18
44
  included_modules << mod
@@ -20,6 +46,8 @@ module Spec
20
46
  end
21
47
  end
22
48
 
49
+ # Use this to pull in examples from shared behaviours.
50
+ # See Spec::Runner for information about shared behaviours.
23
51
  def it_should_behave_like(behaviour_description)
24
52
  behaviour = @behaviour.class.find_shared_behaviour(behaviour_description)
25
53
  if behaviour.nil?
@@ -28,7 +56,7 @@ module Spec
28
56
  behaviour.copy_to(self)
29
57
  end
30
58
 
31
- def copy_to(eval_module)
59
+ def copy_to(eval_module) # :nodoc:
32
60
  examples.each { |e| eval_module.examples << e; }
33
61
  before_each_parts.each { |p| eval_module.before_each_parts << p }
34
62
  after_each_parts.each { |p| eval_module.after_each_parts << p }
@@ -39,10 +67,12 @@ module Spec
39
67
  end
40
68
 
41
69
  # :call-seq:
42
- # predicate_matchers[method_on_object] = matcher_name
70
+ # predicate_matchers[matcher_name] = method_on_object
71
+ # predicate_matchers[matcher_name] = [method1_on_object, method2_on_object]
43
72
  #
44
73
  # Dynamically generates a custom matcher that will match
45
- # a predicate on your class.
74
+ # a predicate on your class. RSpec uses this itself to allow you
75
+ # to say File.should exist("path/to/file").
46
76
  #
47
77
  # == Example
48
78
  #
@@ -75,15 +105,18 @@ module Spec
75
105
  end
76
106
  end
77
107
 
108
+ # Creates an instance of Spec::DSL::Example and adds
109
+ # it to a collection of examples of the current behaviour.
78
110
  def it(description=:__generate_description, opts={}, &block)
79
111
  examples << Example.new(description, opts, &block)
80
112
  end
81
113
 
114
+ # Alias for it.
82
115
  def specify(description, opts={}, &block)
83
116
  it(description, opts, &block)
84
117
  end
85
118
 
86
- def methods
119
+ def methods # :nodoc:
87
120
  my_methods = super
88
121
  my_methods |= behaviour_superclass.methods
89
122
  my_methods
@@ -3,21 +3,33 @@ module Spec
3
3
  class ExampleMatcher
4
4
 
5
5
  attr_writer :example_desc
6
- def initialize(context_desc, example_desc=nil)
7
- @context_desc = context_desc
6
+ def initialize(behaviour_desc, example_desc=nil)
7
+ @behaviour_desc = behaviour_desc
8
8
  @example_desc = example_desc
9
9
  end
10
10
 
11
11
  def matches?(specified_examples)
12
12
  specified_examples.each do |specified_example|
13
- return true if specified_example =~ /(^#{context_regexp} #{example_regexp}$|^#{context_regexp}$|^#{example_regexp}$)/
13
+ return true if matches_literal_example?(specified_example) || matches_example_not_considering_modules?(specified_example)
14
14
  end
15
15
  false
16
16
  end
17
17
 
18
18
  private
19
+ def matches_literal_example?(specified_example)
20
+ specified_example =~ /(^#{context_regexp} #{example_regexp}$|^#{context_regexp}$|^#{example_regexp}$)/
21
+ end
22
+
23
+ def matches_example_not_considering_modules?(specified_example)
24
+ specified_example =~ /(^#{context_regexp_not_considering_modules} #{example_regexp}$|^#{context_regexp_not_considering_modules}$|^#{example_regexp}$)/
25
+ end
26
+
19
27
  def context_regexp
20
- Regexp.escape(@context_desc.split('::').last)
28
+ Regexp.escape(@behaviour_desc)
29
+ end
30
+
31
+ def context_regexp_not_considering_modules
32
+ Regexp.escape(@behaviour_desc.split('::').last)
21
33
  end
22
34
 
23
35
  def example_regexp
@@ -2,7 +2,7 @@ module Spec
2
2
  module Expectations
3
3
  module StringHelpers
4
4
  def starts_with?(prefix)
5
- to_s[0..(prefix.length - 1)] == prefix
5
+ to_s[0..(prefix.to_s.length - 1)] == prefix.to_s
6
6
  end
7
7
  end
8
8
  end
@@ -8,7 +8,7 @@ module Spec
8
8
  end
9
9
 
10
10
  def add_behaviour(behaviour)
11
- unless specified_examples.nil? || specified_examples.empty? #|| behaviour.matches?(specified_examples)
11
+ if !specified_examples.nil? && !specified_examples.empty? #&& behaviour.matches?(specified_examples)
12
12
  behaviour.retain_examples_matching!(specified_examples) #if behaviour.matches?(specified_examples)
13
13
  end
14
14
  @behaviours << behaviour if behaviour.number_of_examples != 0 && !behaviour.shared?
@@ -133,7 +133,7 @@ module Spec
133
133
  <meta http-equiv="Pragma" content="no-cache" />
134
134
  <style type="text/css">
135
135
  body {
136
- margin: 0;
136
+ margin: 0;
137
137
  padding: 0;
138
138
  background: #fff;
139
139
  font-size: 80%;
@@ -176,21 +176,21 @@ function moveProgressBar(percentDone) {
176
176
  }
177
177
  function makeRed(element_id) {
178
178
  document.getElementById(element_id).style.background = '#C40D0D';
179
- document.getElementById(element_id).style.color = '#FFFFFF';
179
+ document.getElementById(element_id).style.color = '#FFFFFF';
180
+ }
181
+
182
+ function makeYellow(element_id) {
183
+ if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
184
+ {
185
+ document.getElementById(element_id).style.background = '#FAF834';
186
+ document.getElementById(element_id).style.color = '#000000';
180
187
  }
181
-
182
- function makeYellow(element_id) {
183
- if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
184
- {
185
- document.getElementById(element_id).style.background = '#FAF834';
186
- document.getElementById(element_id).style.color = '#000000';
187
- }
188
- else
189
- {
190
- document.getElementById(element_id).style.background = '#FAF834';
191
- document.getElementById(element_id).style.color = '#000000';
192
- }
188
+ else
189
+ {
190
+ document.getElementById(element_id).style.background = '#FAF834';
191
+ document.getElementById(element_id).style.color = '#000000';
193
192
  }
193
+ }
194
194
  EOF
195
195
  end
196
196
 
@@ -3,11 +3,11 @@ module Spec
3
3
  unless defined? MAJOR
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- TINY = 2
6
+ TINY = 3
7
7
  RELEASE_CANDIDATE = nil
8
-
9
- # RANDOM_TOKEN: 0.378125753552199
10
- REV = "$LastChangedRevision: 2008 $".match(/LastChangedRevision: (\d+)/)[1]
8
+
9
+ # RANDOM_TOKEN: 0.135908585165873
10
+ REV = "$LastChangedRevision: 2035 $".match(/LastChangedRevision: (\d+)/)[1]
11
11
 
12
12
  STRING = [MAJOR, MINOR, TINY].join('.')
13
13
  TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
@@ -2,6 +2,94 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
3
  module Spec
4
4
  module Runner
5
+ describe BehaviourRunner, "#add_behaviour affecting passed in behaviour" do
6
+ before do
7
+ @options = Options.new
8
+ @runner = BehaviourRunner.new(@options)
9
+ class << @runner
10
+ attr_reader :behaviours
11
+ end
12
+
13
+ @behaviour = ::Spec::DSL::Behaviour.new("A Behaviour") do
14
+ it "runs 1" do
15
+ end
16
+ it "runs 2" do
17
+ end
18
+ end
19
+ end
20
+
21
+ it "removes examples not selected from Behaviour when options.examples is set" do
22
+ @options.examples << "A Behaviour runs 1"
23
+
24
+ @behaviour.number_of_examples.should == 2
25
+
26
+ @runner.add_behaviour @behaviour
27
+ @behaviour.number_of_examples.should == 1
28
+ @behaviour.examples.first.send(:description).should == "runs 1"
29
+ end
30
+
31
+ it "keeps all examples when options.examples is nil" do
32
+ @options.examples = nil
33
+ @behaviour.number_of_examples.should == 2
34
+
35
+ @runner.add_behaviour @behaviour
36
+ @behaviour.number_of_examples.should == 2
37
+ @behaviour.examples.collect {|example| example.send(:description) }.should == ['runs 1', 'runs 2']
38
+ end
39
+
40
+ it "keeps all examples when options.examples is empty" do
41
+ @options.examples = []
42
+ @behaviour.number_of_examples.should == 2
43
+
44
+ @runner.add_behaviour @behaviour
45
+ @behaviour.number_of_examples.should == 2
46
+ @behaviour.examples.collect {|example| example.send(:description) }.should == ['runs 1', 'runs 2']
47
+ end
48
+ end
49
+
50
+ describe BehaviourRunner, "#add_behaviour affecting behaviours" do
51
+ before do
52
+ @options = Options.new
53
+ @runner = BehaviourRunner.new(@options)
54
+ class << @runner
55
+ attr_reader :behaviours
56
+ end
57
+ end
58
+
59
+ it "adds behaviour when behaviour has examples and is not shared" do
60
+ @behaviour = ::Spec::DSL::Behaviour.new("A Behaviour") do
61
+ it "uses this behaviour" do
62
+ end
63
+ end
64
+
65
+ @behaviour.should_not be_shared
66
+ @behaviour.number_of_examples.should be > 0
67
+ @runner.add_behaviour @behaviour
68
+
69
+ @runner.behaviours.length.should == 1
70
+ end
71
+
72
+ it "does not add the behaviour when number_of_examples is 0" do
73
+ @behaviour = ::Spec::DSL::Behaviour.new("A Behaviour") do
74
+ end
75
+ @behaviour.number_of_examples.should == 0
76
+ @runner.add_behaviour @behaviour
77
+
78
+ @runner.behaviours.should be_empty
79
+ end
80
+
81
+ it "does not add the behaviour when behaviour is shared" do
82
+ @behaviour = ::Spec::DSL::Behaviour.new("A Behaviour", :shared => true) do
83
+ it "does not use this behaviour" do
84
+ end
85
+ end
86
+ @behaviour.should be_shared
87
+ @runner.add_behaviour @behaviour
88
+
89
+ @runner.behaviours.should be_empty
90
+ end
91
+ end
92
+
5
93
  describe BehaviourRunner do
6
94
 
7
95
  it "should only run behaviours with at least one example" do
@@ -69,14 +69,14 @@ module Spec
69
69
  # matcher.should match_description("with ([#]) an example")
70
70
  # matcher.should match_description("a context with ([#]) an example")
71
71
  # end
72
- #
72
+ #
73
73
  # it "should match with regexp reserved (characters) in the context" do
74
74
  # matcher=ExampleMatcher.new("with an example", "a ([#]) context")
75
75
  # matcher.should match_description("a ([#]) context with an example")
76
76
  # matcher.should match_description("a ([#]) context with an example")
77
77
  # matcher.should match_description("a ([#]) context with an example")
78
78
  # end
79
-
79
+
80
80
  # it "should not match wrong example only" do
81
81
  # matcher=ExampleMatcher.new("with another example", "a context")
82
82
  # matcher.should_not match_description("with an example")
@@ -98,5 +98,30 @@ module Spec
98
98
  # end
99
99
 
100
100
  end
101
+
102
+ describe ExampleMatcher, "normal case" do
103
+ it "matches when passed in example matches" do
104
+ @matcher = ExampleMatcher.new("Foo", "bar")
105
+ @matcher.matches?(["no match", "Foo bar"]).should == true
106
+ end
107
+
108
+ it "does not match when no passed in examples match" do
109
+ @matcher = ExampleMatcher.new("Foo", "bar")
110
+ @matcher.matches?(["no match1", "no match2"]).should == false
111
+ end
112
+ end
113
+
114
+ describe ExampleMatcher, "where description has '::' in it" do
115
+ it "matches when passed in example matches" do
116
+ @matcher = ExampleMatcher.new("Foo::Bar", "baz")
117
+ @matcher.matches?(["no match", "Foo::Bar baz"]).should == true
118
+ end
119
+
120
+ it "does not match when no passed in examples match" do
121
+ @matcher = ExampleMatcher.new("Foo::Bar", "baz")
122
+ @matcher.matches?(["no match1", "no match2"]).should == false
123
+ end
124
+ end
125
+
101
126
  end
102
127
  end
metadata CHANGED
@@ -3,9 +3,9 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: rspec
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2007-05-23 00:00:00 -05:00
8
- summary: RSpec-1.0.2 (r2008) - BDD for Ruby http://rspec.rubyforge.org/
6
+ version: 1.0.3
7
+ date: 2007-05-25 00:00:00 -05:00
8
+ summary: RSpec-1.0.3 (r2035) - BDD for Ruby http://rspec.rubyforge.org/
9
9
  require_paths:
10
10
  - lib
11
11
  email: rspec-devel@rubyforge.org
@@ -176,6 +176,7 @@ files:
176
176
  - spec/spec/runner/command_line_spec.rb
177
177
  - spec/spec/runner/context_matching_spec.rb
178
178
  - spec/spec/runner/drb_command_line_spec.rb
179
+ - spec/spec/runner/example_matcher_spec.rb
179
180
  - spec/spec/runner/execution_context_spec.rb
180
181
  - spec/spec/runner/extensions/kernel_spec.rb
181
182
  - spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb
@@ -197,7 +198,6 @@ files:
197
198
  - spec/spec/runner/options_spec.rb
198
199
  - spec/spec/runner/quiet_backtrace_tweaker_spec.rb
199
200
  - spec/spec/runner/reporter_spec.rb
200
- - spec/spec/runner/spec_matcher_spec.rb
201
201
  - spec/spec/runner/spec_parser_spec.rb
202
202
  - spec/spec/spec_classes.rb
203
203
  - spec/spec/translator_spec.rb