cells 4.0.0.beta2 → 4.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d87f07c5656008a50a7a2386344a1517f311bfa
4
- data.tar.gz: af694d3c7ce83a603481c49ccb7bf13d1f101347
3
+ metadata.gz: 442134126a42a17ae056d6fea0138663b6868801
4
+ data.tar.gz: 78b1ebe96cb15081e067f62a10208648a71388b4
5
5
  SHA512:
6
- metadata.gz: 53a3d21440e92afd599d99e5c551be02c3684b970be815ad9a36f6570bd367c864286196a9756402bc3e0b134e4dbdec234cc7151f6f48dfdb86366e8309c7ee
7
- data.tar.gz: 291658a9ee8cacc3c50656f68c46028fb6bd0c38e4914664ae8ce20ce7d281ea1d4e423e97597ad86ddda4c145c920cfa7ae5eacd12ad8cee040a44301fe527f
6
+ metadata.gz: 8278561d5102e21559df5a51c852d74c6bc2b017db2d35d933a504ec8d5c521851c1179f5c5ac0d2f8f950be764233c4b4bf26750b59103639c2da96c2b36886
7
+ data.tar.gz: a3ee11a160976a710b93ed9e2ca1705ef64d34c1bc1d0b8c303932cd6a2f22a62898814a25e5897ce757664fae84c9d9da070e5dcc4fe9e55a89b9e9ad8d0b42
data/CHANGES.md CHANGED
@@ -18,6 +18,10 @@
18
18
 
19
19
  * When using HAML, we do not use any of HAML's helper hacks to "fix" ActionView and XSS. While you might not note this, it removes tons of code from our stack.
20
20
 
21
+ ## 4.0.0.beta3
22
+
23
+ * Introduce `Cell::Testing` for Rspec and MiniTest.
24
+ * Add ViewModel::OutputBuffer to be used in Erbse and soon in Haml.
21
25
 
22
26
  ## 3.11.2
23
27
 
data/README.md CHANGED
@@ -20,9 +20,9 @@ Cells is part of the [Trailblazer project](https://github.com/apotonick/trailbla
20
20
  ![](https://raw.githubusercontent.com/apotonick/trailblazer/master/doc/trb.jpg)
21
21
  </a>
22
22
 
23
- * Basic view models, replacing helpers, and how to structure your view into cell components (chapter 2 and 3).
24
- * Advanced Cells API (chapter 3 and 6).
25
- * Testing Cells (chapter 3 and 6).
23
+ * Basic view models, replacing helpers, and how to structure your view into cell components (chapter 2 and 4).
24
+ * Advanced Cells API (chapter 4 and 6).
25
+ * Testing Cells (chapter 4 and 6).
26
26
  * Cells Pagination with AJAX (chapter 6).
27
27
  * View Caching and Expiring (chapter 7).
28
28
 
@@ -862,7 +862,7 @@ This was mainly added to provide compatibility with 3rd-party gems like [Kaminar
862
862
 
863
863
  ## LICENSE
864
864
 
865
- Copyright (c) 2007-2014, Nick Sutterer
865
+ Copyright (c) 2007-2015, Nick Sutterer
866
866
 
867
867
  Copyright (c) 2007-2008, Solide ICT by Peter Bex and Bob Leers
868
868
 
@@ -23,4 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "uber", "~> 0.0.9"
24
24
  spec.add_dependency 'tilt', '>= 1.4', '< 3'
25
25
  spec.add_dependency 'disposable', '~> 0.0.8'
26
+
27
+ spec.add_dependency "capybara"
28
+
29
+ spec.add_development_dependency "cells-erb", ">= 0.0.2"
26
30
  end
@@ -7,7 +7,7 @@ gem "pry-byebug", :platforms => [:mri_20, :mri_21]
7
7
  gem "appraisal"
8
8
  gem "rake"
9
9
  gem "test_xml"
10
- gem "railties", :github => "rails/rails", :branch => "3-2-stable"
10
+ gem "railties", "~> 3.2.0"
11
11
  gem "tzinfo"
12
12
  gem "minitest", "4.7.5"
13
13
 
@@ -7,8 +7,8 @@ gem "pry-byebug", :platforms => [:mri_20, :mri_21]
7
7
  gem "appraisal"
8
8
  gem "rake"
9
9
  gem "test_xml"
10
- gem "railties", :github => "rails/rails", :branch => "4-2-stable"
11
- gem "activemodel", :github => "rails/rails", :branch => "4-2-stable"
10
+ gem "railties", "~> 4.2.0"
11
+ gem "activemodel", "~> 4.2.0"
12
12
  gem "minitest", "~> 5.2"
13
13
 
14
- gemspec :path => "../"
14
+ gemspec :path => "../"
@@ -8,3 +8,5 @@ module Cell
8
8
  include Testing
9
9
  end
10
10
  end
11
+
12
+ Cell::Testing.capybara = true if Object.const_defined?(:"Capybara")
@@ -1,14 +1,44 @@
1
- # Used in rspec-cells, etc.
2
1
  module Cell
2
+ # Builder methods and Capybara support.
3
+ # This gets included into Test::Unit, MiniTest::Spec, etc.
3
4
  module Testing
4
5
  def cell(name, *args)
5
- ViewModel.cell_for(name, controller, *args)
6
+ cell_for(ViewModel, name, *args)
6
7
  end
7
8
 
8
9
  def concept(name, *args)
9
- Concept.cell_for(name, controller, *args)
10
+ cell_for(Concept, name, *args)
10
11
  end
11
12
 
13
+ private
14
+ def cell_for(baseclass, name, *args)
15
+ cell = baseclass.cell(name, controller, *args)
16
+ cell.extend(Capybara) if Cell::Testing.capybara? # leaving this here as most people use Capybara.
17
+ cell
18
+ end
19
+
20
+
21
+ # Set this to true if you have Capybara loaded. Happens automatically in Cell::TestCase.
22
+ def self.capybara=(value)
23
+ @capybara = value
24
+ end
25
+
26
+ def self.capybara?
27
+ @capybara
28
+ end
29
+
30
+ # Extends ViewModel#call by injecting Capybara support.
31
+ module Capybara
32
+ module ToS
33
+ def to_s
34
+ native.to_s
35
+ end
36
+ end
37
+
38
+ def call(*)
39
+ ::Capybara.string(super).extend(ToS)
40
+ end
41
+ end
12
42
 
13
43
 
14
44
  # Rails specific.
@@ -3,7 +3,7 @@ module Cell
3
3
  MAJOR = 4
4
4
  MINOR = 0
5
5
  TINY = 0
6
- PRE = "beta2"
6
+ PRE = "beta3"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
9
9
  end
@@ -146,10 +146,27 @@ module Cell
146
146
  include Rendering
147
147
  include Caching
148
148
 
149
- def output_buffer
150
- @output_buffer ||= []
149
+
150
+ class OutputBuffer < Array
151
+ def encoding
152
+ "UTF-8"
153
+ end
154
+
155
+ def <<(string)
156
+ super
157
+ end
158
+ alias_method :safe_append=, :<<
159
+ alias_method :append=, :<<
160
+
161
+ def to_s # output_buffer is returned at the end of the precompiled template.
162
+ join
163
+ end
151
164
  end
152
- attr_writer :output_buffer # TODO: test that, this breaks in MM.
165
+ def output_buffer # called from the precompiled template. FIXME: this is currently not used in Haml.
166
+ @output_buffer ||= OutputBuffer.new
167
+ end
168
+ attr_writer :output_buffer # FIXME: where is that used? definitely not in Erbse.
169
+
153
170
 
154
171
  module TemplateFor
155
172
  def template_for(options)
@@ -2,6 +2,9 @@ require 'test_helper'
2
2
 
3
3
  class TestCaseTest < MiniTest::Spec
4
4
  class SongCell < Cell::ViewModel
5
+ def show
6
+ "Give It All!"
7
+ end
5
8
  end
6
9
 
7
10
  class Song
@@ -11,11 +14,14 @@ class TestCaseTest < MiniTest::Spec
11
14
 
12
15
  let (:song) { Object.new }
13
16
 
17
+ # #cell returns the instance
14
18
  describe "#cell" do
15
19
  subject { cell("test_case_test/song", song) }
16
20
 
17
21
  it { subject.must_be_instance_of SongCell }
18
22
  it { subject.model.must_equal song }
23
+
24
+ it { cell("test_case_test/song", collection: [song, song]).must_equal "Give It All!Give It All!" }
19
25
  end
20
26
 
21
27
 
@@ -25,9 +31,12 @@ class TestCaseTest < MiniTest::Spec
25
31
  it { subject.must_be_instance_of Song::Cell }
26
32
  it { subject.model.must_equal song }
27
33
  end
34
+ end
28
35
 
36
+ # capybara support
37
+ require "capybara"
29
38
 
30
- # capybara support
39
+ class CapybaraTest < MiniTest::Spec
31
40
  class CapybaraCell < Cell::ViewModel
32
41
  def show
33
42
  "<b>Grunt</b>"
@@ -35,8 +44,14 @@ class TestCaseTest < MiniTest::Spec
35
44
  end
36
45
 
37
46
  describe "capybara support" do
38
- subject { cell("test_case_test/capybara", nil) }
47
+ subject { cell("capybara_test/capybara", nil) }
48
+
49
+ before { Cell::Testing.capybara = true } # yes, a global switch!
50
+ after { Cell::Testing.capybara = false }
51
+
52
+ it { subject.(:show).has_selector?('b').must_equal true }
39
53
 
40
- it { subject.call } # add capybara tests here, @seuros.
54
+ # FIXME: this kinda sucks, what if you want the string in a Capybara environment?
55
+ it { subject.(:show).to_s.must_match "<b>Grunt</b>" }
41
56
  end
42
57
  end
@@ -4,9 +4,7 @@ rescue LoadError
4
4
  end
5
5
 
6
6
  ENV['RAILS_ENV'] = 'test'
7
-
8
7
  require_relative 'dummy/config/environment'
9
- require 'tilt/erubis' if Gem::Version.new(ActiveSupport::VERSION::STRING) >= Gem::Version.new('4.2.0')
10
8
 
11
9
  require 'minitest/autorun'
12
10
  require 'test_xml/mini_test'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cells
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta2
4
+ version: 4.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -72,6 +72,34 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 0.0.8
75
+ - !ruby/object:Gem::Dependency
76
+ name: capybara
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: cells-erb
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.0.2
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 0.0.2
75
103
  description: Cells replace partials and helpers with OOP view models, giving you proper
76
104
  encapsulation, inheritance, testability and a cleaner view architecture.
77
105
  email: