rspec-cells 0.0.3 → 0.0.4

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.
data/CHANGES.textile CHANGED
@@ -1,3 +1,9 @@
1
+ h2. 0.0.4
2
+
3
+ h3. Changes
4
+ * Use Capybara's string matchers in your specs now (if you like)!
5
+
6
+
1
7
  h2. 0.0.2
2
8
 
3
9
  h3. Bugfixes
data/README.rdoc CHANGED
@@ -16,15 +16,38 @@ This gem runs with RSpec2 and Rails 3.0, so just add it to your app's +Gemfile+.
16
16
 
17
17
  = Usage
18
18
 
19
- Put all your specs under <tt>spec/cells</tt> folder. Here is how a simple spec could look like.
19
+ Simply put all your specs in the <tt>spec/cells</tt> directory. However, let the cell generator do that for you!
20
+
21
+ rails g cell blog_post show -t rspec
22
+
23
+ will create an exemplary <tt>spec/cells/blog_post_cell_spec.rb</tt> for you.
24
+
25
+ == Webrat
26
+
27
+ Webrat matchers just work as you might have expected - here is how a simple spec could look like.
20
28
 
21
29
  describe PostsCell do
22
30
  it "should render the posts count" do
23
31
  render_cell(:posts, :count).should have_selector("p", :content => "4 posts!")
24
32
  end
33
+ end
34
+
35
+ == Capybara
36
+
37
+ If you want Capybara's string matchers be sure to bundle at least capybara +0.4.1+ in your Gemfile.
25
38
 
39
+ gem "capybara", "~> 0.4.1"
40
+
41
+ You can then use capybara's matchers in your cell spec.
42
+
43
+ describe PostsCell do
44
+ it "should render the posts count" do
45
+ render_cell(:posts, :box).should have_css("div#widget h3")
46
+ end
26
47
  end
27
48
 
49
+
50
+ == Running the specs
28
51
 
29
52
  Run your examples with
30
53
 
@@ -32,6 +55,9 @@ Run your examples with
32
55
 
33
56
  If you need more helpers, matchers and stuff, {just let us know}[http://cells.rubyforge.org/community.html].
34
57
 
58
+ == Contributors
59
+
60
+ * Jorge Calás Lozano <calas@qvitta.net> (Cleanup, capybara string matchers)
35
61
 
36
62
  == LICENSE
37
63
 
@@ -6,16 +6,15 @@ describe <%= class_name %>Cell do
6
6
  context "rendering <%= state %>" do
7
7
  subject { render_cell(:<%= file_name %>, :<%= state %>) }
8
8
 
9
- it { should have_selector("h1", :text => "<%= class_name %>#<%= state %>") }
10
- it { should have_selector("p", :text => "Find me in app/cells/<%= file_name %>/<%= state %>.html") }
9
+ it { should have_selector("h1", :content => "<%= class_name %>#<%= state %>") }
10
+ it { should have_selector("p", :content => "Find me in app/cells/<%= file_name %>/<%= state %>.html") }
11
11
  end
12
12
  <% end %>
13
13
  end
14
14
 
15
15
 
16
16
  context "cell instance" do
17
- subject { cell(:<%= file_name %>) }
18
-
17
+ subject { cell(:<%= file_name %>) }
19
18
  <% for state in actions %>
20
19
  it { should respond_to(:<%= state %>) }
21
20
  <% end %>
@@ -0,0 +1,47 @@
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
@@ -1,6 +1,6 @@
1
1
  module RSpec # :nodoc:
2
2
  module Cells # :nodoc:
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
6
6
 
@@ -1,8 +1,6 @@
1
1
  module RSpec::Rails
2
2
  # Lets you call #render_cell in Rspec2. Move your cell specs to <tt>spec/cells/</tt>.
3
3
  module CellExampleGroup
4
- VERSION = "0.0.1"
5
-
6
4
  extend ActiveSupport::Concern
7
5
  extend RSpec::Rails::ModuleInclusion
8
6
 
@@ -21,9 +19,9 @@ module RSpec::Rails
21
19
  begin
22
20
  include Capybara::RSpec::StringMatchers
23
21
  rescue NameError
24
- # Read more in the source file
25
- require 'rspec_cells/capybara/string_matchers'
26
- include RSpecCells::Capybara::StringMatchers
22
+ # do this till capybara 0.4.2 is out.
23
+ require 'rspec/cells/capybara/string_matchers'
24
+ include RSpec::Cells::Capybara::StringMatchers
27
25
  end
28
26
  end
29
27
 
@@ -43,9 +41,7 @@ module RSpec::Rails
43
41
  render_views
44
42
  subject { controller }
45
43
  end
46
-
47
- # RSpec.configure &include_self_when_dir_matches('spec','cells') # adds a filter to Configuration that includes this module in matching groups.
48
-
44
+
49
45
  RSpec.configure do |c|
50
46
  c.include self, :example_group => { :file_path => /spec\/cells/ }
51
47
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
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-01-31 00:00:00 +01:00
17
+ date: 2011-02-04 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -79,10 +79,10 @@ 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
82
83
  - lib/rspec/cells/tasks.rake
83
84
  - lib/rspec/cells/version.rb
84
85
  - lib/rspec/rails/example/cell_example_group.rb
85
- - lib/rspec_cells/capybara/string_matchers.rb
86
86
  - rspec-cells.gemspec
87
87
  - spec/cells/cell_spec_spec.rb
88
88
  - spec/spec_helper.rb
@@ -1,45 +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 RSpecCells
15
- module Capybara
16
- module StringMatchers
17
- extend ::RSpec::Matchers::DSL
18
-
19
- %w[css xpath selector].each do |type|
20
- matcher "have_#{type}" do |*args|
21
- match_for_should do |string|
22
- ::Capybara::string(string).send("has_#{type}?", *args)
23
- end
24
-
25
- match_for_should_not do |string|
26
- ::Capybara::string(string).send("has_no_#{type}?", *args)
27
- end
28
-
29
- failure_message_for_should do |string|
30
- "expected #{type} #{formatted(args)} to return something from:\n#{string}"
31
- end
32
-
33
- failure_message_for_should_not do |string|
34
- "expected #{type} #{formatted(args)} not to return anything from:\n#{string}"
35
- end
36
-
37
- def formatted(args)
38
- args.length == 1 ? args.first.inspect : args.inspect
39
- end
40
- end
41
- end
42
-
43
- end
44
- end
45
- end