rspec-cells 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.textile +7 -0
- data/README.rdoc +24 -5
- data/lib/rspec/cells/version.rb +1 -1
- data/lib/rspec/rails/example/cell_example_group.rb +23 -9
- metadata +3 -4
- data/lib/rspec/cells/capybara/string_matchers.rb +0 -47
data/CHANGES.textile
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
h2. 0.0.5
|
2
|
+
|
3
|
+
h3. Changes
|
4
|
+
* Works with RSpec-2.6 now, too.
|
5
|
+
* We no longer provide our own Capybara string matchers but delegate to @Capybara.string@. If you ever used the @==@ equality check, this won't work anymore. As a tradeoff, you get all string matchers Capybara comes up with, making rspec-cells forward-compatible.
|
6
|
+
|
7
|
+
|
1
8
|
h2. 0.0.4
|
2
9
|
|
3
10
|
h3. Changes
|
data/README.rdoc
CHANGED
@@ -17,7 +17,7 @@ This gem runs with RSpec2 and Rails 3.0, so just add it to your app's +Gemfile+.
|
|
17
17
|
= Usage
|
18
18
|
|
19
19
|
Simply put all your specs in the <tt>spec/cells</tt> directory. However, let the cell generator do that for you!
|
20
|
-
|
20
|
+
|
21
21
|
rails g cell blog_post show -t rspec
|
22
22
|
|
23
23
|
will create an exemplary <tt>spec/cells/blog_post_cell_spec.rb</tt> for you.
|
@@ -40,13 +40,32 @@ If you want Capybara's string matchers be sure to bundle at least capybara +0.4.
|
|
40
40
|
|
41
41
|
You can then use capybara's matchers in your cell spec.
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
render_cell(:posts, :
|
43
|
+
describe PostsCell do
|
44
|
+
describe "search posts" do
|
45
|
+
let(:search) { render_cell(:posts, :search) }
|
46
|
+
|
47
|
+
it "should have a search field" do
|
48
|
+
search.should have_field("Search by Title")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have a search button" do
|
52
|
+
search.should have_button("Search")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "latest posts" do
|
57
|
+
subject { render_cell(:posts, :latest) }
|
58
|
+
|
59
|
+
it { should have_css("h3.title", :text => "Latest Posts") }
|
60
|
+
it { should have_table("latest_posts") }
|
61
|
+
it { should have_link("View all Posts") }
|
62
|
+
it { should_not have_button("Create Post") }
|
63
|
+
it { should_not have_field("Search by Title") }
|
46
64
|
end
|
47
65
|
end
|
48
66
|
|
49
|
-
|
67
|
+
You can see all capybara matchers and finders here: http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Simple
|
68
|
+
|
50
69
|
== Running the specs
|
51
70
|
|
52
71
|
Run your examples with
|
data/lib/rspec/cells/version.rb
CHANGED
@@ -7,21 +7,35 @@ module RSpec::Rails
|
|
7
7
|
include RSpec::Rails::RailsExampleGroup
|
8
8
|
include Cell::TestCase::TestMethods
|
9
9
|
include RSpec::Rails::ViewRendering
|
10
|
-
include RSpec::Rails::BrowserSimulators
|
11
10
|
|
12
|
-
|
11
|
+
if defined?(Webrat)
|
13
12
|
include Webrat::Matchers
|
14
13
|
include Webrat::Methods
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
|
-
include Capybara
|
16
|
+
if defined?(Capybara)
|
19
17
|
begin
|
20
|
-
include Capybara::
|
18
|
+
include Capybara::DSL
|
21
19
|
rescue NameError
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
include Capybara
|
21
|
+
end
|
22
|
+
|
23
|
+
# Overwrite to wrap render_cell into a Capybara custom string with a
|
24
|
+
# lot of matchers.
|
25
|
+
#
|
26
|
+
# Read more at:
|
27
|
+
#
|
28
|
+
# The Capybara.string method documentation:
|
29
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara#string-class_method
|
30
|
+
#
|
31
|
+
# Return value is an instance of Capybara::Node::Simple
|
32
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Simple
|
33
|
+
#
|
34
|
+
# That expose all the methods from the following capybara modules:
|
35
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers
|
36
|
+
# - http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders
|
37
|
+
def render_cell(*args)
|
38
|
+
Capybara.string super
|
25
39
|
end
|
26
40
|
end
|
27
41
|
|
@@ -41,7 +55,7 @@ module RSpec::Rails
|
|
41
55
|
render_views
|
42
56
|
subject { controller }
|
43
57
|
end
|
44
|
-
|
58
|
+
|
45
59
|
RSpec.configure do |c|
|
46
60
|
c.include self, :example_group => { :file_path => /spec\/cells/ }
|
47
61
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Sutterer
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-05-17 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- lib/generators/rspec/templates/cell_spec.erb
|
80
80
|
- lib/rspec-cells.rb
|
81
81
|
- lib/rspec/cells.rb
|
82
|
-
- lib/rspec/cells/capybara/string_matchers.rb
|
83
82
|
- lib/rspec/cells/tasks.rake
|
84
83
|
- lib/rspec/cells/version.rb
|
85
84
|
- lib/rspec/rails/example/cell_example_group.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# This includes a backported version of the Capybara string matchers David Chelimsky
|
2
|
-
# is preparing in https://github.com/dchelimsky/capybara/tree/rspec-matchers
|
3
|
-
#
|
4
|
-
# Looks like the string matchers will be included in Capybara 0.4.2 if the feature is ready.
|
5
|
-
#
|
6
|
-
# The branch have not being merged into master because it's missing support for the capybara
|
7
|
-
# page object.
|
8
|
-
#
|
9
|
-
# When we test a rendered cell with the `render_cell` method we get an ActionView::OutputBuffer
|
10
|
-
# instance, it is in short, a safe version of String, so we are testing a String, not a capybara
|
11
|
-
# page object. So the matchers are OK and the missing features won't bother us.
|
12
|
-
#
|
13
|
-
# Follow up in http://groups.google.com/group/ruby-capybara/browse_thread/thread/c8adaa8f750b1020
|
14
|
-
module RSpec
|
15
|
-
module Cells
|
16
|
-
module Capybara
|
17
|
-
module StringMatchers
|
18
|
-
extend ::RSpec::Matchers::DSL
|
19
|
-
|
20
|
-
%w[css xpath selector].each do |type|
|
21
|
-
matcher "have_#{type}" do |*args|
|
22
|
-
match_for_should do |string|
|
23
|
-
::Capybara::string(string).send("has_#{type}?", *args)
|
24
|
-
end
|
25
|
-
|
26
|
-
match_for_should_not do |string|
|
27
|
-
::Capybara::string(string).send("has_no_#{type}?", *args)
|
28
|
-
end
|
29
|
-
|
30
|
-
failure_message_for_should do |string|
|
31
|
-
"expected #{type} #{formatted(args)} to return something from:\n#{string}"
|
32
|
-
end
|
33
|
-
|
34
|
-
failure_message_for_should_not do |string|
|
35
|
-
"expected #{type} #{formatted(args)} not to return anything from:\n#{string}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def formatted(args)
|
39
|
-
args.length == 1 ? args.first.inspect : args.inspect
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|