Sha256: 7020e94ce46d15d15774be491ca54270272a0ed90d41b6226c1592001232e88b

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

# coding: utf-8

require 'spec_helper'

describe "Text block" do
  let(:article) { create(:article) }

  before(:each) do
    clean_database
    visit_article
  end

  def visit_article() visit "/admin/articles/#{article.id}/edit"; end
  def add_block() find_link(I18n.t("redditor.add.text_block")).click; end
  def submit() find_button("Submit").click; end
  def save_block() find("a.redditor__update").click; end
  def delete_block() find("a.redditor__delete").click; end

  it "Saves text block to article", type: :feature, js: true do
    add_block
    page.find(".text-block-input").set("test text block")
    submit
    expect(page.find("textarea").value).to eq "test text block"
  end

  it "Shows validation error if text block content is empty", type: :feature, js: true do
    add_block
    submit
    expect(page).to have_content "can't be blank"
  end

  it "Deletes text block", type: :feature, js: true do
    article.page.text_blocks.build(body: "123", position: 1).save
    visit_article
    save_page
    delete_block
    visit_article
    text_value = begin
      page.find("textarea").value
    rescue
      nil
    end
    expect(text_value).to eq nil
  end

  it "Saves text block to article on save button", type: :feature, js: true do
    add_block
    page.find(".text-block-input").set("test text block")
    save_block
    visit_article
    expect(page.find("textarea").value).to eq "test text block"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redditor-0.1.10 spec/features/text_spec.rb
redditor-0.1.9 spec/features/text_spec.rb
redditor-0.1.8 spec/features/text_spec.rb
redditor-0.1.7 spec/features/text_spec.rb
redditor-0.1.6 spec/features/text_spec.rb