Sha256: a788f44bbf117cb02b021b4f06f8cc0ec18956e94ced49b78bd6942eaf6988fb

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe EditableAreasHelper do
  before :each do
    @area = EditableArea.create!(title: 'New', content: 'Content')
  end

  it "should render text when no edit parameter is given" do
    output = helper.render_or_edit_area('New')
    expect(output).to match(/Content/)
  end

  it "should render the form when edit parameter is given" do
    params[:edit] = true
    output = helper.render_or_edit_area('New')
    expect(output).to match(/class="edit_editable_area"/)
  end

  context "edit button" do
    it "should render when no edit parameter is given" do
      output = helper.render_edit_area_button
      expect(output).to match(/class="editable_area_btn"/)
    end

    it "should NOT render when no edit parameter is given and accessiblity is false" do
      output = helper.render_edit_area_button(accessible: false)
      expect(output).to be_nil
    end

    it "should NOT render when edit parameter is given" do
      params[:edit] = true
      output = helper.render_edit_area_button
      expect(output).to be_nil
    end

    it "should NOT render when edit parameter is given and accessiblity is false" do
      params[:edit] = true
      output = helper.render_edit_area_button(accessible: false)
      expect(output).to be_nil
    end
  end

  it "should render both area and button properly with NO edit parameter" do
    output = helper.render_or_edit_area_with_button('New')

    expect(output).to match(/Content/)
    expect(output).to match(/class="editable_area_btn"/)
  end

  it "should render both area and button properly with edit parameter" do
    params[:edit] = true
    output = helper.render_or_edit_area_with_button('New')

    expect(output).to match(/class="edit_editable_area"/)
    expect(output).to_not match(/class="editable_area_btn"/)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
editable_areas-0.1.0 spec/helpers/areas_helper_spec.rb
editable_areas-0.0.3 spec/helpers/areas_helper_spec.rb
editable_areas-0.0.2 spec/helpers/areas_helper_spec.rb
editable_areas-0.0.1 spec/helpers/areas_helper_spec.rb