rspec-cells 0.1.10 → 0.1.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82183ffcbebeb8ae42aa604d38f0ccc156e3e1f0
4
- data.tar.gz: 47ea6cdfd59eabe643714d0fa2d483daedf16dc8
3
+ metadata.gz: 17af3de29745c3cc54fcf49748b91c5a2c076671
4
+ data.tar.gz: e85b1253250341cc536e7f691bed8b98eaa95bc2
5
5
  SHA512:
6
- metadata.gz: 4dfd2791cd1a01fe309d238959bdb7f2edac185b9e5c06ffa7bd7b863d23c5db9c02f9f25e2f81ea8a740699ad477bb29f0e6ce6fd0735f9ae6fdf8d4effc8d8
7
- data.tar.gz: 7f426354b63764010d5dcfaaeada105bc0d27adccf8b74e9fd639773c3080f1677c1de003113f717687e53bffcbe47c2b35f46b4f52f49a37d9aaafd1c5b0726
6
+ metadata.gz: 54c471f5c5ab63615d5a46ab4866b02f4c8d839e6df79340bc0dabed61d21b123cc6ef289bf03148c972cc2da3856c65be4f2c57446119041536e3d21c2a180c
7
+ data.tar.gz: 03854804f36c54717cbd8f8efb335b62ce25554880628c9b3a37f5fbb60c54d180c5657aab47f84dd400c59fd5d5758c92fc1a53b4f27c535eb817023d083ed2
data/CHANGES.textile CHANGED
@@ -1,3 +1,7 @@
1
+ h2. 0.1.11
2
+
3
+ * Make specs work with cell view models.
4
+
1
5
  h2. 0.1.10
2
6
 
3
7
  * Don't use `have_selector` in generated spec unless Capybara's around.
data/README.rdoc CHANGED
@@ -27,6 +27,8 @@ will create an exemplary <tt>spec/cells/blog_post_cell_spec.rb</tt> for you.
27
27
 
28
28
  == API
29
29
 
30
+ === Old API
31
+
30
32
  In your specs you can use +render_cell+ to assert the rendered markup (or whatever your state is supposed to do). This goes fine with Webrat matchers.
31
33
 
32
34
  it "renders posts count" do
@@ -44,6 +46,18 @@ You can create a cell instance using the +cell+ method, and then render afterwar
44
46
 
45
47
  After preparing the instance you can use +render_state+ for triggering the state.
46
48
 
49
+
50
+ === View Models
51
+
52
+ With the introduction of cells [view models]() you get a slightly different API for your specs (which is identical to your app's one).
53
+
54
+ it "renders empty posts list" do
55
+ posts = cell(:posts).count.should should have_css "#comment_new .flag", visible: true)
56
+ end
57
+
58
+ It's pretty simple, you use `#cell` to instantiate a view model instance and then call the state method on it.
59
+
60
+
47
61
  == Capybara
48
62
 
49
63
  If you want Capybara's string matchers be sure to bundle at least capybara +0.4.1+ in your Gemfile.
@@ -54,7 +68,7 @@ If you want Capybara's string matchers be sure to bundle at least capybara +0.4.
54
68
 
55
69
  In order to make the cells test generator work properly, capybara needs to be in both groups.
56
70
 
57
-
71
+
58
72
  You can then use capybara's matchers in your cell spec.
59
73
 
60
74
  describe PostsCell do
data/lib/rspec/cells.rb CHANGED
@@ -2,4 +2,4 @@ require 'cell/test_case'
2
2
  require 'rspec/core'
3
3
  require 'rspec/rails/adapters'
4
4
  require 'rspec/rails/example/rails_example_group'
5
- require 'rspec/rails/example/cell_example_group'
5
+ require 'rspec/cells/cell_example_group'
@@ -38,12 +38,22 @@ module RSpec::Rails
38
38
  end
39
39
 
40
40
  def cell(*args)
41
- super.extend(RenderStateWithCapybaraString)
41
+ Content.new(super)
42
42
  end
43
43
 
44
- module RenderStateWithCapybaraString
45
- def render_state(*args)
46
- Capybara.string(super)
44
+
45
+ # TODO: test if view model cell wrapping works (and normal dialect)
46
+ # test with both webrick and capybara
47
+ class Content
48
+ def initialize(cell)
49
+ @cell = cell
50
+ end
51
+
52
+ def method_missing(*args)
53
+ content = @cell.send(*args)
54
+
55
+ return Capybara.string(content) if content.is_a?(String)
56
+ content
47
57
  end
48
58
  end
49
59
  end
@@ -1,6 +1,6 @@
1
1
  module RSpec
2
2
  module Cells
3
- VERSION = '0.1.10'
3
+ VERSION = '0.1.11'
4
4
  end
5
5
  end
6
6
 
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,7 @@ require 'rspec-cells'
7
7
  require 'rspec/rails'
8
8
  require 'cell/base'
9
9
  require 'cell/test_case'
10
- require 'rspec/rails/example/cell_example_group'
10
+ require 'rspec/cells'
11
11
 
12
12
  module RSpecCells
13
13
  class Application < ::Rails::Application
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-cells
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-24 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -70,9 +70,9 @@ files:
70
70
  - lib/generators/rspec/templates/cell_spec.erb
71
71
  - lib/rspec-cells.rb
72
72
  - lib/rspec/cells.rb
73
+ - lib/rspec/cells/cell_example_group.rb
73
74
  - lib/rspec/cells/tasks.rake
74
75
  - lib/rspec/cells/version.rb
75
- - lib/rspec/rails/example/cell_example_group.rb
76
76
  - rspec-cells.gemspec
77
77
  - spec/cells/cell_generator_spec.rb
78
78
  - spec/cells/cell_spec_spec.rb
@@ -105,3 +105,4 @@ test_files:
105
105
  - spec/cells/cell_generator_spec.rb
106
106
  - spec/cells/cell_spec_spec.rb
107
107
  - spec/spec_helper.rb
108
+ has_rdoc: