rspec-cells 0.1.12 → 0.2.0

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: 63aa56b8e9ae132537ab2992ad9ed08783ed7350
4
- data.tar.gz: 825b81132c90eac0bbec8924205c9318e4c94868
3
+ metadata.gz: b00052a706101e635fbfd70d6d3b38feef321326
4
+ data.tar.gz: 22ae5044d29a41ca4107dc3be88e888b21177c35
5
5
  SHA512:
6
- metadata.gz: 17ee62a830230d3823dde7cd9aeaf41e1789aff3381b21f89a3caf0bf503a3ccf1caffa7ad2f4fafcab87a55f0a5d163acd355b0c099a8d541f1ab1ccb588722
7
- data.tar.gz: 8171f1ff29d0fbaefe365c65973f58dd5fea98e32807c1798608c2eaf90ad0436c6b311ee88308d1c66870e34b2fba97a2e78b1c81710a7f0d6d99af9193e229
6
+ metadata.gz: 3d8d79e4ffc7bac6710ae8f2ed3c50a9b721726e44129001aed422f791a7b3394c8ce45e26509d78627629f216c4680934ae5fbf45cbc42feeba750696831b0d
7
+ data.tar.gz: 5443a773b0ac3191fd81bed77f5d11507f192eacdd14e114241ccf7e48bcf46d6dc62f69676f19f63b445ea723bd8175d9571d185d534cde2c857669076ca705
data/.gitignore CHANGED
@@ -1,5 +1,5 @@
1
1
  .idea/
2
- Gemfile.lock
2
+ *.lock
3
3
  *.gem
4
4
  /.rvmrc
5
5
  spec/tmp
data/.travis.yml CHANGED
@@ -1,5 +1,12 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.2
5
+ - rbx-2
6
+
7
+ gemfile:
8
+ - gemfiles/rspec2.gemfile
9
+ - gemfiles/rspec3.gemfile
10
+
4
11
  notifications:
5
12
  irc: "irc.freenode.org#cells"
data/Appraisals ADDED
@@ -0,0 +1,8 @@
1
+ appraise "rspec2" do
2
+ gem "rspec-rails", "2.99"
3
+ end
4
+
5
+ appraise "rspec3" do
6
+ gem "rspec-rails", ">= 3.0.0"
7
+ end
8
+
data/CHANGES.textile CHANGED
@@ -1,3 +1,7 @@
1
+ h2. 0.2.0
2
+
3
+ * rspec-cells only works with rspec >= 2.99 and uses the expect syntax. Thanks to @seuros for his help.
4
+
1
5
  h2. 0.1.12
2
6
 
3
7
  * Remove `respond_to` tests from generated tests.
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "3.2.12"
5
+ gem 'rails', '~> 3.2'
6
+ gem 'appraisal'
data/README.rdoc CHANGED
@@ -12,7 +12,7 @@ Cells is Rails' popular {view components framework}[http://github.com/apotonick/
12
12
 
13
13
  This gem runs with RSpec2 and Rails >= 3.x, so just add it to your app's +Gemfile+.
14
14
 
15
- group :test do
15
+ group :development, :test do
16
16
  gem "rspec-cells"
17
17
  end
18
18
 
@@ -32,7 +32,7 @@ will create an exemplary <tt>spec/cells/blog_post_cell_spec.rb</tt> for you.
32
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.
33
33
 
34
34
  it "renders posts count" do
35
- render_cell(:posts, :count).should have_selector("p", :content => "4 posts!")
35
+ expect(render_cell(:posts, :count)).to have_selector("p", :content => "4 posts!")
36
36
  end
37
37
 
38
38
  You can create a cell instance using the +cell+ method, and then render afterwards. This is helpful when you're planning to stub things or if you need to pass arguments to the cell constructor.
@@ -41,7 +41,7 @@ You can create a cell instance using the +cell+ method, and then render afterwar
41
41
  posts = cell(:posts)
42
42
  posts.stub(:recent_posts).and_return([])
43
43
 
44
- posts.render_state(:count).should have_selector("p", :content => "No posts!")
44
+ expect(posts.render_state(:count)).to have_selector("p", :content => "No posts!")
45
45
  end
46
46
 
47
47
  After preparing the instance you can use +render_state+ for triggering the state.
@@ -52,7 +52,7 @@ After preparing the instance you can use +render_state+ for triggering the state
52
52
  With the introduction of cells [view models](https://github.com/apotonick/cells#view-models) you get a slightly different API for your specs (which is identical to your app's one).
53
53
 
54
54
  it "renders empty posts list" do
55
- posts = cell(:posts).count.should should have_css "#comment_new .flag", visible: true)
55
+ expect(cell(:posts).count.to be_zero
56
56
  end
57
57
 
58
58
  It's pretty simple, you use `#cell` to instantiate a view model instance and then call the state method on it.
@@ -76,22 +76,22 @@ You can then use capybara's matchers in your cell spec.
76
76
  let(:search) { render_cell(:posts, :search) }
77
77
 
78
78
  it "should have a search field" do
79
- search.should have_field("Search by Title")
79
+ expect(search).to have_field("Search by Title")
80
80
  end
81
81
 
82
82
  it "should have a search button" do
83
- search.should have_button("Search")
83
+ expect(search).to have_button("Search")
84
84
  end
85
85
  end
86
86
 
87
87
  describe "latest posts" do
88
88
  subject { render_cell(:posts, :latest) }
89
89
 
90
- it { should have_css("h3.title", :text => "Latest Posts") }
91
- it { should have_table("latest_posts") }
92
- it { should have_link("View all Posts") }
93
- it { should_not have_button("Create Post") }
94
- it { should_not have_field("Search by Title") }
90
+ it { is_expected.to have_css("h3.title", :text => "Latest Posts") }
91
+ it { is_expected.to have_table("latest_posts") }
92
+ it { is_expected.to have_link("View all Posts") }
93
+ it { is_expected.to_not have_button("Create Post") }
94
+ it { is_expected.to_not have_field("Search by Title") }
95
95
  end
96
96
  end
97
97
 
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2"
6
+ gem "appraisal"
7
+ gem "rspec-rails", "2.99"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2"
6
+ gem "appraisal"
7
+ gem "rspec-rails", ">= 3.0.0"
8
+
9
+ gemspec :path => "../"
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe <%= class_name %>Cell do
3
+ describe <%= class_name %>Cell, type: :cell do
4
4
 
5
- context "cell rendering" do
5
+ context 'cell rendering' do
6
6
  <%- actions.each_with_index do |state, index| -%>
7
- context "rendering <%= state %>" do
7
+ context 'rendering <%= state %>' do
8
8
  subject { render_cell(<%= cell_name %>, :<%= state %>) }
9
9
 
10
10
  <%- if defined?(Capybara) -%>
11
- it { should have_selector("h1", :text => "<%= class_name %>#<%= state %>") }
12
- it { should have_selector("p", :text => "Find me in app/cells/<%= file_path %>/<%= state %>.html") }
11
+ it { is_expected.to have_selector('h1', text: '<%= class_name %>#<%= state %>') }
12
+ it { is_expected.to have_selector('p', text: 'Find me in app/cells/<%= file_path %>/<%= state %>.html') }
13
13
  <%- else -%>
14
- it { should include "<%= class_name %>#<%= state %>" }
15
- it { should include "Find me in app/cells/<%= file_path %>/<%= state %>.html" }
14
+ it { is_expected.to include '<%= class_name %>#<%= state %>' }
15
+ it { is_expected.to include 'Find me in app/cells/<%= file_path %>/<%= state %>.html' }
16
16
  <%- end -%>
17
17
  end
18
18
  <%- unless index == actions.length - 1 -%>
@@ -7,16 +7,15 @@ module RSpec::Rails
7
7
  include Cell::TestCase::TestMethods
8
8
  include ActionController::UrlFor
9
9
 
10
- if defined?(Webrat)
11
- include Webrat::Matchers
12
- include Webrat::Methods
13
- end
10
+ if defined?(::Webrat)
11
+ include ::Webrat::Matchers
12
+ include ::Webrat::Methods
14
13
 
15
- if defined?(Capybara)
14
+ elsif defined?(::Capybara)
16
15
  begin
17
- include Capybara::DSL
16
+ include ::Capybara::DSL
18
17
  rescue NameError
19
- include Capybara
18
+ include ::Capybara
20
19
  end
21
20
 
22
21
  # Overwrite to wrap render_cell into a Capybara custom string with a
@@ -33,11 +32,11 @@ module RSpec::Rails
33
32
  # That expose all the methods from the following capybara modules:
34
33
  # - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers
35
34
  # - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders
36
- def render_cell(*args)
35
+ def render_cell(*)
37
36
  Capybara.string super
38
37
  end
39
38
 
40
- def cell(*args)
39
+ def cell(*)
41
40
  Content.new(super)
42
41
  end
43
42
 
@@ -84,5 +83,6 @@ module RSpec::Rails
84
83
  end
85
84
 
86
85
  RSpec.configure do |c|
87
- c.include RSpec::Rails::CellExampleGroup, :example_group => { :file_path => /spec\/cells/ }
86
+ c.include RSpec::Rails::CellExampleGroup, :file_path => /spec\/cells/
87
+ c.include RSpec::Rails::CellExampleGroup, :type => :cell
88
88
  end
@@ -1,6 +1,6 @@
1
1
  module RSpec
2
2
  module Cells
3
- VERSION = '0.1.12'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
6
6
 
data/lib/rspec-cells.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rails/railtie'
1
2
  module RSpec
2
3
  module Cells
3
4
  class Railtie < ::Rails::Railtie
data/rspec-cells.gemspec CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_runtime_dependency "railties", ">= 3.0"
23
- s.add_runtime_dependency "rspec-rails", ">= 2.2.0"
23
+ s.add_runtime_dependency 'rspec-rails', '>= 2.99'
24
24
  s.add_runtime_dependency "cells", ">= 3.4.0"
25
25
  end
@@ -32,24 +32,24 @@ describe Rspec::Generators::CellGenerator do
32
32
 
33
33
  it "creates widget spec" do
34
34
  test.assert_file "spec/cells/twitter_cell_spec.rb", t("require 'spec_helper'")
35
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('describe TwitterCell do')
36
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('context "cell rendering" do')
35
+ test.assert_file "spec/cells/twitter_cell_spec.rb", t('describe TwitterCell, type: :cell do')
36
+ test.assert_file "spec/cells/twitter_cell_spec.rb", t('context \'cell rendering\' do')
37
37
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('end')
38
38
  end
39
39
 
40
40
  it 'creates display state' do
41
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('context "rendering display" do')
41
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('context \'rendering display\' do')
42
42
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('subject { render_cell(:twitter, :display) }')
43
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should have_selector("h1", :text => "Twitter#display") }')
44
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should have_selector("p", :text => "Find me in app/cells/twitter/display.html") }')
43
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('it { is_expected.to have_selector(\'h1\', text: \'Twitter#display\') }')
44
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('it { is_expected.to have_selector(\'p\', text: \'Find me in app/cells/twitter/display.html\') }')
45
45
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('end')
46
46
  end
47
47
 
48
48
  it 'creates form state' do
49
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('context "rendering form" do')
49
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('context \'rendering form\' do')
50
50
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('subject { render_cell(:twitter, :form) }')
51
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should have_selector("h1", :text => "Twitter#form") }')
52
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should have_selector("p", :text => "Find me in app/cells/twitter/form.html") }')
51
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('it { is_expected.to have_selector(\'h1\', text: \'Twitter#form\') }')
52
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('it { is_expected.to have_selector(\'p\', text: \'Find me in app/cells/twitter/form.html\') }')
53
53
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('end')
54
54
  end
55
55
  end
@@ -65,24 +65,24 @@ describe Rspec::Generators::CellGenerator do
65
65
 
66
66
  it "creates widget spec" do
67
67
  test.assert_file "spec/cells/twitter_cell_spec.rb", t("require 'spec_helper'")
68
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('describe TwitterCell do')
69
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('context "cell rendering" do')
68
+ test.assert_file "spec/cells/twitter_cell_spec.rb", t('describe TwitterCell, type: :cell do')
69
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('context \'cell rendering\' do')
70
70
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('end')
71
71
  end
72
72
 
73
73
  it 'creates display state' do
74
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('context "rendering display" do')
74
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('context \'rendering display\' do')
75
75
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('subject { render_cell(:twitter, :display) }')
76
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should include "Twitter#display" }')
77
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should include "Find me in app/cells/twitter/display.html" }')
76
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('it { is_expected.to include \'Twitter#display\' }')
77
+ test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { is_expected.to include \'Find me in app/cells/twitter/display.html\' }')
78
78
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('end')
79
79
  end
80
80
 
81
81
  it 'creates form state' do
82
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('context "rendering form" do')
82
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('context \'rendering form\' do')
83
83
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('subject { render_cell(:twitter, :form) }')
84
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should include "Twitter#form" }')
85
- test.assert_file "spec/cells/twitter_cell_spec.rb", t('it { should include "Find me in app/cells/twitter/form.html" }')
84
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('it { is_expected.to include \'Twitter#form\' }')
85
+ test.assert_file 'spec/cells/twitter_cell_spec.rb', t('it { is_expected.to include \'Find me in app/cells/twitter/form.html\' }')
86
86
  test.assert_file "spec/cells/twitter_cell_spec.rb", t('end')
87
87
  end
88
88
  end
@@ -101,24 +101,24 @@ describe Rspec::Generators::CellGenerator do
101
101
 
102
102
  it "creates widget spec" do
103
103
  test.assert_file GENERATED_FILE, t("require 'spec_helper'")
104
- test.assert_file GENERATED_FILE, t('describe Forum::CommentCell do')
105
- test.assert_file GENERATED_FILE, t('context "cell rendering" do')
104
+ test.assert_file GENERATED_FILE, t('describe Forum::CommentCell, type: :cell do')
105
+ test.assert_file GENERATED_FILE, t('context \'cell rendering\' do')
106
106
  test.assert_file GENERATED_FILE, t('end')
107
107
  end
108
108
 
109
109
  it 'creates display state' do
110
- test.assert_file GENERATED_FILE, t('context "rendering display" do')
110
+ test.assert_file GENERATED_FILE, t('context \'rendering display\' do')
111
111
  test.assert_file GENERATED_FILE, t('subject { render_cell("forum/comment", :display) }')
112
- test.assert_file GENERATED_FILE, t('it { should include "Forum::Comment#display" }')
113
- test.assert_file GENERATED_FILE, t('it { should include "Find me in app/cells/forum/comment/display.html" }')
112
+ test.assert_file GENERATED_FILE, t('it { is_expected.to include \'Forum::Comment#display\' }')
113
+ test.assert_file GENERATED_FILE, t('it { is_expected.to include \'Find me in app/cells/forum/comment/display.html\' }')
114
114
  test.assert_file GENERATED_FILE, t('end')
115
115
  end
116
116
 
117
117
  it 'creates form state' do
118
- test.assert_file GENERATED_FILE, t('context "rendering form" do')
118
+ test.assert_file GENERATED_FILE, t('context \'rendering form\' do')
119
119
  test.assert_file GENERATED_FILE, t('subject { render_cell("forum/comment", :form) }')
120
- test.assert_file GENERATED_FILE, t('it { should include "Forum::Comment#form" }')
121
- test.assert_file GENERATED_FILE, t('it { should include "Find me in app/cells/forum/comment/form.html" }')
120
+ test.assert_file GENERATED_FILE, t('it { is_expected.to include \'Forum::Comment#form\' }')
121
+ test.assert_file GENERATED_FILE, t('it { is_expected.to include \'Find me in app/cells/forum/comment/form.html\' }')
122
122
  test.assert_file GENERATED_FILE, t('end')
123
123
  end
124
124
  end
@@ -22,26 +22,26 @@ module RSpec::Rails
22
22
  end
23
23
 
24
24
  it "adds :type => :cell to the metadata" do
25
- group.metadata[:type].should eq(:cell)
25
+ expect(group.metadata[:type]).to eq(:cell)
26
26
  end
27
27
 
28
28
  describe "#render_cell" do
29
29
  it "renders a state" do
30
- group.new.render_cell(:dummy, :show).should == "<p>I'm Dummy.</p>"
30
+ expect(group.new.render_cell(:dummy, :show)).to eq("<p>I'm Dummy.</p>")
31
31
  end
32
32
 
33
33
  it "allows passing state args" do
34
- group.new.render_cell(:dummy, :update, "this").should == "Updating this."
34
+ expect(group.new.render_cell(:dummy, :update, "this")).to eq('Updating this.')
35
35
  end
36
36
  end
37
37
 
38
38
  it "responds to #cell" do
39
- group.new.cell(:dummy).should be_kind_of(DummyCell)
39
+ expect(group.new.cell(:dummy)).to be_kind_of(DummyCell)
40
40
  end
41
41
 
42
42
  # FIXME: could anyone make capybara/rails work in these tests?
43
43
  # it "allows using matchers with #render_state" do
44
- # cell(:dummy).render_state(:show).should have_selector("p")
44
+ # expect(cell(:dummy).render_state(:show)).to have_selector("p")
45
45
  # end
46
46
 
47
47
  context "as a test writer" do
@@ -49,15 +49,15 @@ module RSpec::Rails
49
49
 
50
50
  it "should support _path helpers from the controller" do
51
51
  # We have to stub include so that things determine the route exists.
52
- Rails.application.routes.named_routes.helpers.stub(:include?).and_return(:true)
53
- @controller.should_receive(:test_path).at_least(:once)
52
+ allow(Rails.application.routes.named_routes.helpers).to receive(:include?).and_return(true)
53
+ expect(@controller).to receive(:test_path).at_least(:once)
54
54
  test_path
55
55
  end
56
56
 
57
57
  it "should support polymorphic_path from the controller" do
58
58
  # We have to stub include so that things determine the route exists.
59
- Rails.application.routes.named_routes.helpers.stub(:include?).and_return(:true)
60
- @controller.should_receive(:test_path).at_least(:once)
59
+ allow(Rails.application.routes.named_routes.helpers).to receive(:include?).and_return(true)
60
+ expect(@controller).to receive(:test_path).at_least(:once)
61
61
  polymorphic_path(:test)
62
62
  end
63
63
 
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,9 @@ require 'rubygems' unless defined?(Gem)
2
2
  require 'bundler/setup'
3
3
 
4
4
  #$:.unshift File.dirname(__FILE__) # add current dir to LOAD_PATHS
5
- require "rails/all"
5
+ require 'rails'
6
+ require 'action_controller/railtie'
7
+ require 'action_view/railtie'
6
8
  require 'rspec-cells'
7
9
  require 'rspec/rails'
8
10
  require 'cell/base'
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.12
4
+ version: 0.2.0
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-04-27 00:00:00.000000000 Z
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.0
33
+ version: '2.99'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.2.0
40
+ version: '2.99'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cells
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -61,11 +61,14 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".travis.yml"
64
+ - Appraisals
64
65
  - CHANGES.textile
65
66
  - Gemfile
66
67
  - MIT-LICENSE
67
68
  - README.rdoc
68
69
  - Rakefile
70
+ - gemfiles/rspec2.gemfile
71
+ - gemfiles/rspec3.gemfile
69
72
  - lib/generators/rspec/cell_generator.rb
70
73
  - lib/generators/rspec/templates/cell_spec.erb
71
74
  - lib/rspec-cells.rb