rack-pjax 0.5.1 → 0.5.2

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/.gitignore CHANGED
@@ -3,3 +3,5 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  .rvmrc
6
+ .rbenv-version
7
+
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in rack-pjax.gemspec
4
3
  gemspec
4
+
5
+ group :test do
6
+ gem "rspec", ">2"
7
+ gem "rack-test"
8
+ end
data/Rakefile CHANGED
@@ -1 +1,14 @@
1
1
  require 'bundler/gem_tasks'
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.rspec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
6
+ end
7
+
8
+ desc "Run the specs"
9
+ task :default => :spec
10
+
11
+ desc 'Removes trailing whitespace'
12
+ task :whitespace do
13
+ sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
14
+ end
@@ -25,11 +25,7 @@ module Rack
25
25
  end
26
26
  response = [body]
27
27
 
28
- if headers['Content-Length']
29
- length = response.to_ary.inject(0) { |len, part| len + bytesize(part) }
30
- headers['Content-Length'] = length.to_s
31
- end
32
-
28
+ headers['Content-Length'] &&= bytesize(body).to_s
33
29
  end
34
30
  [status, headers, response]
35
31
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Pjax
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency('rack', '>1.0')
22
- s.add_dependency('nokogiri', '~>1.4.4')
22
+ s.add_dependency('nokogiri', '~>1.5.0')
23
23
  end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Rack::Pjax do
4
+ include Rack::Test::Methods # can be moved to config
5
+
6
+ def app
7
+ Rack::Builder.app do
8
+ use Rack::Pjax
9
+ run lambda { |env|
10
+ body = '<html><title>Hello</title><body><div data-pjax-container>World!</div></body></html>'
11
+ headers = {"Content-Length" => Rack::Utils.bytesize(body).to_s}
12
+ [200, headers, [body]]
13
+ }
14
+ end
15
+ end
16
+
17
+ context "when receiving a pjax-request" do
18
+ it "should return title-tag and inner-html of the pjax-container" do
19
+ get "/", {}, {'HTTP_X_PJAX' => true}
20
+ body.should == "<title>Hello</title>World!"
21
+ end
22
+
23
+ it "should recalculate the Content Length" do
24
+ get "/", {}, {'HTTP_X_PJAX' => true}
25
+ headers['Content-Length'].should == Rack::Utils.bytesize(body).to_s
26
+ end
27
+ end
28
+
29
+ context "when receiving a non-pjax request" do
30
+ it "should not alter the body" do
31
+ get "/"
32
+ body.should == '<html><title>Hello</title><body><div data-pjax-container>World!</div></body></html>'
33
+ end
34
+
35
+ it "should have the correct Content Length" do
36
+ get "/"
37
+ headers['Content-Length'].should == Rack::Utils.bytesize(body).to_s
38
+ end
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,34 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ $:.unshift File.expand_path("../../lib", __FILE__)
6
+ require "rack-pjax"
7
+
8
+ Bundler.require(:test)
9
+
10
+ # helpers ripped from wycat's Rack::Offline
11
+ # (https://github.com/wycats/rack-offline/blob/master/spec/spec_helper.rb)
12
+ module Rack::Test::Methods
13
+ def self.included(klass)
14
+ class << klass
15
+ attr_accessor :app
16
+ end
17
+ end
18
+
19
+ def body
20
+ last_response.body
21
+ end
22
+
23
+ def status
24
+ last_response.status
25
+ end
26
+
27
+ def headers
28
+ last_response.headers
29
+ end
30
+
31
+ def app
32
+ self.class.app
33
+ end
34
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-pjax
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gert Goet
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-07 00:00:00 +02:00
19
- default_executable:
18
+ date: 2011-11-01 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rack
@@ -41,12 +40,12 @@ dependencies:
41
40
  requirements:
42
41
  - - ~>
43
42
  - !ruby/object:Gem::Version
44
- hash: 15
43
+ hash: 3
45
44
  segments:
46
45
  - 1
47
- - 4
48
- - 4
49
- version: 1.4.4
46
+ - 5
47
+ - 0
48
+ version: 1.5.0
50
49
  type: :runtime
51
50
  version_requirements: *id002
52
51
  description: Serve pjax responses through rack middleware
@@ -68,7 +67,9 @@ files:
68
67
  - lib/rack/pjax.rb
69
68
  - lib/rack/pjax/version.rb
70
69
  - rack-pjax.gemspec
71
- has_rdoc: true
70
+ - spec/rack/pjax_spec.rb
71
+ - spec/spec.opts
72
+ - spec/spec_helper.rb
72
73
  homepage: https://github.com/eval/rack-pjax
73
74
  licenses: []
74
75
 
@@ -98,9 +99,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  requirements: []
99
100
 
100
101
  rubyforge_project: rack-pjax
101
- rubygems_version: 1.6.2
102
+ rubygems_version: 1.8.11
102
103
  signing_key:
103
104
  specification_version: 3
104
105
  summary: Serve pjax responses through rack middleware
105
- test_files: []
106
-
106
+ test_files:
107
+ - spec/rack/pjax_spec.rb
108
+ - spec/spec.opts
109
+ - spec/spec_helper.rb