rspec 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,6 +1,25 @@
1
1
  = RSpec Changelog
2
2
 
3
- == Version 0.7.0 (in SVN)
3
+ == Version 0.7.1
4
+
5
+ Bug fixes and a couple o' new features.
6
+
7
+ * Fixed [#6575] Parse error in aliasing the partial mock original method (patch by Brian Takita)
8
+ * Fixed [#6277] debris left by stubbing (trunk) [submitted by dastels] (fixed by fix to [#6575])
9
+ * Fixed [#6575] Parse error in aliasing the partial mock original method
10
+ * Fixed [#6555] should_have_tag does not match documentation
11
+ * Fixed [#6567] SyntaxError should not stop entire run
12
+ * Fixed [#6558] integrated views look for template even when redirected
13
+ * Fixed [#6547] response.should_be_redirect broken in 0.7.0
14
+ * Applied [#6471] Easy way to spec routes
15
+ * Applied [#6587] Rspec on Rails displays "Spec::Rails::ContextFactory" as context name
16
+ * Applied [#6514] Document has trivial typos.
17
+ * Added [#6560] controller.session should be available before the action
18
+ * Added support for should_have_rjs :visual_effect
19
+ * Different printing and colours for unmet expectations (red) and other exceptions (magenta)
20
+ * Simplified method_missing on mock_methods to make it less invasive on partial mocks.
21
+
22
+ == Version 0.7.0
4
23
 
5
24
  This is the "Grow up and eat your own dog food release". RSpec is now used on itself and
6
25
  we're no longer using Test::Unit to test it. Although, we are still extending Test::Unit
@@ -10,7 +29,6 @@ IMPORTANT NOTE: THIS RELEASE IS NOT 100% BACKWARDS COMPATIBLE TO 0.6.x
10
29
 
11
30
  There are a few changes that will require that you change your existing specs.
12
31
 
13
- --------------------------------------------------
14
32
  RSpec now handles equality exactly like ruby does:
15
33
 
16
34
  # actual.should_equal(expected) will pass if actual.equal?(expected) returns true
@@ -35,8 +53,8 @@ used to pass for any non-nil, non-false value), and actual.should_be false will
35
53
  value other than false (it used to pass for nil or false).
36
54
 
37
55
  Here's what you'll need to do to update your specs:
38
- * search for "should_equal" and replace with "should_eql"
39
- * run specs
56
+ # search for "should_equal" and replace with "should_eql"
57
+ # run specs
40
58
 
41
59
  If any specs still fail, they are probably related to should_be(true) or should_be(false) using
42
60
  non-boolean values. Those you'll just have to inspect manually and adjust appropriately (sorry!).
@@ -53,15 +71,15 @@ mock.should_receive(:message).and_return([1,2,3])
53
71
  but we decided that was counter intuitive and otherwise lame.
54
72
 
55
73
  Here's what you'll need to do to update your specs:
56
- * search for "and_return(["
57
- * get rid of the "[" and "]"
74
+ # search for "and_return(["
75
+ # get rid of the "[" and "]"
58
76
 
59
77
  --------------------------------------------------
60
78
  RSpec on Rails now supports the following (thanks to ZenTest upon which it is built):
61
79
 
62
- * Separate specs for models, views, controllers and helpers
63
- * Controller specs are completely decoupled from the views by default (though you can tell them to couple themselves if you prefer)
64
- * View specs are completely decoupled from app-specific controllers
80
+ # Separate specs for models, views, controllers and helpers
81
+ # Controller specs are completely decoupled from the views by default (though you can tell them to couple themselves if you prefer)
82
+ # View specs are completely decoupled from app-specific controllers
65
83
 
66
84
  See http://rspec.rubyforge.org/documentation/rails/index.html for more information
67
85
  --------------------------------------------------
data/Rakefile CHANGED
@@ -24,6 +24,7 @@ PKG_FILES = FileList[
24
24
  'vendor/watir/*.rb',
25
25
  'vendor/watir/*.txt',
26
26
  'vendor/selenium/*.rb',
27
+ 'vendor/selenium/*.patch',
27
28
  'vendor/selenium/*.txt'
28
29
  ]
29
30
 
@@ -35,7 +36,7 @@ Spec::Rake::SpecTask.new do |t|
35
36
  t.spec_opts = ['--diff','--color','--backtrace']
36
37
  t.rcov = true
37
38
  t.rcov_dir = 'doc/output/coverage'
38
- t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec']
39
+ t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,examples']
39
40
  end
40
41
 
41
42
  desc "Run all failing examples"
@@ -188,8 +189,12 @@ task :pre_commit => [
188
189
 
189
190
  task :rails_pre_commit do
190
191
  Dir.chdir 'vendor/rspec_on_rails' do
191
- `rake pre_commit --verbose`
192
- raise "RSpec on Rails pre_commit failed\n(cd to vendor/rspec_on_rails and run rake pre_commit for more details)" if $? != 0
192
+ IO.popen("rake pre_commit --verbose") do |io|
193
+ io.each do |line|
194
+ puts line
195
+ end
196
+ end
197
+ raise "RSpec on Rails pre_commit failed" if $? != 0
193
198
  end
194
199
  end
195
200
 
data/bin/spec CHANGED
@@ -1,19 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH.push File.dirname(__FILE__) + "/../lib"
3
3
  require File.expand_path(File.dirname(__FILE__) + "/../lib/spec") # better stack traces this way
4
-
5
- $context_runner = ::Spec::Runner::OptionParser.create_context_runner(ARGV, false, STDERR, STDOUT)
6
-
7
- # If ARGV is a glob, it will actually each over each one of the matching files.
8
- ARGV.each do |file_or_dir|
9
- if File.directory?(file_or_dir)
10
- Dir["#{file_or_dir}/**/*.rb"].each do |file|
11
- require file
12
- end
13
- else
14
- require file_or_dir
15
- end
16
- end
17
-
18
- $context_runner.run(true)
4
+ ::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
19
5
 
@@ -1,4 +1,4 @@
1
1
  require 'spec/version'
2
2
  require 'spec/expectations'
3
3
  require 'spec/mocks'
4
- require 'spec/runner'
4
+ require 'spec/runner'
@@ -1,9 +1,9 @@
1
1
  module Spec
2
2
  module Mocks
3
- class MockExpectationError < StandardError
3
+ class MockExpectationError < Expectations::ExpectationNotMetError
4
4
  end
5
5
 
6
- class AmbiguousReturnError < StandardError
6
+ class AmbiguousReturnError < Expectations::ExpectationNotMetError
7
7
  end
8
8
  end
9
9
  end
@@ -10,6 +10,17 @@ module Spec
10
10
  @name = name
11
11
  @options = options
12
12
  end
13
+
14
+ def method_missing(sym, *args, &block)
15
+ __mock_handler.instance_eval {@messages_received << [sym, args, block]}
16
+ begin
17
+ return self if __mock_handler.null_object?
18
+ super(sym, *args, &block)
19
+ rescue NoMethodError
20
+ __mock_handler.raise_unexpected_message_error sym, *args
21
+ end
22
+ end
23
+
13
24
  end
14
25
  end
15
26
  end
@@ -9,7 +9,7 @@ module Spec
9
9
  @expectations = []
10
10
  @messages_received = []
11
11
  @stubs = []
12
- @proxied_methods = []
12
+ @proxied_methods = {}
13
13
  @options = options ? DEFAULT_OPTIONS.dup.merge(options) : DEFAULT_OPTIONS
14
14
  end
15
15
 
@@ -17,44 +17,41 @@ module Spec
17
17
  :null_object => false,
18
18
  :auto_verify => true
19
19
  }
20
-
20
+
21
21
  def null_object?
22
22
  @options[:null_object]
23
23
  end
24
-
24
+
25
25
  def add_message_expectation(expected_from, sym, opts={}, &block)
26
26
  __add expected_from, sym, block
27
27
  @expectations << MessageExpectation.new(@error_generator, @expectation_ordering, expected_from, sym, block_given? ? block : nil, 1, opts)
28
28
  @expectations.last
29
29
  end
30
-
30
+
31
31
  def add_negative_message_expectation(expected_from, sym, &block)
32
32
  __add expected_from, sym, block
33
33
  @expectations << NegativeMessageExpectation.new(@error_generator, @expectation_ordering, expected_from, sym, block_given? ? block : nil)
34
34
  @expectations.last
35
35
  end
36
-
36
+
37
37
  def add_stub(expected_from, sym)
38
38
  __add expected_from, sym, nil
39
39
  @stubs << MethodStub.new(@error_generator, @expectation_ordering, expected_from, sym, nil)
40
40
  @stubs.last
41
41
  end
42
-
42
+
43
43
  def __add expected_from, sym, block
44
44
  Runner::Specification.add_listener(self) if @options[:auto_verify]
45
45
  define_expected_method(sym)
46
46
  end
47
-
47
+
48
48
  def spec_finished spec
49
49
  verify
50
50
  end
51
51
 
52
52
  def define_expected_method(sym)
53
- if @target.respond_to? sym
54
- metaclass_eval %-
55
- alias_method :#{__pre_proxied_method_name(sym)}, :#{sym}
56
- -
57
- @proxied_methods << sym
53
+ if @target.respond_to?(sym) && !@proxied_methods[sym]
54
+ @proxied_methods[sym] = @target.method(sym)
58
55
  end
59
56
 
60
57
  metaclass_eval %-
@@ -64,10 +61,6 @@ module Spec
64
61
  -
65
62
  end
66
63
 
67
- def __pre_proxied_method_name method_name
68
- "original_#{method_name.to_s.delete('!').delete('[').delete('\]')}_before_proxy"
69
- end
70
-
71
64
  def verify #:nodoc:
72
65
  begin
73
66
  verify_expectations
@@ -75,14 +68,14 @@ module Spec
75
68
  reset
76
69
  end
77
70
  end
78
-
71
+
79
72
  def reset
80
73
  clear_expectations
81
74
  clear_stubs
82
75
  reset_proxied_methods
83
76
  clear_proxied_methods
84
77
  end
85
-
78
+
86
79
  def verify_expectations
87
80
  @expectations.each do |expectation|
88
81
  expectation.verify_messages_received
@@ -90,24 +83,25 @@ module Spec
90
83
  end
91
84
 
92
85
  def reset_proxied_methods
93
- @proxied_methods.each do |method_name|
94
- if @target.respond_to? __pre_proxied_method_name(method_name)
95
- metaclass_eval %-
96
- alias_method :#{method_name}, :#{__pre_proxied_method_name(method_name)}
97
- remove_method :#{__pre_proxied_method_name(method_name)}
98
- -
99
- end
100
- end
101
- end
86
+ @proxied_methods.each do |method_name, method_obj|
87
+ define_instance_method(method_name, method_obj)
88
+ end
89
+ end
90
+
91
+ def define_instance_method(method_name, method_obj)
92
+ (class << @target; self; end).class_eval do
93
+ define_method method_name, &method_obj
94
+ end
95
+ end
102
96
 
103
97
  def clear_expectations #:nodoc:
104
98
  @expectations.clear
105
99
  end
106
-
100
+
107
101
  def clear_stubs #:nodoc:
108
102
  @stubs.clear
109
103
  end
110
-
104
+
111
105
  def clear_proxied_methods #:nodoc:
112
106
  @proxied_methods.clear
113
107
  end
@@ -115,7 +109,7 @@ module Spec
115
109
  def metaclass_eval str
116
110
  (class << @target; self; end).class_eval str
117
111
  end
118
-
112
+
119
113
  def received_message?(sym, *args, &block)
120
114
  return true if @messages_received.find {|array| array == [sym, args, block]}
121
115
  return false
@@ -124,19 +118,19 @@ module Spec
124
118
  def find_matching_expectation(sym, *args)
125
119
  @expectations.find {|expectation| expectation.matches(sym, args)}
126
120
  end
127
-
121
+
128
122
  def find_almost_matching_expectation(sym, *args)
129
123
  @expectations.find {|expectation| expectation.matches_name_but_not_args(sym, args)}
130
124
  end
131
-
125
+
132
126
  def find_matching_method_stub(sym)
133
127
  @stubs.find {|stub| stub.matches(sym, [])}
134
128
  end
135
-
129
+
136
130
  def has_negative_expectation?(sym)
137
131
  @expectations.detect {|expectation| expectation.negative_expectation_for?(sym)}
138
132
  end
139
-
133
+
140
134
  def message_received(sym, *args, &block)
141
135
  if expectation = find_matching_expectation(sym, *args)
142
136
  expectation.invoke(args, block)
@@ -148,11 +142,11 @@ module Spec
148
142
  @target.send :method_missing, sym, *args, &block
149
143
  end
150
144
  end
151
-
145
+
152
146
  def raise_unexpected_message_error sym, *args
153
147
  @error_generator.raise_unexpected_message_error sym, *args
154
148
  end
155
-
149
+
156
150
  end
157
151
  end
158
152
  end
@@ -27,15 +27,11 @@ module Spec
27
27
 
28
28
  def method_missing(sym, *args, &block)
29
29
  __mock_handler.instance_eval {@messages_received << [sym, args, block]}
30
- begin
31
- return self if __mock_handler.null_object?
32
- super(sym, *args, &block)
33
- rescue NoMethodError
34
- __mock_handler.raise_unexpected_message_error sym, *args
35
- end
30
+ super(sym, *args, &block)
36
31
  end
37
32
 
38
33
  private
34
+
39
35
  def __mock_handler
40
36
  @mock_handler ||= MockHandler.new(self, @name, @options)
41
37
  end
@@ -5,6 +5,7 @@ require 'spec/runner/specification'
5
5
  require 'spec/runner/execution_context'
6
6
  require 'spec/runner/context_runner'
7
7
  require 'spec/runner/option_parser'
8
+ require 'spec/runner/command_line'
8
9
  require 'spec/runner/backtrace_tweaker'
9
10
  require 'spec/runner/reporter'
10
11
  require 'spec/runner/spec_matcher'
@@ -1,13 +1,10 @@
1
1
  module Spec
2
2
  module Runner
3
- class BacktraceTweaker
3
+ class NoisyBacktraceTweaker
4
4
  def tweak_instance_exec_line line, spec_name
5
5
  line = line.split(':in')[0] + ":in `#{spec_name}'" if line.include?('__instance_exec')
6
6
  line
7
7
  end
8
- end
9
-
10
- class NoisyBacktraceTweaker < BacktraceTweaker
11
8
  def tweak_backtrace(error, spec_name)
12
9
  return if error.backtrace.nil?
13
10
  error.backtrace.collect! do |line|
@@ -18,24 +15,28 @@ module Spec
18
15
  end
19
16
 
20
17
  # Tweaks raised Exceptions to mask noisy (unneeded) parts of the backtrace
21
- class QuietBacktraceTweaker < BacktraceTweaker
18
+ class QuietBacktraceTweaker
19
+ def tweak_instance_exec_line line, spec_name
20
+ line = line.split(':in')[0] if line.include?('__instance_exec')
21
+ line
22
+ end
22
23
  def tweak_backtrace(error, spec_name)
23
24
  return if error.backtrace.nil?
24
25
  error.backtrace.collect! do |line|
25
26
  line = tweak_instance_exec_line line, spec_name
26
27
  line = nil if line =~ /\/lib\/ruby\//
27
28
  line = nil if line =~ /\/lib\/spec\/expectations\//
28
- line = nil if line =~ /\/lib\/spec\/method_proxy\//
29
29
  line = nil if line =~ /\/lib\/spec\/mocks\//
30
30
  line = nil if line =~ /\/lib\/spec\/rake\//
31
31
  line = nil if line =~ /\/lib\/spec\/runner\//
32
- line = nil if line =~ /\/lib\/spec\/stubs\//
33
32
  line = nil if line =~ /bin\/spec:/
34
33
  line = nil if line =~ /bin\/rcov:/
35
34
  line = nil if line =~ /lib\/rspec_on_rails/
36
35
  line = nil if line =~ /script\/rails_spec/
37
- # TextMate's Ruby plugin
36
+ # TextMate's Ruby and RSpec plugins
38
37
  line = nil if line =~ /Ruby\.tmbundle\/Support\/tmruby.rb:/
38
+ line = nil if line =~ /RSpec\.tmbundle\/Support\/lib/
39
+ line = nil if line =~ /temp_textmate\./
39
40
  line
40
41
  end
41
42
  error.backtrace.compact!
@@ -0,0 +1,31 @@
1
+ module Spec
2
+ module Runner
3
+ # Facade to run specs without having to fork a new ruby process (using `spec ...`)
4
+ class CommandLine
5
+ # Runs specs. +argv+ is the commandline args as per the spec commandline API, +stderr+
6
+ # and +stdiout+ are the streams output will be written to, +exit+ tells whether or
7
+ # not a system exit should be called after the specs are run and
8
+ # +warn_if_no_files+ tells whether or not a warning (the help message)
9
+ # should be printed to +stderr+ in case no files are specified.
10
+ def self.run(argv, stderr, stdout, exit, warn_if_no_files)
11
+ old_context_runner = defined?($context_runner) ? $context_runner : nil
12
+ $context_runner = OptionParser.create_context_runner(argv, stderr, stdout, warn_if_no_files)
13
+
14
+ # If ARGV is a glob, it will actually each over each one of the matching files.
15
+ argv.each do |file_or_dir|
16
+ if File.directory?(file_or_dir)
17
+ Dir["#{file_or_dir}/**/*.rb"].each do |file|
18
+ load file
19
+ end
20
+ elsif File.file?(file_or_dir)
21
+ load file_or_dir
22
+ else
23
+ raise "File or directory not found: #{file_or_dir}"
24
+ end
25
+ end
26
+ $context_runner.run(exit)
27
+ $context_runner = old_context_runner
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,12 +3,10 @@ require File.dirname(__FILE__) + '/../../spec'
3
3
  module Spec
4
4
  module Runner
5
5
  class ContextRunner
6
- attr_reader :standalone
7
6
 
8
- def initialize(reporter, standalone, dry_run, single_spec=nil)
7
+ def initialize(reporter, dry_run, single_spec=nil)
9
8
  @contexts = []
10
9
  @reporter = reporter
11
- @standalone = standalone
12
10
  @dry_run = dry_run
13
11
  @single_spec = single_spec
14
12
  end
@@ -1,14 +1,13 @@
1
1
  module Kernel
2
2
  def context(name, &block)
3
3
  context = Spec::Runner::Context.new(name, &block)
4
- runner = context_runner
5
- runner.add_context(context)
4
+ context_runner.add_context(context)
6
5
  end
7
6
 
8
7
  private
9
8
 
10
9
  def context_runner
11
- if $context_runner.nil?; $context_runner = ::Spec::Runner::OptionParser.create_context_runner(ARGV.dup, true, STDERR, STDOUT); at_exit { $context_runner.run(false) }; end
10
+ if $context_runner.nil?; $context_runner = ::Spec::Runner::OptionParser.create_context_runner(ARGV.dup, STDERR, STDOUT, false); at_exit { $context_runner.run(false) }; end
12
11
  $context_runner
13
12
  end
14
13
  end
@@ -59,8 +59,13 @@ module Spec
59
59
  def dump_failure(counter, failure)
60
60
  @output.puts
61
61
  @output.puts "#{counter.to_s})"
62
- @output.puts failure.header
63
- @output.puts failure.exception.message
62
+ if(failure.expectation_not_met?)
63
+ @output.puts red(failure.header)
64
+ @output.puts red(failure.exception.message)
65
+ else
66
+ @output.puts magenta(failure.header)
67
+ @output.puts magenta(failure.exception.message)
68
+ end
64
69
  @output.puts failure.exception.backtrace.join("\n")
65
70
  STDOUT.flush
66
71
  end
@@ -88,6 +93,7 @@ module Spec
88
93
 
89
94
  def red(text); colour(text, "\e[31m"); end
90
95
  def green(text); colour(text, "\e[32m"); end
96
+ def magenta(text); colour(text, "\e[35m"); end
91
97
 
92
98
  def format_backtrace(backtrace)
93
99
  backtrace.nil? ? "" : backtrace.join("\n")
@@ -20,8 +20,8 @@ module Spec
20
20
  @output.puts "</div>"
21
21
  end
22
22
  @output.puts "<div class=\"context\">"
23
- @output.puts " <h2>#{name}</h2>"
24
23
  @output.puts " <ul>"
24
+ @output.puts " <li class=\"context_name\">#{name}</li>"
25
25
  end
26
26
 
27
27
  def start_dump
@@ -36,17 +36,17 @@ module Spec
36
36
  end
37
37
 
38
38
  def spec_passed(name)
39
- @output.puts "<li class=\"spec passed\"><div class=\"name\">#{escape(@current_spec)}</div></li>"
39
+ @output.puts " <li class=\"spec passed\"><div class=\"passed_spec_name\">#{escape(@current_spec)}</div></li>"
40
40
  end
41
41
 
42
42
  def spec_failed(name, counter, failure)
43
- @output.puts "<li class=\"spec failed\">"
44
- @output.puts " <div class=\"name\">#{escape(@current_spec)}</div>"
45
- @output.puts " <div class=\"failure\" id=\"failure_#{counter}\">"
46
- @output.puts " <div class=\"message\"><pre>#{escape(failure.exception.message)}</pre></div>" unless failure.exception.nil?
47
- @output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(failure.exception.backtrace)}</pre></div>" unless failure.exception.nil?
48
- @output.puts " </div>"
49
- @output.puts "</li>"
43
+ @output.puts " <li class=\"spec failed\">"
44
+ @output.puts " <div class=\"failed_spec_name\">#{escape(@current_spec)}</div>"
45
+ @output.puts " <div class=\"failure\" id=\"failure_#{counter}\">"
46
+ @output.puts " <div class=\"message\"><pre>#{escape(failure.exception.message)}</pre></div>" unless failure.exception.nil?
47
+ @output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(failure.exception.backtrace)}</pre></div>" unless failure.exception.nil?
48
+ @output.puts " </div>"
49
+ @output.puts " </li>"
50
50
  STDOUT.flush
51
51
  end
52
52
 
@@ -58,8 +58,8 @@ module Spec
58
58
  end
59
59
 
60
60
  def dump_summary(duration, spec_count, failure_count)
61
- @output.print "</body>"
62
- @output.print "</html>"
61
+ @output.puts "</body>"
62
+ @output.puts "</html>"
63
63
  STDOUT.flush
64
64
  end
65
65
 
@@ -76,15 +76,11 @@ module Spec
76
76
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
77
77
  <style type="text/css">
78
78
  body {
79
- font-size: 10pt;
80
- font: "lucida grande";
79
+ font-size: 9pt;
80
+ font-family: verdana, arial, helvetica;
81
81
  width: 85%;
82
82
  }
83
83
 
84
- h2 {
85
- color: #589CCF;
86
- }
87
-
88
84
  div.context {
89
85
  padding: 0px;
90
86
  background: #fff;
@@ -98,23 +94,36 @@ module Spec
98
94
  li {
99
95
  list-style-type: none;
100
96
  margin: 0;
101
- border: 2px solid #fff;
97
+ border: 1px solid #fff;
98
+ }
99
+
100
+ li.context_name {
101
+ font-size: 1.3em;
102
+ font-weight: bold;
103
+ color: #589CCF;
104
+ }
105
+
106
+ div.passed_spec_name {
107
+ font-weight: bold;
108
+ color: #324F17;
109
+ }
110
+
111
+ div.failed_spec_name {
112
+ font-weight: bold;
113
+ color: #EEB4B4;
102
114
  }
103
115
 
104
116
  li.passed {
105
117
  display: block;
106
- background: #46A002;
107
- color: #fff;
108
- padding: 2px 4px;
109
- font-weight: bold
118
+ background: #659D32;
119
+ padding: 1px 4px;
110
120
  }
111
121
 
112
122
  li.failed {
113
123
  display: block;
114
- background: red;
115
- color: #fff;
124
+ background: #CD0000;
125
+ color: #000;
116
126
  padding: 2px 4px;
117
- font-weight: bold
118
127
  }
119
128
 
120
129
  li.failed .failure {
@@ -8,7 +8,7 @@ module Spec
8
8
  end
9
9
 
10
10
  def spec_failed(name, counter, failure)
11
- @output.print red('F')
11
+ @output.print failure.expectation_not_met? ? red('F') : magenta('F')
12
12
  STDOUT.flush
13
13
  end
14
14
 
@@ -9,7 +9,7 @@ module Spec
9
9
  end
10
10
 
11
11
  def spec_failed(name, counter, failure)
12
- @output.print red("- #{name} (FAILED - #{counter})\n")
12
+ @output.puts failure.expectation_not_met? ? red("- #{name} (FAILED - #{counter})") : magenta("- #{name} (ERROR - #{counter})")
13
13
  STDOUT.flush
14
14
  end
15
15
 
@@ -5,8 +5,8 @@ module Spec
5
5
  module Runner
6
6
  class OptionParser
7
7
 
8
- def self.create_context_runner(args, standalone, err, out=STDOUT)
9
- options = parse(args, standalone, err, out)
8
+ def self.create_context_runner(args, err, out, warn_if_no_files)
9
+ options = parse(args, err, out, warn_if_no_files)
10
10
 
11
11
  formatter = options.formatter_type.new(options.out, options.dry_run, options.colour)
12
12
  reporter = Reporter.new(formatter, options.backtrace_tweaker)
@@ -17,10 +17,10 @@ module Spec
17
17
  Spec::Expectations::Should::Base.differ = options.differ_class.new(options.diff_format, options.context_lines, options.colour)
18
18
  end
19
19
 
20
- ContextRunner.new(reporter, standalone, options.dry_run, options.spec_name)
20
+ ContextRunner.new(reporter, options.dry_run, options.spec_name)
21
21
  end
22
22
 
23
- def self.parse(args, standalone, err, out)
23
+ def self.parse(args, err, out, warn_if_no_files)
24
24
  options = OpenStruct.new
25
25
  options.out = out == STDOUT ? Kernel : out
26
26
  options.formatter_type = Formatter::ProgressBarFormatter
@@ -120,9 +120,9 @@ module Spec
120
120
  end
121
121
  opts.parse!(args)
122
122
 
123
- if args.empty?
124
- err.puts opts unless standalone
125
- exit if err == $stderr unless standalone
123
+ if args.empty? && warn_if_no_files
124
+ err.puts opts
125
+ exit if err == $stderr
126
126
  end
127
127
 
128
128
  options
@@ -83,7 +83,15 @@ module Spec
83
83
  end
84
84
 
85
85
  def header
86
- "#{@exception.class.name} in '#{@context_name} #{@spec_name}'"
86
+ if expectation_not_met?
87
+ "'#{@context_name} #{@spec_name}' FAILED"
88
+ else
89
+ "#{@exception.class.name} in '#{@context_name} #{@spec_name}'"
90
+ end
91
+ end
92
+
93
+ def expectation_not_met?
94
+ @exception.is_a?(Spec::Expectations::ExpectationNotMetError)
87
95
  end
88
96
 
89
97
  end
@@ -3,9 +3,9 @@ module Spec
3
3
  unless defined? MAJOR
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- TINY = 0
7
- # RANDOM_TOKEN: 0.846310547367564
8
- REV = "$LastChangedRevision: 1039 $".match(/LastChangedRevision: (\d+)/)[1]
6
+ TINY = 1
7
+ # RANDOM_TOKEN: 0.75692472177863
8
+ REV = "$LastChangedRevision: 1080 $".match(/LastChangedRevision: (\d+)/)[1]
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY].join('.')
11
11
  FULL_VERSION = "#{STRING} (r#{REV})"
@@ -0,0 +1,65 @@
1
+ Index: find_rspecs_home_page.rb
2
+ ===================================================================
3
+ --- find_rspecs_home_page.rb (revision 767)
4
+ +++ find_rspecs_home_page.rb (working copy)
5
+ @@ -2,22 +2,18 @@
6
+
7
+ context "Google's search page" do
8
+
9
+ - setup do
10
+ - @browser = Selenium::SeleneseInterpreter.new("localhost", 4444, "*firefox", "http://www.google.no", 10000)
11
+ - @browser.start
12
+ - @browser.open('http://www.google.no')
13
+ - end
14
+ -
15
+ specify "should find rspec's home page when I search for rspec" do
16
+ - @browser.type "name=q", "rspec"
17
+ - @browser.click_and_wait "name=btnG"
18
+ - @browser.is_text_present("rspec.rubyforge.org").should_be(true)
19
+ + browser.open('http://www.google.no')
20
+ + browser.type "name=q", "rspec"
21
+ + browser.click_and_wait "name=btnG"
22
+ + browser.is_text_present("rspec.rubyforge.org").should_be(true)
23
+ end
24
+
25
+ specify "should not find Ali G when I search for rspec" do
26
+ - @browser.type "name=q", "rspec"
27
+ - @browser.click_and_wait "name=btnG"
28
+ - @browser.is_text_present("Ali G").should_be(false)
29
+ + browser.open('http://www.google.no')
30
+ + browser.type "name=q", "rspec"
31
+ + browser.click_and_wait "name=btnG"
32
+ + browser.is_text_present("Ali G").should_be(false)
33
+ end
34
+
35
+ end
36
+
37
+ Index: rspec_selenium.rb
38
+ ===================================================================
39
+ --- rspec_selenium.rb (revision 767)
40
+ +++ rspec_selenium.rb (working copy)
41
+ @@ -3,10 +3,22 @@
42
+ require File.dirname(__FILE__) + '/selenium'
43
+
44
+ class RSpecSelenium
45
+ - def teardown
46
+ - @browser.stop
47
+ + def setup
48
+ + unless defined?@@browser
49
+ + @@browser = Selenium::SeleneseInterpreter.new("localhost", 4444, "*firefox", "http://www.google.no", 10000)
50
+ + @@browser.start
51
+ + end
52
+ end
53
+ +
54
+ + def browser
55
+ + @@browser
56
+ + end
57
+ +
58
+ + def self.shutdown
59
+ + @@browser.stop
60
+ + end
61
+ end
62
+ +at_exit{RSpecSelenium.shutdown}
63
+
64
+ module Spec
65
+ module Runner
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rspec
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.0
7
- date: 2006-11-05
8
- summary: RSpec-0.7.0 (r1039) - BDD for Ruby http://rspec.rubyforge.org/
6
+ version: 0.7.1
7
+ date: 2006-11-10 00:00:00 -06:00
8
+ summary: RSpec-0.7.1 (r1080) - BDD for Ruby http://rspec.rubyforge.org/
9
9
  require_paths:
10
10
  - lib
11
11
  email: rspec-devel@rubyforge.org
@@ -23,6 +23,9 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
23
23
  version: 0.0.0
24
24
  version:
25
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
26
29
  authors:
27
30
  - - Steven Baker
28
31
  - Aslak Hellesoy
@@ -36,7 +39,6 @@ files:
36
39
  - Rakefile
37
40
  - README
38
41
  - lib/spec.rb
39
- - lib/spec/callback.rb
40
42
  - lib/spec/expectations.rb
41
43
  - lib/spec/mocks.rb
42
44
  - lib/spec/runner.rb
@@ -67,6 +69,7 @@ files:
67
69
  - lib/spec/rake/spectask.rb
68
70
  - lib/spec/rake/verify_rcov.rb
69
71
  - lib/spec/runner/backtrace_tweaker.rb
72
+ - lib/spec/runner/command_line.rb
70
73
  - lib/spec/runner/context.rb
71
74
  - lib/spec/runner/context_eval.rb
72
75
  - lib/spec/runner/context_runner.rb
@@ -103,6 +106,7 @@ files:
103
106
  - vendor/watir/README.txt
104
107
  - vendor/selenium/find_rspecs_home_page.rb
105
108
  - vendor/selenium/rspec_selenium.rb
109
+ - vendor/selenium/start_browser_once.patch
106
110
  - vendor/selenium/README.txt
107
111
  test_files: []
108
112
 
File without changes