Logo: Relish

  1. Sign in

Project: Pannier v0.1.0

Writing assets

In order to use my assets in a site
As a developer
I want to write the HTML that will include my assets on the page

Background
Given
this code has executed
require 'pannier/mounted'
Scenarios
Writing JavaScript assets in production
Given
these files exist
input/scripts/one.js
input/scripts/two.js
And
the file ".assets.rb" contains
input  'input'
output 'output'

package :scripts do
  input  'scripts'
  assets '*.js'
end
And
the app is loaded in a production environment
And
the app has been processed
When
I write the tags as follows
tags = Pannier::Tags.new(@app)
tags.write(:scripts, :as => Pannier::Tags::JavaScript, :defer => 'defer')
Then
the following HTML should be written to the page
<script defer="defer" src="/one.js" type="text/javascript"></script>
<script defer="defer" src="/two.js" type="text/javascript"></script>
Writing CSS assets in production
Given
these files exist
input/styles/a.css
input/styles/b.css
And
the file ".assets.rb" contains
input  'input'
output 'output'

package :styles do
  input  'styles'
  assets '*.css'
end
And
the app is loaded in a production environment
And
the app has been processed
When
I write the tags as follows
tags = Pannier::Tags.new(@app)
tags.write(:styles, :as => Pannier::Tags::CSS, :media => 'screen')
Then
the following HTML should be written to the page
<link href="/a.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/b.css" media="screen" rel="stylesheet" type="text/css" />
Writing assets from a mounted app in production
Given
these files exist
input/styles/foo.css
And
the file ".assets.rb" contains
root   '/assets'

input  'input'
output 'output'

package :styles do
  input  'styles'
  assets 'foo.css'
end
And
the app is loaded in a production environment
And
the app has been processed
When
I write the tags as follows
tags = Pannier::Tags.new(@app)
tags.write(:styles, :as => Pannier::Tags::CSS)
Then
the following HTML should be written to the page
<link href="/assets/foo.css" rel="stylesheet" type="text/css" />

Last published about 4 years ago by joecorcoran.