Sha256: dcbf597f08d7ab2f4fb2246a13911ee1120c81593f4cd205a62c97a9f949f8a5

Contents?: true

Size: 1.55 KB

Versions: 34

Compression:

Stored size: 1.55 KB

Contents

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

RSpec.describe Card::Set::All::AssignAttributes do
  it "assigns attributes" do
    card = Card.new name: "#name", type: :basic, content: "#content", codename: "#codename"
    expect(card.attributes).to include(
      "name" => "#name",
      "db_content" => "#content",
      "codename" => "#codename",
      "type_id" => Card::BasicID
    )
  end

  it "assigns subcards" do
    card = Card.new name: "#name", subcards: { "sub" => { content: "subcontent" } }
    expect(card.subcards.first).to eq "sub"
    subcard = card.subcard "sub"
    expect(subcard).to be_a(Card)
    expect(subcard.content).to eq "subcontent"
  end

  example "change type attribute", as_bot: true do
    update "A", type_id: Card::CardtypeID
    expect(Card["A"].type_code).to eq(:cardtype)
  end

  example "create cardtype with codename" do
    card = Card.create! name: "Foo Type", codename: "foo",
                        type: "Cardtype"
    expect(card).to have_type(:cardtype).and have_codename :foo
  end

  it "assigns subfields" do
      card = Card.new name: "#name", subfields: { default: { content: "subcontent" } }
      expect(card.subcards.first).to eq "name+*default"
      subcard = card.subfield :default
      expect(subcard).to be_a(Card)
      expect(subcard.name).to eq "#name+*default"
      expect(subcard.content).to eq "subcontent"
    end

  describe "set specific attributes" do
    example "file card with set specfic attribute" do
      card = Card.new name: "empty", type: :file, empty_ok: true
      expect(card.empty_ok?).to be_truthy
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
card-1.97.0.1 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.97.0 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.8 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.7 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.6 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.5 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.4 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.3 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.2 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.1 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.96.0 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.95.3 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.95.2 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.95.1 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.95.0 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.94.1 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.94.0 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.93.13 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.93.12 mod/core/spec/set/all/assign_attributes_spec.rb
card-1.93.11 mod/core/spec/set/all/assign_attributes_spec.rb