ankh 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ankh}
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 = ["Dan Pickett"]
@@ -8,8 +8,8 @@ module Ankh
8
8
  def validate(record)
9
9
  if has_valid_answer?(record)
10
10
  record.errors.add(:human_answer, @options[:message] || "is not valid")
11
- record.human_answer = ""
12
11
  end
12
+ record.human_answer = ""
13
13
  end
14
14
 
15
15
  private
@@ -4,10 +4,13 @@ describe Ankh::Model do
4
4
  INVALID_ANSWER = "3241235" #this answer will never be valid due to constraints
5
5
  class Post < ActiveRecord::Base
6
6
  validates_human
7
+ attr_accessor :name
8
+ validates_presence_of :name
7
9
  end
8
10
 
9
11
  subject do
10
12
  p = Post.new
13
+ p.name = "John"
11
14
  p.generate_human_question
12
15
  p
13
16
  end
@@ -46,4 +49,13 @@ describe Ankh::Model do
46
49
  subject.human_answer = question.answer
47
50
  subject.save.should be_true
48
51
  end
52
+
53
+ it "should clear the human answer if the model is not valid" do
54
+ question = Ankh::Question.new
55
+ Ankh::Question.expects(:generate).returns(question)
56
+ subject.name = nil
57
+ subject.human_answer = question.answer
58
+ subject.save.should be_false
59
+ subject.human_answer.should be_blank
60
+ end
49
61
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ankh
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
  - Dan Pickett