Sha256: 0b2b1f69420de72743cf5e907d6214d8643e2b816c27661f7456f31ab16a9347

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

require "spec_helper"
require "mvcli/actions"

describe "MVCLI::Actions" do
  Given(:loader) {mock(:Loader)}
  Given(:renderer) {mock(:Renderer, :render => true)}
  Given(:actions) {MVCLI::Actions.new '/root', loader, renderer}

  context "when the loader cannot find an appropriate controller" do
    Given {loader.stub(:load) {fail LoadError}}
    When(:action) {actions['foo']}
    Then {action.should_not be_nil}

    context ".calling it" do
      When(:result) {action.call(mock(:Command))}
      Then {result.should have_failed LoadError}
    end
  end

  context "when the class exists" do
    Given(:output) {mock(:Output)}
    Given(:controller) {mock(:Controller)}
    Given {loader.stub(:load).with(:controller, 'foo', {}) {controller}}
    Given {controller.stub(:bar) {"the context"}}
    When {actions['foo#bar'].call(mock(:Command, :output => output), {})}
    Then {controller.should have_received(:bar)}
    And {renderer.should have_received(:render).with(output, 'foo/bar', 'the context')}
  end

  context "when the action is callable" do
    Given(:app) { ->(c) {} }
    Then { actions[app] == app }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mvcli-0.0.16 spec/mvcli/actions_spec.rb
mvcli-0.0.14 spec/mvcli/actions_spec.rb
mvcli-0.0.13 spec/mvcli/actions_spec.rb
mvcli-0.0.12 spec/mvcli/actions_spec.rb