Sha256: 321d62652ad55aff0a235ac0a5dbcabbe05f2b67590039cd6f2952ec64834c68

Contents?: true

Size: 1.96 KB

Versions: 4

Compression:

Stored size: 1.96 KB

Contents

require 'test_helper'

module Vedeu

  module DSL

    describe Composition do

      let(:described) { Vedeu::DSL::Composition }
      let(:instance)  { described.new(model) }
      let(:model)     { Vedeu::Composition.new }
      let(:client)    {}

      describe '#initialize' do
        it { instance.must_be_instance_of(described) }
        it { instance.instance_variable_get('@model').must_equal(model) }
        it { instance.instance_variable_get('@client').must_equal(client) }
      end

      describe '#view' do
        subject {
          instance.view('dysprosium') do
            # ...
          end
        }

        it { subject.must_be_instance_of(Vedeu::InterfaceCollection) }
        it { subject.first.must_be_instance_of(Vedeu::Interface) }

        context 'when the block is not given' do
          it { proc { instance.view }.must_raise(InvalidSyntax) }
        end
      end

      describe '#template_for' do
        let(:_name)    {}
        let(:filename) {}
        let(:object)   {}
        let(:content)  { "Hydrogen\nCarbon\nOxygen\nNitrogen" }
        let(:options)  { {} }

        subject { instance.template_for(_name, filename, object, options) }

        context 'when the name of the view is not given' do
          let(:filename) { 'my_interface.erb' }

          it { proc { subject }.must_raise(MissingRequired) }
        end

        context 'when the filename of the template is not given' do
          let(:_name) { 'my_interface' }

          it { proc { subject }.must_raise(MissingRequired) }
        end

        context 'when the name and filename are given' do
          let(:_name) { 'my_interface' }
          let(:filename) { 'my_interface.erb' }

          before {
            Vedeu::Templating::ViewTemplate.expects(:parse).
              with(object, filename, options).returns(content)
          }

          it { subject.must_be_instance_of(Vedeu::InterfaceCollection) }
        end
      end

    end # Composition

  end # DSL

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.5.4 test/lib/vedeu/dsl/composition_test.rb
vedeu-0.5.3 test/lib/vedeu/dsl/composition_test.rb
vedeu-0.5.2 test/lib/vedeu/dsl/composition_test.rb
vedeu-0.5.1 test/lib/vedeu/dsl/composition_test.rb