Sha256: d3c8862947b7fed863b13c759ef8a854fd61313f4f0e1e26ff16b5436a2fbf82

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"

describe Form::Component::Label do
  describe "#text" do
    let(:form) { mock(base_name: nil) }
    subject { described_class.new(form, :email) }

    context "with simple name" do
      it "returns specified text" do
        subject.options[:text] = "E-mail address"
        subject.text.should eql("E-mail address")
      end

      it "returns text for full scope" do
        i18n :en, {form: {
          labels: {email: "E-mail"}
        }}

        subject.text.should eql("E-mail")
      end

      it "returns humanized text" do
        subject.text.should eql("Email")
      end
    end

    context "with composed name" do
      before { form.stub base_name: %w[user profile] }

      it "returns specified text" do
        subject.options[:text] = "E-mail address"
        subject.text.should eql("E-mail address")
      end

      it "returns text for full scope" do
        i18n :en, {form: {
          labels: {user: {profile: {email: "E-mail"}}}
        }}

        subject.text.should eql("E-mail")
      end

      it "returns text for root scope" do
        i18n :en, {form: {
          labels: {email: "E-mail"}
        }}

        subject.text.should eql("E-mail")
      end

      it "returns humanized text" do
        subject.text.should eql("Email")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
form-0.0.1.alpha1 spec/form/component/label_spec.rb