Sha256: ec29f6cfce9368f3e3c267b69a9648654097fa011e3c89f4a389d08c808453d7

Contents?: true

Size: 982 Bytes

Versions: 7

Compression:

Stored size: 982 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'wagn/spec_helper'

describe Card, "validate name" do

  it "should error on name with /" do
    @c = Card.create :name=>"testname/"
    @c.errors[:name].should_not be_blank
  end

  it "should error on junction name  with /" do
    @c = Card.create :name=>"jasmin+ri/ce"
    @c.errors[:name].should_not be_blank
  end

  it "shouldn't create any new cards when name invalid" do
    original_card_count = Card.count
    @c = Card.create :name=>"jasmin+ri/ce"
    Card.count.should == original_card_count
  end

  it "should not allow empty name" do
    @c = Card.new :name=>""
    @c.valid?.should == false
    @c.errors[:name].should_not be_blank
  end

  # maybe the @c.key= should just throw an error, but now it doesn't take anyway
  it "should not allow mismatched name and key" do
    @c = Card.new :name=>"Test"
    @c.key="foo"
    #@c.key.should == 'test'
    @c.valid?.should == false
    #@c.errors[:key].should_not be_blank
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wagn-1.12.13 spec/models/card/validation_spec.rb
wagn-1.12.12 spec/models/card/validation_spec.rb
wagn-1.12.11 spec/models/card/validation_spec.rb
wagn-1.12.10 spec/models/card/validation_spec.rb
wagn-1.12.9 spec/models/card/validation_spec.rb
wagn-1.12.8 spec/models/card/validation_spec.rb
wagn-1.12.7 spec/models/card/validation_spec.rb