Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

generated cells not rendering in specs #29

Closed
jacobpatton opened this Issue · 9 comments

5 participants

@jacobpatton

I'm having some trouble getting rspec-cells to run cleanly.

Namely, I generated a cell with:

bundle exec rails g cell task listing -e haml -t rspec

and when I test the generated cell and spec, I get this error:

  1) TaskCell cell rendering rendering listing
     Failure/Error: it { should have_selector("h1", :content => "Task#listing") }
       expected following output to contain a <h1>Task#listing</h1> tag:
       <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
       <html><body><p>#<:node::simple:0x007fb2850c5e60></:node::simple:0x007fb2850c5e60></p></body></html>
     # ./spec/cells/task_cell_spec.rb:15:in `block (4 levels) in <top (required)>'

Has anyone seen that sort of thing before, or else have any ideas? FWIW, I'm running Rails 3.2.11 with the latest capybara.

@apotonick
Owner

Do your specs work after you customized your cell views and the specs?

@sethiele

I have the same problem. I't dose no matter what I change on the cell (view).
My Cell:

class TradesCell < Cell::Rails
  def show(args)
    @trades = 1
    render
  end
end

My view:

%span.badge.badge-info= @trades

My Test:

require 'spec_helper'

describe TradesCell do
  context "cell rendering" do
    context "rendering show" do
      before(:each) do
        @cell = render_cell :trades, :show
      end

      it "should display the number of open trades" do
        @cell.should have_selector("span", :class => "badge badge-info", :content => "1")
      end
    end
  end
end

The output:

expected following output to contain a <span class='badge badge-info'>1</span> tag:
       <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
       <html><body><p>#<:node::simple:0x007f9cce0db548></:node::simple:0x007f9cce0db548></p></body></html>

It's a simple first test (the code makes no sense)

@apotonick
Owner

Please paste the output of your render_cell :trades, :show.

@sethiele

Hi, thanks for your response. The output is:

<span class="badge badge-info">1</span>
@apotonick
Owner

I meant to say the render_cell call in the rspec test.

@cell = render_cell :trades, :show
puts @cell.inspect
@sethiele

Ah okay, sorry.
This is the output
#<Capybara::Node::Simple:0x007fe03c866388 @native=#<Nokogiri::HTML::Document:0x3ff01e433110 name="document" children=[#<Nokogiri::XML::DTD:0x3ff01e432c4c name="html">, #<Nokogiri::XML::Element:0x3ff01e438a84 name="html" children=[#<Nokogiri::XML::Element:0x3ff01e438714 name="body" children=[#<Nokogiri::XML::Element:0x3ff01e438354 name="span" attributes=[#<Nokogiri::XML::Attr:0x3ff01e4382c8 name="class" value="badge badge-info">] children=[#<Nokogiri::XML::Text:0x3ff01e43b644 "1">]>]>]>]>>

@rebeccamen

Was this ever resolved? I am seeing the same issue with rspec-apotomo.

@apotonick
Owner

Guys- an example app with a Gemfile that nails the respective versions an a failing test would greatly help. Just email a tarball or skype me or...

@seuros
Collaborator

bug was in capybara not this gem.
@apotonick, Please close this ticket too.

@apotonick apotonick closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.