ubazu 0.1.2 → 0.1.3

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.
@@ -36,7 +36,17 @@ module Ubazu
36
36
  super(instance)
37
37
 
38
38
  @expected_message ||= :blank
39
- !@instance.valid? and @instance.errors.include? @expected_message
39
+ logger.debug "Expected to be validated with message: #{@expected_message}" if !@expected_message.blank?
40
+ wrong_value = rand(99999999999).to_s.to_sym #wrong symbol
41
+ @instance.send("#{@attribute}=", wrong_value)
42
+ result = !errors_match?
43
+
44
+ if result
45
+ true
46
+ else
47
+ @failure_message = "#{@attribute} is not validated for inclusion in #{@array.inspect}"
48
+ false
49
+ end
40
50
  end
41
51
 
42
52
  def description
@@ -45,6 +55,31 @@ module Ubazu
45
55
 
46
56
  private
47
57
 
58
+ def errors_match?
59
+ @instance.valid?
60
+ @errors = errors_for_attribute(@instance, @attribute)
61
+ @errors = [@errors] unless @errors.is_a?(Array)
62
+ @expected_message ? (errors_match_regexp? || errors_match_string?) : (@errors.compact.any?)
63
+ end
64
+
65
+ def errors_match_regexp?
66
+ if Regexp === @expected_message
67
+ @matched_error = @errors.detect { |e| e =~ @expected_message }
68
+ !@matched_error.nil?
69
+ else
70
+ false
71
+ end
72
+ end
73
+
74
+ def errors_match_string?
75
+ if @errors.include?(@expected_message)
76
+ @matched_error = @expected_message
77
+ true
78
+ else
79
+ false
80
+ end
81
+ end
82
+
48
83
  def blank_value
49
84
  if collection?
50
85
  []
data/ubazu.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ubazu}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Silviu Rosu"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ubazu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Silviu Rosu