Sha256: 7fb73159af88cdb11b8c1769056066d9c27e9d773a2a2b7e5c0f097cb76203f9

Contents?: true

Size: 1.74 KB

Versions: 3

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'
require 'support/test_database'

describe "adminpanel rake task" do

  before :all do
    Rake.application.rake_require "tasks/adminpanel/adminpanel"
    Rake::Task.define_task(:environment)
  end

  describe "adminpanel:populate[10, product, name:name description:lorem price:small_lorem]" do

    let(:has_nil_attribute) { false }
    before do
      Rake.application.invoke_task "adminpanel:populate[10, product, name:name description:lorem price:number]"
    end


    # it "should generate 10 product records" do
    #   Adminpanel::Product.find(:all).count.should eq 10
    # end

    it "attributes shouldn't be nil" do
      Adminpanel::Product.find(:all).each do |product|
        if (product.name.nil? || product.description.nil? || product.price.nil? ||
          product.name == "" || product.description == "" || product.price == "")
          has_nil_attribute = true
        end
      end
      has_nil_attribute.should eq false
    end
  end

  describe "adminpanel:section[about, mission]" do
    before do
      Rake.application.invoke_task "adminpanel:section[about, mission]"
    end

    it "should create a section with name 'mission' and section 'about'" do
      (
        (Adminpanel::Section.last.name.should eq("Mission")) &&
        (Adminpanel::Section.last.page.should eq("about")) &&
        (Adminpanel::Section.last.key.should eq("mission")) &&
        (Adminpanel::Section.last.has_description.should be_false) &&
        (Adminpanel::Section.last.has_image.should be_false)
      )
    end
  end

  describe 'adminpanel:user' do
    before do
      Rake.application.invoke_task "adminpanel:user"
    end
    it 'should create admin@codn user' do
      Adminpanel::User.last.email.should eq('admin@codn.com')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-1.2.12 spec/tasks/adminpanel_rake_spec.rb
adminpanel-1.2.11 spec/tasks/adminpanel_rake_spec.rb
adminpanel-1.2.10 spec/tasks/adminpanel_rake_spec.rb