rspec-cells 0.3.2 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1632cd4d7920d1673c4205ac06a0c42984936dd6
4
- data.tar.gz: 2e4d1ff66a84a43bf86a3ab907e761816f0d839e
2
+ SHA256:
3
+ metadata.gz: 44801a75a08a49bc26e5a72b126199b14b08a24e5b5ce6c0998d51468d7f9ccb
4
+ data.tar.gz: f291ede5db682f504d1716ca2dbd8b3ed189106765842b198f81945a27701009
5
5
  SHA512:
6
- metadata.gz: e0f03c8abea68185039f8c31d7c7a925b87f734dd635c553e09973f036dcea2700d70c411f225a68cd18a5182a69522ee26c3ac5662c8fcea7a2d4aa88b804c2
7
- data.tar.gz: 1bc38912b08475adb5e67cdf052ae1d6d9c7671cac402b03b29a3429c286cd50c50364f5b10c6e860b6529717fbe456e750c6b19140ed5f1ecfb4eff925b1ff8
6
+ metadata.gz: 20a7f4a5152c5cf6f6222c33d7a7958c204a71febfc44d2a6a05e7b8fcdbbfad1e7608638275bda6c98f3d1e9ff1a78b68a284c7f7a96f7b0c50f5d5d5c2109f
7
+ data.tar.gz: e9c08212997383bc3e37d05311417113a66afff461ab77257fd3410516a691069c96f0cc30759107ddf1e37e9858bfa756aed9114590562d053385921188372f
@@ -0,0 +1,26 @@
1
+ name: CI
2
+ on:
3
+ - push
4
+ - pull_request
5
+ jobs:
6
+ test:
7
+ name: Test (Ruby ${{ matrix.ruby }})
8
+ strategy:
9
+ matrix:
10
+ ruby:
11
+ - '2.3'
12
+ - '2.4'
13
+ - '2.5'
14
+ - '2.6'
15
+ - '2.7'
16
+ - '3.0'
17
+ - 'head'
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ bundler-cache: true
25
+ - name: RSpec
26
+ run: bundle exec rake spec
data/CHANGES.md CHANGED
@@ -1,3 +1,20 @@
1
+ # 0.3.6
2
+
3
+ * Support Ruby 3.
4
+
5
+ # 0.3.5
6
+
7
+ * Avoid global configuration change (#86)
8
+ * Support rspec-rails 4.x. This is required for Rails 6 (#88)
9
+
10
+ # 0.3.4
11
+
12
+ * Allow Cells 4.1.
13
+
14
+ # 0.3.3
15
+
16
+ * Maintenance release to make it work with rspec-rails 3.3.
17
+
1
18
  # 0.3.2
2
19
 
3
20
  * Bugfix: In 0.3.1, I included cells specific `#controller` code into every Rspec example. Thanks to @psynix for spotting this within minutes.
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- gem 'appraisal'
data/README.md CHANGED
@@ -4,7 +4,7 @@ _Spec your Cells._
4
4
 
5
5
  This plugin allows you to spec your cells with RSpec.
6
6
 
7
- Cells is Rails' popular [view components framework(http://github.com/apotonick/cells).
7
+ Cells is Rails' popular [view components framework](http://github.com/apotonick/cells).
8
8
 
9
9
  # Installation
10
10
 
@@ -20,12 +20,14 @@ Note: In case you're still using **Cells 3**, [go here](https://github.com/apoto
20
20
 
21
21
  # Usage
22
22
 
23
- Simply put all your specs in the <tt>spec/cells</tt> directory or add type: :cell to the describe block.
23
+ Simply put all your specs in the `spec/cells` directory or add `type: :cell` to the describe block.
24
24
  However, let the cell generator do that for you!
25
25
 
26
- rails g rspec:cell blog_post show
26
+ ```
27
+ rails g rspec:cell comment show
28
+ ```
27
29
 
28
- will create an exemplary <tt>spec/cells/blog_post_cell_spec.rb</tt> for you.
30
+ will create an exemplary `spec/cells/comment_cell_spec.rb` for you.
29
31
 
30
32
 
31
33
  # API
@@ -33,13 +35,27 @@ will create an exemplary <tt>spec/cells/blog_post_cell_spec.rb</tt> for you.
33
35
  To invoke rendering of a cell you use the exact same API as in your application.
34
36
 
35
37
  ```ruby
36
- it "renders post" do
37
- expect(cell(:posts).call).to have_content "Really Great!"
38
+ describe CommentCell do
39
+ it "renders comment" do
40
+ expect(cell(:comment).call).to have_content "Really Great!"
41
+ end
38
42
  end
39
43
  ```
40
44
 
41
45
  As you can see, it is nothing more than using `#cell` or `#concept`, invoke the default state using `#call` (or any other state with `call(:other_state)`) and use Rspecs and Capybara's matchers.
42
46
 
47
+
48
+ ## URL helpers
49
+
50
+ If your cells use helpers with controller dependency, you need to specify a controller to use in your test.
51
+
52
+ ```ruby
53
+ describe CommentCell do
54
+ controller CommentsController
55
+ ```
56
+
57
+ Excuse the clumsiness, but this is done wrong in Rails and not Cells' fault.
58
+
43
59
  # Running Specs
44
60
 
45
61
  Run your examples with
@@ -50,20 +66,22 @@ rake spec:cells
50
66
 
51
67
  # More docs
52
68
 
53
- All the docs about testing can be found on the [Trailblazer project page](http://trailblazerb.org/gems/cells/testing.html).
69
+ All the docs about testing can be found on the [Trailblazer project page](http://trailblazer.to/gems/cells/testing.html).
54
70
 
55
- == Test cells with caching
71
+ # Test cells with caching
56
72
 
57
73
  By default your code for caching code is not run if you set <tt>ActionController::Base.perform_caching = false</tt>
58
74
  That's a reasonable default but you might want to increase coverage by running caching code at least once.
59
75
  Here is an example:
60
76
 
77
+ ```ruby
61
78
  describe SomeCell do
62
79
  describe 'caching' do
63
80
  enable_cell_caching!
64
81
  # Code for testing...
65
82
  end
66
83
  end
84
+ ```
67
85
 
68
86
 
69
87
  # Contributors
@@ -9,10 +9,10 @@ module RSpec
9
9
 
10
10
  attr_reader :routes
11
11
 
12
- def method_missing(method, *args, &block)
12
+ def method_missing(method, *args, **kwargs, &block)
13
13
  # Send the route helpers to the application router.
14
14
  if route_defined?(method)
15
- controller.send(method, *args, &block)
15
+ controller.send(method, *args, **kwargs, &block)
16
16
  else
17
17
  super
18
18
  end
@@ -33,25 +33,32 @@ module RSpec
33
33
 
34
34
  before do # called before every it.
35
35
  @routes = ::Rails.application.routes
36
- ActionController::Base.allow_forgery_protection = false
37
36
  end
38
37
 
39
- # add Example::controller and ::controller_class. for some reasons, this doesn't get imported from Cell::Testing.
40
- extend RSpec::Cells::ExampleGroup::ControllerClass
41
- end
38
+ around do |example|
39
+ begin
40
+ old_value = ActionController::Base.allow_forgery_protection
41
+ ActionController::Base.allow_forgery_protection = false
42
42
 
43
+ example.run
43
44
 
44
- # DISCUSS: in MiniTest, this is done via inheritable_attr. Doesn't work in Rspec, though.
45
- module ControllerClass
46
- def controller_class
47
- @controller_class
45
+ ensure
46
+ ActionController::Base.allow_forgery_protection = old_value
47
+ end
48
48
  end
49
49
 
50
- def controller(name)
51
- @controller_class = name
52
- end
50
+ # add Example::controller and ::controller_class.
51
+ extend RSpec::Cells::ExampleGroup::Controller
52
+ let(:controller_class) {}
53
+ let(:controller) { controller_for(controller_class) }
53
54
  end
54
55
 
56
+
57
+ module Controller
58
+ def controller(name) # DSL for test, e.g. `controller SongsController`.
59
+ let (:controller_class) { name }
60
+ end
61
+ end
55
62
  end
56
63
  end
57
64
  end
@@ -1,6 +1,6 @@
1
1
  module RSpec
2
2
  module Cells
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.6"
4
4
  end
5
5
  end
6
6
 
data/lib/rspec/cells.rb CHANGED
@@ -2,6 +2,7 @@ require 'cell/testing'
2
2
 
3
3
  require 'rspec/core'
4
4
  require 'rspec/rails/adapters'
5
+ require 'rspec/rails/fixture_support'
5
6
  require 'rspec/rails/example/rails_example_group'
6
7
  require 'rspec/cells/example_group'
7
8
  require 'rspec/cells/caching'
data/rspec-cells.gemspec CHANGED
@@ -7,17 +7,28 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Nick Sutterer"]
9
9
  s.email = ["apotonick@gmail.com"]
10
- s.homepage = "http://rubygems.org/gems/rspec-cells"
10
+ s.homepage = "https://github.com/trailblazer/rspec-cells"
11
11
  s.summary = %q{Spec your cells.}
12
12
  s.description = %q{Use render_cell in your specs.}
13
13
  s.license = 'MIT'
14
+
15
+ s.metadata = {
16
+ "bug_tracker_uri" => "https://github.com/trailblazer/rspec-cells/issues",
17
+ "changelog_uri" => "https://github.com/trailblazer/rspec-cells/blob/master/CHANGES.md",
18
+ "documentation_uri" => "https://www.rubydoc.info/gems/rspec-cells/#{s.version}",
19
+ "homepage_uri" => s.homepage,
20
+ "source_code_uri" => "https://github.com/trailblazer/rspec-cells/tree/v#{s.version}",
21
+ "wiki_uri" => "https://github.com/trailblazer/rspec-cells/wiki",
22
+ }
23
+
14
24
  s.files = `git ls-files`.split("\n")
15
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
26
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
27
  s.require_paths = ["lib"]
18
28
 
19
- s.add_runtime_dependency 'rspec-rails', '~> 3.2'
20
- s.add_runtime_dependency "cells", "~> 4.0.0.beta"
29
+ s.add_runtime_dependency 'rspec-rails', '< 6.0'
30
+ s.add_runtime_dependency "cells", ">= 4.0.0", "< 6.0.0"
31
+
21
32
 
22
- # s.add_development_dependency "capybara" # FIXME: please make test for Capybara run.
33
+ s.add_development_dependency "capybara" # FIXME: please make test for Capybara run.
23
34
  end
@@ -17,7 +17,6 @@ class SongCell < Cell::ViewModel
17
17
  end
18
18
 
19
19
  describe "Cell::Testing in specs", type: :cell do
20
-
21
20
  describe "#cell" do
22
21
  it { expect(cell(:dummy).call).to have_text("I'm Dummy.") }
23
22
 
metadata CHANGED
@@ -1,43 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-cells
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.6
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-05-28 00:00:00.000000000 Z
11
+ date: 2021-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cells
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.0.beta
33
+ version: 4.0.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 6.0.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 4.0.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 6.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: capybara
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
39
59
  - !ruby/object:Gem::Version
40
- version: 4.0.0.beta
60
+ version: '0'
41
61
  description: Use render_cell in your specs.
42
62
  email:
43
63
  - apotonick@gmail.com
@@ -45,9 +65,8 @@ executables: []
45
65
  extensions: []
46
66
  extra_rdoc_files: []
47
67
  files:
68
+ - ".github/workflows/ci.yml"
48
69
  - ".gitignore"
49
- - ".travis.yml"
50
- - Appraisals
51
70
  - CHANGES.md
52
71
  - Gemfile
53
72
  - MIT-LICENSE
@@ -67,10 +86,16 @@ files:
67
86
  - spec/cells/cell_generator_spec.rb
68
87
  - spec/cells/cell_spec_spec.rb
69
88
  - spec/spec_helper.rb
70
- homepage: http://rubygems.org/gems/rspec-cells
89
+ homepage: https://github.com/trailblazer/rspec-cells
71
90
  licenses:
72
91
  - MIT
73
- metadata: {}
92
+ metadata:
93
+ bug_tracker_uri: https://github.com/trailblazer/rspec-cells/issues
94
+ changelog_uri: https://github.com/trailblazer/rspec-cells/blob/master/CHANGES.md
95
+ documentation_uri: https://www.rubydoc.info/gems/rspec-cells/0.3.6
96
+ homepage_uri: https://github.com/trailblazer/rspec-cells
97
+ source_code_uri: https://github.com/trailblazer/rspec-cells/tree/v0.3.6
98
+ wiki_uri: https://github.com/trailblazer/rspec-cells/wiki
74
99
  post_install_message:
75
100
  rdoc_options: []
76
101
  require_paths:
@@ -86,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
111
  - !ruby/object:Gem::Version
87
112
  version: '0'
88
113
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.2.2
114
+ rubygems_version: 3.0.8
91
115
  signing_key:
92
116
  specification_version: 4
93
117
  summary: Spec your cells.
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- rvm:
2
- - 1.9.3
3
- - 2.0.0
4
- - 2.1.5
5
- - 2.2.0
6
- - rbx-2
7
-
8
- gemfile:
9
- - gemfiles/rspec3.gemfile
10
-
11
- notifications:
12
- irc: "irc.freenode.org#cells"
data/Appraisals DELETED
@@ -1,8 +0,0 @@
1
- appraise "rspec2" do
2
- gem "rspec-rails", "~> 2.14.0"
3
- end
4
-
5
- appraise "rspec3" do
6
- gem "rspec-rails", ">= 3.0.0"
7
- end
8
-