[rspec-users] Is it still possible to use should_have_rjs

David Chelimsky dchelimsky at gmail.com
Fri Jun 15 07:42:05 EDT 2007


On 6/15/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> Hi
>
> I've come back to a Rails project after about a month doing other
> work, and there's a lot of changes.  I was on the 0.7 branch before
> and I've upgraded to RSpec 1.0.5.  I used the spec translator, fixed
> the cases where it barfed on unusual line contents, and all my model
> and controller specs now pass. But I'm getting 53 failures on my view
> specs, all along the lines of:
>
> should have visual effect
> Unknown RJS statement type effect
> /Users/ashleymoran/Documents/Development/YourMoney/trunk/src/spec/
> views/admin/add_dealer_rjs_view_spec.rb:33
> 31
> 32  it "should have visual effect" do
> 33    response.should have_rjs(:effect, :blind_down, "add_dealer")
> 34  end
> 35
>
> I'm trying to revert these to should_have_rjs but I've looked through
> the RSpec source and it seems should_have_rjs was silently removed
> between 0.8 and 0.9.  At least I can't find any reference to it in
> the 0.9.4 source or the 1.0.5 source.  Am I missing something?

You're not missing anything. I switched from a direct port of ARTS to
wrapping assert_select_rjs in 0.9. Neither library covers the full
breadth of rjs statements and I went w/ the wrapper because it meant
that rspec would reap the benefits of improvements to
assert_select_rjs. Sadly, it seems as though the only improvements to
assert_select_rjs have been those that I've personally contributed to
Rails, and they haven't covered every situation.

As for your immediate problem, Spec::Rails provides access to
Test::Unit assertions for free. I'd recommend that you install the
ARTS plugin (from which should_have_rjs was ported) and use it
directly as/is (assert_rjs) right in your examples. It won't be as
pleasing syntactically, but at least it should work for you.

http://glu.ttono.us/articles/2006/05/29/guide-test-driven-rjs-with-arts

There are a couple of things that ARTS didn't cover that we had added
to RSpec. Those you'll have to do manually with any of these:

response.should have_text("full text of the response")
response.should have_text(/regexp representing a substring of the response/)
response.body.should == "full text of the response"
response.body.should =~ /regexp representing a substring of the response/

In terms of a longer term solution for rspec, I'm open to suggestions.
ARTS and assert_select_rjs both make assumptions about what options
are available, which means they both need to be updated as new options
appear. I had hoped that this would be maintained in rails, but it
doesn't appear to be happening.

We could resurrect ARTS in RSpec, but that would mean either coming up
with a new matcher (include_rjs?) as not to break existing specs that
use "should have_rjs.", and it would put more of a burden on
Spec::Rails to keep up with additions to rjs.

Other ideas?

David
>  I
> really need should_have_rjs- those 53 failures represent about 20% of
> all my view specs.
>
> Thanks
> Ashley
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list