Sha256: 10a1b6dc0addd45a572e698f0b42141bd33f28fde796ef6c1f42ccb073716e21

Contents?: true

Size: 1.68 KB

Versions: 12

Compression:

Stored size: 1.68 KB

Contents

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

describe Card::Set::All::RichHtml::Form do
  describe "type_list" do
    before do
      @card = Card['UserForm']  # no cards with this type
    end

    it "should get type options from type_field renderer method" do
      expect(@card.format.type_field).to match(/<option [^>]*selected/)
      tf=@card.format.type_field(no_current_type: true)
      expect(tf).not_to match(/<option [^>]*selected/)
      expect(tf.scan(/<option /).length).to eq(29)
      tf=@card.format.type_field
      expect(tf).to match(/<option [^>]*selected/)
      expect(tf.scan(/<option /).length).to eq(29)
    end

    it "should get type list" do
      Card::Auth.as :anonymous do
        tf=@card.format.type_field(no_current_type: true)
        expect(tf).not_to match(/<option [^>]*selected/)
        expect(tf.scan(/<option /).length).to eq(1)
        tf=@card.format.type_field
        expect(tf).to match(/<option [^>]*selected/)
        expect(tf.scan(/<option /).length).to eq(2)
      end
    end
  end

  context "type and header" do
    it "should render type without no-edit class when no cards of type" do
      card = Card['UserForm']  # no cards with this type
      expect(card.format.render_type).to match(/<a[^>]* class="([^"]*)?\bcardtype\b[^"]*"/)
      expect(card.format.render_type).not_to match(/<a[^>]* class="([^"]*)?\bno-edit\b[^"]*"/)
    end
    it "should render type header with no-edit class when cards of type exist" do
      no_edit_card = Card['cardtype a']
      expect(no_edit_card.format.render_type).to match(/<a[^>]* class="([^"]*)?\bcardtype\b[^"]*"/)
      expect(no_edit_card.format.render_type).to match(/<a[^>]* class="([^"]*)?\bno-edit\b[^"]*"/)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-1.17.4 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.17.3 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.17.2 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.17.1 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.17.0 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.16.15 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.16.14 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.16.13 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.16.12 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.16.11 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.16.10 mod/05_standard/spec/set/all/rich_html/form_spec.rb
card-1.16.9 mod/05_standard/spec/set/all/rich_html/form_spec.rb