Sha256: 218240daff63e37b4c499db3d22e9bdc8b2e6e5331e4369c171ced1f74d5382c

Contents?: true

Size: 1.85 KB

Versions: 4

Compression:

Stored size: 1.85 KB

Contents

require "spec_helper.rb"

describe "ModJS templates" do

  before :each do
    suppress_output do
      @project = ModJS::Blueprint.new( { name: 'myapp' }, TMP_DIR)
      @project.create
      FileUtils.cd("#{TMP_DIR}")
    end
  end

  after :each do
    FileUtils.rm_rf(TMP_DIR)
    FileUtils.cd(SPEC_DIR)
  end

  it 'should generate a module file' do
    config = {
      arguments: ['module', 'foo'],
      template: 'module',
      filename: 'foo',
      options: {}
    }

    @project.generator.generate(config)
    File.exists?("#{TMP_DIR}/foo.js").should be_true
    "#{TMP_DIR}/foo.module.js".should be_same_file_as "#{FIXTURES}/foo.js"
  end

  it 'should render a module with elements' do
    config = {
      arguments: ['module', 'foo_elements', '-e'],
      template: 'module',
      filename: 'foo_elements',
      options: { e: true }
    }

    @project.generator.generate(config)
    File.exists?("#{TMP_DIR}/foo_elements.module.js").should be_true
    "#{TMP_DIR}/foo_elements.module.js".should be_same_file_as "#{FIXTURES}/foo_elements.js"
  end

  it 'should render a module with a model' do
    config = {
      arguments: ['module', 'foo_model', '-m'],
      template: 'module',
      filename: 'foo_model',
      options: { m: true }
    }

    @project.generator.generate(config)
    File.exists?("#{TMP_DIR}/foo_model.module.js").should be_true
    "#{TMP_DIR}/foo_model.module.js".should be_same_file_as "#{FIXTURES}/foo_model.js"
  end

  it 'should render a module with both a model and elements' do
    config = {
      arguments: ['module', 'foo_all', '-e', '-m'],
      template: 'module',
      filename: 'foo_all',
      options: { e: true, m: true }
    }

    @project.generator.generate(config)
    File.exists?("#{TMP_DIR}/foo_all.module.js").should be_true
    "#{TMP_DIR}/foo_all.module.js".should be_same_file_as "#{FIXTURES}/foo_all.js"
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
modjs-architecture-0.3.3 spec/templates_spec.rb
modjs-architecture-0.3.2 spec/templates_spec.rb
modjs-architecture-0.3.1 spec/templates_spec.rb
modjs-architecture-0.3.0 spec/templates_spec.rb