Sha256: 8015cb3446b86a30bc03d571defa1987251e25350131c8593241d3706deeef1c

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require "#{File.expand_path(File.dirname(__FILE__))}/controller_helper"
require 'crystal_ext/prepare_model'

describe "User Error" do
  with_environment :test
  with_controller_ext_spec
  
  before :all do
    class ::SomeModel
      def self.find! id
        id.should == 'some id'
        SomeModel.new
      end
    end
    
    # crystal[:config].environment = :test
    # crystal[:environment] = Crystal::Environment.new
    # crystal[:environment].load :controller_ext_spec
  end
  
  after :all do    
    remove_constants %w(SomeModel ControllerSpec)
    
    # Micon.clear
  end
  
  it "user error" do
    class ::ControllerSpec
      inherit Crystal::HttpController
      
      prepare_model SomeModel, :id => :some_model, :variable => 'some_model'
      
      def action
        @some_model.should_not == nil
        render :inline => 'ok'
      end
    end
    
    ccall(ControllerSpec, :action, :some_model => 'some id').content.should == 'ok'
    # workspace.response.should == [200, {"Content-Type"=>"application/json"}, %({"result":true})]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crystal_ext-0.0.4 spec/prepare_model_spec.rb