On Dec 16, 2012, at 12:38 PM, David Chelimsky wrote:
> On Sun, Dec 16, 2012 at 1:29 PM, Perry Smith <[email protected]> wrote:
>>
>> On Dec 16, 2012, at 7:34 AM, David Chelimsky wrote:
>>
>>> On Sun, Dec 16, 2012 at 3:07 AM, Perry Smith <[email protected]> wrote:
>>>> Below are two methods of doing the same thing in a view spec. I have some
>>>> hidden magic to tie in to capybara which I am not showing.
>>>
>>> First question: why lay another abstraction on top of what is already
>>> an abstraction for spec'ing html content?
>>
>> Thank you for both replies. I got everything except the above... I'm not
>> clear what you mean by the 2nd abstraction layer. I thought I was just
>> using the tools provided as they were intended to be used.
>
> You wrote "I have some hidden magic to tie in to capybara which I am
> not showing." I thought that's what produced things like
> text_box[:name], but maybe that's all from Nokogiri?
text_box is a method already posted that is inside the second describe:
def form
@form ||= rendered.find('form#swinfo_form')
end
def label
@label ||= form.find('label')
end
def text_box
@text_box ||= form.find('input[type="text"]')
end
The magic is something that you suggested a while back (I didn't think it was
important to the discussion... but I guess it was) I bumped into your email
reply to a forum it via a blog post.
module RSpec::CapybaraExtensions
def rendered
Capybara.string(@rendered)
end
def within(selector)
yield rendered.find(selector)
end
end
and then a matching:
config.include RSpec::CapybaraExtensions, type: :view
inside the configure block in my spec_helper.rb file.
I appreciate your help.
Perry
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.