Sha256: f39b4174816ade29a8030279cc25c2c29819da11dcdb5181827f26df3b43dc5b

Contents?: true

Size: 1.71 KB

Versions: 7

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe OrdersController, ':' do
  Order.delete_all
  Order.create :name => 'name', :qty => 123
  let(:order) {Order.all.first}

  %w{index new}.each do |action|
    describe "#{action}" do
      it "renders the '#{action}' template" do
	get action.to_sym
	response.code.should eq('200')
	response.should render_template("rows/#{action}")
	response.body.should == ''
      end
    end
  end

  %w{edit show}.each do |action|
    describe "#{action}" do
      it "renders the '#{action}' template" do
	get action.to_sym, :id => order.id
	response.code.should eq('200')
	response.should render_template("rows/#{action}")
	response.body.should == ''
      end
    end
  end

  it 'checking resource' do
    get :show, :id => order.id
    subject.send(:resource).should == order
    assigns(:order).should == order
  end

  it 'checking resources' do
    get :index
    subject.send(:resources).should be_a_kind_of(Array)
    assigns(:orders).should be_a_kind_of(Array)
    assigns(:orders).should == Order.all
  end

  it 'checking model_class' do
    get :show, :id => order.id
    subject.send(:model_class).should == Order
    subject.send(:model_name).should == 'Order'
    subject.send(:model_symbol).should == 'order'
    subject.send(:model_symbol_plural).should == 'orders'
  end
end


class CategoriesController < RowsController
  model_class Order
end

describe CategoriesController do
  it 'checking model_class' do
    get :index
# both not working, Why?
#    subject.send(:model_class).should be_a(Order)
#    subject.send(:model_class).should == Order
    subject.send(:model_name).should == 'Order'
    subject.send(:model_symbol).should == 'order'
    subject.send(:model_symbol_plural).should == 'orders'
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rows_controller-0.4.4 spec/controllers/orders_spec.rb
rows_controller-0.4.3 spec/controllers/orders_spec.rb
rows_controller-0.4.2 spec/controllers/orders_spec.rb
rows_controller-0.4.1 spec/controllers/orders_spec.rb
rows_controller-0.3.2 spec/controllers/orders_spec.rb
rows_controller-0.2.4 spec/controllers/orders_spec.rb
rows_controller-0.2.3 spec/controllers/orders_spec.rb