Hi David,

Thanks for the reply and sorry for the late response (the holidays got in 
the way). After reading your reply I went back and double checked my code 
(before dumping on here) and found out what I was doing wrong. Without 
going into too much detail, I had pluralized a hash key when it shouldn't 
have been, which resulted in the test passing. When I tried to debug the 
custom matcher for the test, I was actually debugging the custom matchers 
use in another example, which caused my confusion.

Again, thanks for the response.

Merry Christmas,

Chris

On Sunday, December 23, 2012 1:44:40 AM UTC+13, [email protected] wrote:
>
> On Sat, Dec 22, 2012 at 1:52 AM, Chris Gat <[email protected]<javascript:>> 
> wrote: 
> > I have something similar to the following code 
> > 
> > feature Something do 
> >     let!(:var) { FactoryGirl.create(:var) } 
> >     include_examples "these examples" 
> > end 
> > 
> > shared_examples_for "these examples" do 
> >    scenario "test" do 
> >       visit some_url 
> >       expect(page).to have_values(var) 
> >    end 
> > end 
> > 
> > RSpec::Matchers.define :have_values do |expected| 
> >   match do |actual| 
> >      page.has_text(expected.name) 
> >   end 
> > end 
> > 
> > FactoryGirl.define do 
> >   factory :var do 
> >      sequence(name) {|n| "name#{n}} 
> >   end 
> > end 
> > 
> > The problem I'm having is that let doesn't seem to memoize var into the 
> > matcher. Since var.name is a sequence, the name on the page when it is 
> > visited is different from the check in the customer matcher. 
> > 
> > Rspec 2.12, Capybara 2 
> > 
> > Thanks in advance for the help 
>
> What you've posted should work, assuming that some_url points to a 
> page that lists all of the var objects' names. 
>
> The fact that you're using a sequence shouldn't matter at all. Using 
> let!() (vs just let()) means that the var object is generated before 
> the example (scenario in this case), and any call to "var" returns 
> that same object. 
>
> Any chance you could post the exact code (including the controller 
> action, failure message, and possibly output of the actual html) so we 
> can see what's really going on? It's quite common for things to get 
> lost in translation when you write "I have code like this" instead of 
> the actual code. 
>
> Cheers, 
> David 
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rspec/-/lrIx6sEJXsIJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to