code-spec 0.2.8 → 0.2.9

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.2.9
data/code-spec.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{code-spec}
8
- s.version = "0.2.8"
8
+ s.version = "0.2.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-10-21}
12
+ s.date = %q{2010-10-22}
13
13
  s.description = %q{Code file RSpec 2 matchers that make it easy to spec Ruby code files, fx updated or generated by a Thor generator}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -17,6 +17,14 @@ module RSpec
17
17
  def debug?
18
18
  false
19
19
  end
20
+
21
+ def display_content
22
+ "\ncontent:#{content}"
23
+ end
24
+
25
+ def display msg
26
+ "#{msg}#{display_content}\nRegexp: #{@expr}\n#{@special_error}"
27
+ end
20
28
 
21
29
  def matches? content, &block
22
30
  @content = content
@@ -30,7 +38,8 @@ module RSpec
30
38
  end
31
39
 
32
40
  def is_match? content
33
- expr = get_expr(content)
41
+ expr = get_expr(content)
42
+ @expr = expr
34
43
  debug "match expression: #{expr}"
35
44
  match = (content =~ expr)
36
45
  @content_matches = [$1, $2, $3]
@@ -45,12 +45,12 @@ module RSpec::RubyContentMatchers
45
45
 
46
46
  def failure_message
47
47
  super
48
- return "Expected there to be a block #{name}#{args_msg}#{block_args_msg}, but there wasn't"
48
+ display "Expected there to be a block #{name}#{args_msg}#{block_args_msg}, but there wasn't"
49
49
  end
50
50
 
51
51
  def negative_failure_message
52
52
  super
53
- return "Did not expect there to be a block #{name}#{args_msg}, but there was"
53
+ display "Did not expect there to be a block #{name}#{args_msg}, but there was"
54
54
  end
55
55
 
56
56
  protected
@@ -10,16 +10,16 @@ module RSpec::RubyContentMatchers
10
10
  attr_accessor :method_name, :args, :dot, :content
11
11
 
12
12
  def initialize(method_name, options = {})
13
- self.method_name = method_name.to_s
14
- self.args = case options
13
+ @method_name = method_name.to_s
14
+ @args = case options
15
15
  when Hash
16
- self.dot = options[:dot]
16
+ @dot = options[:dot]
17
17
  options[:args]
18
18
  else
19
19
  (options == {}) ? nil : options
20
20
  end
21
21
 
22
- self.args = ":#{args}" if args.kind_of? Symbol
22
+ @args = ":#{args}" if args.kind_of? Symbol
23
23
  end
24
24
 
25
25
  def matches?(content)
@@ -27,7 +27,7 @@ module RSpec::RubyContentMatchers
27
27
  def_pos = (content =~ /def(.*)#{method_name}/) || 999
28
28
  call_pos = (content =~ /[^def]?#{method_name}/) || 999
29
29
 
30
- arguments_expr = case args
30
+ arguments_expr = case @args
31
31
  when String
32
32
  args_expr
33
33
  when Array
@@ -35,7 +35,10 @@ module RSpec::RubyContentMatchers
35
35
  arg_val = (arg.kind_of?(String) && arg[0] == '#') ? arg[1..-1] : arg.inspect
36
36
  res << '(\s|,|\w|:)*' + arg_val
37
37
  end
38
+ when NilClass
39
+ ""
38
40
  else
41
+ @special_error = "Unknown arguments: #{args.inspect}"
39
42
  return nil
40
43
  end
41
44
 
@@ -53,12 +56,12 @@ module RSpec::RubyContentMatchers
53
56
 
54
57
  def failure_message
55
58
  super
56
- "Expected there to be a call to #{method_name}#{args_msg}, but there wasn't. Regexp: #{@expr} did not match\n#{@content}"
59
+ display "Expected there to be a call to #{method_name}#{args_msg}, but there wasn't."
57
60
  end
58
61
 
59
62
  def negative_failure_message
60
63
  super
61
- "Did not expect there to be a call to #{method_name}#{args_msg}, but there was"
64
+ display "Did not expect there to be a call to #{method_name}#{args_msg}, but there was"
62
65
  end
63
66
 
64
67
  protected
@@ -11,12 +11,12 @@ module RSpec::RubyContentMatchers
11
11
 
12
12
  def failure_message
13
13
  super
14
- "Expected there to be the #{type} #{name}"
14
+ display "Expected there to be the #{type} #{name}"
15
15
  end
16
16
 
17
17
  def negative_failure_message
18
18
  super
19
- "Did not expected there to be the #{type} #{name}"
19
+ display "Did not expected there to be the #{type} #{name}"
20
20
  end
21
21
 
22
22
  protected
@@ -14,12 +14,12 @@ module RSpec::RubyContentMatchers
14
14
 
15
15
  def failure_message
16
16
  super
17
- return "Expected there to be a: class << self"
17
+ display "Expected there to be a: class << self"
18
18
  end
19
19
 
20
20
  def negative_failure_message
21
21
  super
22
- "Did not expect there to be a: class << self"
22
+ display "Did not expect there to be a: class << self"
23
23
  end
24
24
 
25
25
  protected
@@ -13,12 +13,12 @@ module RSpec::RubyContentMatchers
13
13
 
14
14
  def failure_message
15
15
  super
16
- "Expected there to be the comment '# #{comment}'"
16
+ display "Expected there to be the comment '# #{comment}'"
17
17
  end
18
18
 
19
19
  def negative_failure_message
20
20
  super
21
- "Did not expect there to be the comment '# #{comment}'"
21
+ display "Did not expect there to be the comment '# #{comment}'"
22
22
  end
23
23
 
24
24
  protected
@@ -14,11 +14,11 @@ module RSpec::RubyContentMatchers
14
14
  end
15
15
 
16
16
  def failure_message
17
- "Expected the file #{file_path} to have content"
17
+ display "Expected the file #{file_path} to have content"
18
18
  end
19
19
 
20
20
  def negative_failure_message
21
- "Did not expect the file #{file_path} to have content"
21
+ display "Did not expect the file #{file_path} to have content"
22
22
  end
23
23
  end
24
24
 
@@ -22,12 +22,12 @@ module RSpec::RubyContentMatchers
22
22
 
23
23
  def failure_message
24
24
  super
25
- "Expected there to be the #{class_msg} method #{method}, but there wasn't"
25
+ display "Expected there to be the #{class_msg} method #{method}, but there wasn't"
26
26
  end
27
27
 
28
28
  def negative_failure_message
29
29
  super
30
- "Did not expect there to be the #{class_msg} method #{method}, but there was"
30
+ display "Did not expect there to be the #{class_msg} method #{method}, but there was"
31
31
  end
32
32
 
33
33
  protected
@@ -9,12 +9,12 @@ module RSpec::RubyContentMatchers
9
9
 
10
10
  def failure_message
11
11
  super
12
- "Expected there to be a #{region} region"
12
+ display "Expected there to be a #{region} region"
13
13
  end
14
14
 
15
15
  def negative_failure_message
16
16
  super
17
- "Did no expected there to be a #{region} region"
17
+ display "Did no expected there to be a #{region} region"
18
18
  end
19
19
 
20
20
  protected
@@ -12,12 +12,12 @@ module RSpec::RubyContentMatchers
12
12
 
13
13
  def failure_message
14
14
  super
15
- "Expected there to be the subclass #{full_class} of #{superclass}"
15
+ display "Expected there to be the subclass #{full_class} of #{superclass}"
16
16
  end
17
17
 
18
18
  def negative_failure_message
19
19
  super
20
- "Did no expected there to be the subclass #{full_class} of #{superclass}"
20
+ display "Did no expected there to be the subclass #{full_class} of #{superclass}"
21
21
  end
22
22
 
23
23
  protected
@@ -14,12 +14,12 @@ module RSpec::RubyContentMatchers
14
14
 
15
15
  def failure_message
16
16
  super
17
- "Expected there to be an inclusion of module #{module_name}"
17
+ display "Expected there to be an inclusion of module #{module_name}"
18
18
  end
19
19
 
20
20
  def negative_failure_message
21
21
  super
22
- "Did not expect there to be an inclusion of module #{module_name}"
22
+ display "Did not expect there to be an inclusion of module #{module_name}"
23
23
  end
24
24
 
25
25
  end
@@ -13,12 +13,12 @@ module RSpec::RubyContentMatchers
13
13
 
14
14
  def failure_message
15
15
  super
16
- "Expected the class to inherit from #{klass}"
16
+ "Expected the class to inherit from #{klass}\ncontent:#{content}"
17
17
  end
18
18
 
19
19
  def negative_failure_message
20
20
  super
21
- "Did not expect the class to inherit from #{klass}"
21
+ "Did not expect the class to inherit from #{klass}\ncontent:#{content}"
22
22
  end
23
23
 
24
24
  protected
@@ -38,12 +38,12 @@ module RSpec::RubyContentMatchers
38
38
 
39
39
  def failure_message
40
40
  super
41
- "Expected there to be the #{type} #{name}"
41
+ display "Expected there to be the #{type} #{name}"
42
42
  end
43
43
 
44
44
  def negative_failure_message
45
45
  super
46
- "Did not expected there to be the #{type} #{name}"
46
+ display "Did not expected there to be the #{type} #{name}"
47
47
  end
48
48
 
49
49
  protected
@@ -63,7 +63,6 @@ describe 'method call matcher' do
63
63
  migration_klass.should have_class_method :up
64
64
 
65
65
  migration_klass.should have_class_method :down do |down|
66
- puts down
67
66
  down.should have_call 'drop_table', :users
68
67
  end
69
68
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 8
9
- version: 0.2.8
8
+ - 9
9
+ version: 0.2.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-21 00:00:00 +02:00
17
+ date: 2010-10-22 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency