wbzyl-sinatra-static-assets 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 5
4
+ :patch: 6
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+
3
+ require 'sinatra'
4
+ require 'sinatra/url_for'
5
+ require 'sinatra/static_assets'
6
+
7
+ get "/url_for" do
8
+ content_type "text/plain"
9
+ <<"EOD"
10
+ #{url_for("/")}
11
+ #{url_for("/foo")}
12
+ #{url_for("/foo", :full)}
13
+ EOD
14
+ end
15
+
16
+ get "/image_tag" do
17
+ content_type "text/plain"
18
+ <<"EOD"
19
+ #{image_tag("/images/foo.jpg", :alt => "[foo image]")}
20
+ EOD
21
+ end
@@ -1,91 +1,39 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require 'sinatra_app'
2
+ require 'test/unit'
3
+ require 'rack/test'
2
4
 
3
- class SinatraRDiscountTest < Test::Unit::TestCase
5
+ set :environment, :test
6
+
7
+ class SintraStaticAssetsTest < Test::Unit::TestCase
4
8
  include Rack::Test::Methods
5
-
6
- def rdiscount_app(&block)
7
- mock_app {
8
- set :views, File.dirname(__FILE__) + '/views'
9
- helpers Sinatra::RDiscount
10
- set :show_exceptions, false
11
- get '/', &block
12
- }
13
- get '/'
14
- end
15
-
16
- def test_renders_inline_strings
17
- rdiscount_app { rdiscount 'hello world' }
18
- assert last_response.ok?
19
- assert_equal "<p>hello world</p>\n", last_response.body
20
- end
21
-
22
- def test_renders_inline_erb_string
23
- rdiscount_app { rdiscount '{%= 1 + 1 %}' }
24
- assert last_response.ok?
25
- assert_equal "<p>2</p>\n", last_response.body
26
- end
27
9
 
28
- def test_renders_files_in_views_path
29
- rdiscount_app { rdiscount :hello }
30
- assert last_response.ok?
31
- assert_equal "<h1>hello world</h1>\n", last_response.body
32
- end
33
-
34
- def test_takes_locals_option
35
- rdiscount_app {
36
- locals = {:foo => 'Bar'}
37
- rdiscount "{%= foo %}", :locals => locals
38
- }
39
- assert last_response.ok?
40
- assert_equal "<p>Bar</p>\n", last_response.body
10
+ def app
11
+ Sinatra::Application
41
12
  end
42
13
 
43
- def test_renders_with_inline_layouts
44
- rdiscount_app {
45
- rdiscount 'Sparta', :layout => 'THIS. IS. <%= yield.upcase %>'
46
- }
14
+ def test_url_for_returns_absolute_paths_and_full_urls
15
+ get '/url_for', {}, 'SCRIPT_NAME' => '/bar'
47
16
  assert last_response.ok?
48
- assert_equal "THIS. IS. <P>SPARTA</P>\n", last_response.body
17
+ assert_equal last_response.body, <<EOD
18
+ /bar/
19
+ /bar/foo
20
+ http://example.org/bar/foo
21
+ EOD
49
22
  end
50
-
51
- def test_renders_with_file_layouts
52
- rdiscount_app {
53
- rdiscount 'hello world', :layout => :layout2
54
- }
23
+
24
+ def test_image_tag_returns_absolute_paths_and_full_urls
25
+ get '/image_tag', {}, 'SCRIPT_NAME' => '/bar'
55
26
  assert last_response.ok?
56
- assert_equal "erb layout\n<p>hello world</p>\n\n", last_response.body
27
+ assert_equal last_response.body, <<EOD
28
+ <img alt="[foo image]" src="/bar/images/foo.jpg">
29
+ EOD
57
30
  end
58
31
 
59
- def test_renders_erb_with_blocks
60
- mock_app {
61
- set :views, File.dirname(__FILE__) + '/views'
62
- helpers Sinatra::RDiscount
63
-
64
- def container
65
- yield
66
- end
67
- def is;
68
- "THIS. IS. SPARTA!"
69
- end
70
-
71
- get '/' do
72
- rdiscount '{% container do %} {%= is %} {% end %}'
73
- end
74
- }
75
-
76
- get '/'
77
- assert last_response.ok?
78
- assert_equal "<p> THIS. IS. SPARTA! </p>\n", last_response.body
79
- end
80
32
 
81
- def test_raises_error_if_template_not_found
82
- mock_app {
83
- set :views, File.dirname(__FILE__) + '/views'
84
- helpers Sinatra::RDiscount
85
- set :show_exceptions, false
86
-
87
- get('/') { rdiscount :no_such_template }
88
- }
89
- assert_raise(Errno::ENOENT) { get('/') }
90
- end
91
33
  end
34
+
35
+ __END__
36
+
37
+ stylesheet_link_tag "/stylesheets/screen.css", "/stylesheets/summer.css", :media => "projection"
38
+ javascript_script_tag "/javascripts/jquery.js", "/javascripts/summer.js", :charset => "iso-8859-2"
39
+ link_to "Tatry Mountains Rescue Team", "/topr"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbzyl-sinatra-static-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wlodek Bzyl
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-06 00:00:00 -07:00
12
+ date: 2009-07-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: "0"
33
+ version: 0.9.1
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: emk-sinatra-url-for
@@ -103,8 +103,8 @@ files:
103
103
  - examples/winter/views/layout.erb
104
104
  - examples/winter/winter.rb
105
105
  - lib/sinatra/static_assets.rb
106
+ - test/sinatra_app.rb
106
107
  - test/sinatra_static_assets_test.rb
107
- - test/test_helper.rb
108
108
  - LICENSE
109
109
  - README.markdown
110
110
  has_rdoc: false
@@ -134,8 +134,8 @@ signing_key:
134
134
  specification_version: 3
135
135
  summary: Sinatra extension providing helper methods to output tags for static assetgemspec.
136
136
  test_files:
137
- - test/test_helper.rb
138
137
  - test/sinatra_static_assets_test.rb
138
+ - test/sinatra_app.rb
139
139
  - examples/summer/summer.rb
140
140
  - examples/rsummer/summer.rb
141
141
  - examples/rwinter/winter.rb
data/test/test_helper.rb DELETED
@@ -1,21 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'rack/test'
4
-
5
- $LOAD_PATH.unshift(File.dirname(__FILE__))
6
- require 'sinatra/rdiscount'
7
-
8
- require 'rdiscount'
9
-
10
- class Test::Unit::TestCase
11
- include Rack::Test::Methods
12
-
13
- attr_reader :app
14
-
15
- # Sets up a Sinatra::Base subclass defined with the block
16
- # given. Used in setup or individual spec methods to establish
17
- # the application.
18
- def mock_app(base=Sinatra::Base, &block)
19
- @app = Sinatra.new(base, &block)
20
- end
21
- end