Sha256: d2d3922dbc213c000e0afe939a7ca9961752a71bea3b452700a5446c734a4eff

Contents?: true

Size: 1.21 KB

Versions: 15

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe MB::Cli::SubCommand do
  subject { described_class }

  describe "::new" do
    context "given a MB::Plugin" do
      let(:metadata) do
        double('metadata',
          name: "rspec-test"
        )
      end

      let(:plugin) { MB::Plugin.new(metadata) }

      it "returns an anonymous class whose superclass is MB::Cli::SubCommand::Plugin" do
        klass = subject.new(plugin)
        klass.should be_a(Class)
        klass.superclass.should eql(MB::Cli::SubCommand::Plugin)
      end
    end

    context "given a MB::Component" do
      let(:plugin) { double('plugin') }
      let(:component) { MB::Component.new(plugin, plugin) }

      it "returns an anonymous class whose superclass is MB::Cli::SubCommand::Component" do
        klass = subject.new(component)

        klass.should be_a(Class)
        klass.superclass.should eql(MB::Cli::SubCommand::Component)
      end
    end

    context "given a class which is not a MB::Plugin or MB::Component" do
      it "raises an ArgumentError" do
        expect {
          subject.new(double('whatever'))
        }.to raise_error(ArgumentError, "don't know how to fabricate a subcommand for a 'RSpec::Mocks::Mock'")
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
motherbrain-1.5.0 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.4.0 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.3.0 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.2.1 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.2.0 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.1.3 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.1.2 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.1.1 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.1.0 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-1.0.0 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-0.14.5 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-0.14.4 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-0.14.3 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-0.14.2 spec/unit/mb/cli/sub_command_spec.rb
motherbrain-0.13.1 spec/unit/mb/cli/sub_command_spec.rb