Sha256: 7505c19712cedb51c3e394c24db112f0d6498a1c619f956bb47d96b4ea875d58

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require File.dirname(__FILE__) + '/generator_spec_helper'
require 'fileutils'

describe Rhogen::ModelGenerator do

  model_name = 'employee'

  it "should complain if no name is specified" do
    lambda {
      @generator = Rhogen::ModelGenerator.new('/tmp', {})
    }.should raise_error(::Templater::TooFewArgumentsError)
  end

  before do
    @generator = Rhogen::ModelGenerator.new('/tmp', {}, model_name, "http://something.com/sources/5", 5, "name,industry,address")
  end
  
  it "should have attributes" do
    @generator.attributes?.should == true
  end
  
  it "should have all attributes" do
    @generator.attributes.should == ['name', 'industry', 'address']
  end

  it "should create config.rb, controller.rb, index.erb, edit.erb, and new.erb files" do
    ['config.rb', 'controller.rb', 'index.erb', 'edit.erb', 'new.erb', 'show.erb'].each do |template|
      @generator.should create("/tmp/#{model_name.camel_case}/#{template}")
    end
  end
  
  it "should generate valid erb templates" do
    pending "need to figure out how to validate erb"
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rhodes-0.2.4 spec/model_generator_spec.rb
rhodes-0.2.6 spec/model_generator_spec.rb
rhodes-0.3.0 spec/model_generator_spec.rb
rhodes-0.2.5 spec/model_generator_spec.rb