Sha256: e6e543f07364f1cf9cbe335ea0a9132a4b07e3987b6b91952fbec2d9d462ebd2

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

ENV['RAILS_ENV'] = 'test'

require_relative '../../../app/config/environment'

require 'capybara/rspec'
require 'capybara/rails'

module Angular
  module NGT
    describe Railtie, type: :feature do
      before(:each) { FileUtils.rm_rf Rails.root.join('tmp', 'cache', 'assets', 'test') }

      it "sets up rails to serve ng templates" do
        visit '/assets/templates/test.ngt'
        page.should have_content "$templateCache"
        page.should have_content "Hello World"
      end

      it "enables Haml for js assets" do
        visit '/assets/templates/test_haml.js'
        page.should have_content "$templateCache"
        page.body.should include "<h1>hello haml</h1>"
      end

      describe 'file with .html extension' do
        it 'is processed by default' do
          pending 'html extension support' do
            visit '/assets/templates/test_html.js'
            page.should have_content "$templateCache"
            page.body.should include "<h1>hello html</h1>"
          end
        end
      end

      describe "Configuration" do
        after { NGT.reset_config! }

        it "allows you to configure the module" do
          Rails.configuration.angular_ngt.module_name = 'myRailsModule'
          NGT.config.module_name.should == 'myRailsModule'
        end

        it "allows you to set the cache key" do
          Rails.configuration.angular_ngt.cache_id { |file| "rails-#{file}" }
          NGT.config.cache_id.call('test').should == 'rails-test'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
angular-ngt-0.2.0 spec/angular/html2js/railtie_spec.rb
angular-ngt-0.1.0 spec/angular/html2js/railtie_spec.rb