Sha256: fb79b58e75859b656d4dca0e68f70680a6b61657ca5930a2b1de7eebbf4e8f2c

Contents?: true

Size: 979 Bytes

Versions: 7

Compression:

Stored size: 979 Bytes

Contents

# -*- encoding : utf-8 -*-

describe Card, "validate name" do
  it "should error on name with /" do
    @c = Card.create name: "testname/"
    expect(@c.errors[:name]).not_to be_blank
  end

  it "should error on junction name  with /" do
    @c = Card.create name: "jasmin+ri/ce"
    expect(@c.errors[:name]).not_to 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"
    expect(Card.count).to eq(original_card_count)
  end

  it "should not allow empty name" do
    @c = Card.new name: ""
    expect(@c.valid?).to eq(false)
    expect(@c.errors[:name]).not_to 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'
    expect(@c.valid?).to eq(false)
    # @c.errors[:key].should_not be_blank
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
card-1.19.6 spec/models/card/validation_spec.rb
card-1.19.5 spec/models/card/validation_spec.rb
card-1.19.4 spec/models/card/validation_spec.rb
card-1.19.3 spec/models/card/validation_spec.rb
card-1.19.2 spec/models/card/validation_spec.rb
card-1.19.1 spec/models/card/validation_spec.rb
card-1.19.0 spec/models/card/validation_spec.rb