Sha256: 29f32cdaff0bee5c38a215f5b0e918bf7cf1b2b47786e69fe3e6a20cb0d63d15

Contents?: true

Size: 1.54 KB

Versions: 27

Compression:

Stored size: 1.54 KB

Contents

RSpec.describe Card::Set::All::Chunk do
  describe "#edit_fields" do
    def format_with_edit_fields args
      Card["A"].format_with(:html) do
        define_method :edit_fields do
          args
        end
      end
    end

    it "interprets strings as field names" do
      format = format_with_edit_fields ["B", "+C"]
      expect(format.render_edit).to have_tag ".card-slot" do
        with_tag ".card-editor.RIGHT-b", with: { card_name: "A+B" }
        with_tag ".card-editor.RIGHT-c", with: { card_name: "A+C" }
      end
    end

    it "doesn't make card objects to fields" do
      format = format_with_edit_fields [Card["B"]]
      expect(format.render_edit).to have_tag ".card-editor", with: { card_name: "B" }
    end

    it "treats symbols as codenames", as_bot: true do
      format = format_with_edit_fields [:write, :basic]
      expect(format.render_edit).to have_tag ".card-slot" do
        with_tag ".card-editor.RIGHT-Xwrite", with: { card_name: "A+*write" }
        with_tag ".card-editor.RIGHT-basic", with: { card_name: "A+Basic" }
      end
    end

    example "absolute option", as_bot: true do
      format = format_with_edit_fields [[:self, { absolute: true }]]
      expect(format.render_edit).to have_tag ".card-editor", with: { card_name: "*self" }
    end

    example "title argument" do
      format = format_with_edit_fields [["B", "custom title"]]
      expect(format.render_edit)
        .to have_tag ".card-editor.RIGHT-b", with: { card_name: "A+B" } do
        with_tag ".card-title", text: "custom title"
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

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