Sha256: 5a5146832ad10aa7a96c8f59d478c17173a36ee6e0b245a8e46f10ae44bf408a

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

module Hexx
  describe Settings do

    around do |example|
      module TestModule; include Settings; end
      class TestClass; end
      example.run
      Hexx.send :remove_const, :TestClass
      Hexx.send :remove_const, :TestModule
    end

    subject { TestModule }

    describe ".configure" do

      it "is public" do
        expect(subject).to respond_to(:configure).with(0).arguments
      end

      it "sends itself to a block" do
        subject.configure do |config|
          expect(config).to eq subject
        end
      end
    end

    describe ".depends_on" do

      it "is public" do
        expect(subject).to respond_to(:depends_on).with(1).argument
      end

      it "defines name settings accessor" do
        subject.depends_on :test_class
        expect(subject).to respond_to(:test_class_name).with(0).arguments
        expect(subject).to respond_to(:test_class_name=).with(1).argument
        expect { subject.test_class_name = "TestClass" }
          .to change { subject.test_class_name }.from(nil).to "TestClass"
      end

      it "defines corresponding constant reader" do
        subject.depends_on :test_class
        expect(subject).to respond_to(:test_class).with(0).arguments
        expect { subject.test_class_name = "Hexx::TestClass" }
          .to change { subject.test_class }.from(nil).to TestClass
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hexx-1.1.1 spec/hexx/settings_spec.rb
hexx-1.1.0 spec/hexx/settings_spec.rb
hexx-1.0.2 spec/hexx/settings_spec.rb
hexx-1.0.1 spec/hexx/settings_spec.rb
hexx-1.0.0 spec/hexx/settings_spec.rb
hexx-0.1.1 spec/hexx/settings_spec.rb
hexx-0.1.0 spec/hexx/settings_spec.rb