Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

generated cells not rendering in specs #29

Closed
jacobpatton opened this Issue Sep 6, 2013 · 9 comments

Comments

Projects
None yet
5 participants

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.

Owner

apotonick commented Sep 16, 2013

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

sethiele commented Oct 9, 2013

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)

Owner

apotonick commented Oct 15, 2013

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

Hi, thanks for your response. The output is:

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

apotonick commented Oct 17, 2013

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

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

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">]>]>]>]>>

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

Owner

apotonick commented Dec 8, 2013

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...

Collaborator

seuros commented Jun 11, 2014

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

@apotonick apotonick closed this Jun 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment