public
Description: Behaviour Driven Development framework for Ruby
Homepage: http://rspec.info
Clone URL: git://github.com/dchelimsky/rspec.git
Click here to lend your support to: rspec and make a donation at www.pledgie.com !
add example and fix coverage problem with have_spec
dchelimsky (author)
Sun Jul 06 05:10:47 -0700 2008
commit  bee481078ad706ac8ab951703b20a8f1b924469d
tree    1c1f3418354c0a8046e4591b71b9cb240a2c7fd2
parent  6096e8d73757179b6e766e286ed97975e6b360ef
...
40
41
42
43
 
44
45
46
...
40
41
42
 
43
44
45
46
0
@@ -40,7 +40,7 @@ Spec::Rake::SpecTask.new do |t|
0
   t.spec_opts = ['--options', 'spec/spec.opts']
0
   unless ENV['NO_RCOV']
0
     t.rcov = true
0
- t.rcov_dir = '../doc/output/coverage'
0
+ t.rcov_dir = 'coverage'
0
     t.rcov_opts = ['--exclude', 'lib/spec.rb,lib/spec/runner.rb,spec\/spec,bin\/spec,examples,\/var\/lib\/gems,\/Library\/Ruby,\.autotest']
0
   end
0
 end
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
29
30
31
32
33
34
35
...
2
3
4
 
 
 
 
 
 
5
6
 
7
8
9
...
22
23
24
 
25
26
27
0
@@ -2,15 +2,8 @@ module Spec
0
   module Expectations
0
     class InvalidMatcherError < ArgumentError; end
0
     
0
- module MatcherHandlerHelper
0
- def describe_matcher(matcher)
0
- matcher.respond_to?(:description) ? matcher.description : "[#{matcher.class.name} does not provide a description]"
0
- end
0
- end
0
-
0
     class ExpectationMatcherHandler
0
       class << self
0
- include MatcherHandlerHelper
0
         def handle_matcher(actual, matcher, &block)
0
           ::Spec::Matchers.last_should = "should"
0
           return Spec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?
0
@@ -29,7 +22,6 @@ module Spec
0
 
0
     class NegativeExpectationMatcherHandler
0
       class << self
0
- include MatcherHandlerHelper
0
         def handle_matcher(actual, matcher, &block)
0
           ::Spec::Matchers.last_should = "should not"
0
           return Spec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
...
17
18
19
20
21
22
23
 
 
24
25
26
...
17
18
19
 
 
 
 
20
21
22
23
24
0
@@ -17,10 +17,8 @@ module Spec
0
     
0
       def method_missing(sym, *args, &block)
0
         @collection_name = sym
0
- if defined?(ActiveSupport::Inflector)
0
- @plural_collection_name = ActiveSupport::Inflector.pluralize(sym.to_s)
0
- elsif Object.const_defined?(:Inflector)
0
- @plural_collection_name = Inflector.pluralize(sym.to_s)
0
+ if inflector = (defined?(ActiveSupport::Inflector) ? ActiveSupport::Inflector : (defined?(Inflector) ? Inflector : nil))
0
+ @plural_collection_name = inflector.pluralize(sym.to_s)
0
         end
0
         @args = args
0
         @block = block
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,6 +4,6 @@ require 'spec/rake/spectask'
0
 desc "Generate HTML report for failing examples"
0
 Spec::Rake::SpecTask.new('failing_examples_with_html') do |t|
0
   t.spec_files = FileList['failing_examples/**/*.rb']
0
- t.spec_opts = ["--format", "html:../doc/output/documentation/tools/failing_examples.html", "--diff"]
0
+ t.spec_opts = ["--format", "html:doc/reports/tools/failing_examples.html", "--diff"]
0
   t.fail_on_error = false
0
 end
0
\ No newline at end of file
...
3
4
5
6
 
7
...
3
4
5
 
6
7
0
@@ -3,5 +3,5 @@ require 'spec/rake/verify_rcov'
0
 
0
 RCov::VerifyTask.new(:verify_rcov => :spec) do |t|
0
   t.threshold = 100.0 # Make sure you have rcov 0.7 or higher!
0
- t.index_html = '../doc/output/coverage/index.html'
0
+ t.index_html = 'coverage/index.html'
0
 end
...
50
51
52
53
 
54
 
55
56
57
...
66
67
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
70
71
...
50
51
52
 
53
54
55
56
57
58
...
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
0
@@ -50,8 +50,9 @@ end
0
 describe 'should have(1).item when ActiveSupport::Inflector is defined' do
0
   include HaveSpecHelper
0
   
0
- before do
0
+ before(:each) do
0
     unless defined?(ActiveSupport::Inflector)
0
+ @active_support_was_not_defined
0
       module ActiveSupport
0
         class Inflector
0
           def self.pluralize(string)
0
@@ -66,6 +67,38 @@ describe 'should have(1).item when ActiveSupport::Inflector is defined' do
0
     owner = create_collection_owner_with(1)
0
     owner.should have(1).item
0
   end
0
+
0
+ after(:each) do
0
+ if @active_support_was_not_defined
0
+ Object.send :remove_const, :ActiveSupport
0
+ end
0
+ end
0
+end
0
+
0
+describe 'should have(1).item when Inflector is defined' do
0
+ include HaveSpecHelper
0
+
0
+ before(:each) do
0
+ unless defined?(Inflector)
0
+ @inflector_was_not_defined
0
+ class Inflector
0
+ def self.pluralize(string)
0
+ string.to_s + 's'
0
+ end
0
+ end
0
+ end
0
+ end
0
+
0
+ it 'should pluralize the collection name' do
0
+ owner = create_collection_owner_with(1)
0
+ owner.should have(1).item
0
+ end
0
+
0
+ after(:each) do
0
+ if @inflector_was_not_defined
0
+ Object.send :remove_const, :Inflector
0
+ end
0
+ end
0
 end
0
 
0
 describe "should have(n).items where result responds to items but returns something other than a collection" do

Comments

    No one has commented yet.