Bölüm #6
[ Dinle ]
Ruby Hunt
Gutter
Ruby 2.2 ile gelen yeni metodlar
Rspec web sitesi yenilendi
Ruby / Rails ile yapılan en yaygın 10 hata
Tisikkirlir

seen from United States
seen from United States
seen from China
seen from United States
seen from United States
seen from Canada

seen from Netherlands

seen from Netherlands
seen from Malaysia

seen from United States
seen from China
seen from Maldives
seen from United States
seen from China
seen from Norway
seen from United States

seen from Kazakhstan

seen from United States

seen from Netherlands

seen from Spain
Bölüm #6
[ Dinle ]
Ruby Hunt
Gutter
Ruby 2.2 ile gelen yeni metodlar
Rspec web sitesi yenilendi
Ruby / Rails ile yapılan en yaygın 10 hata
Tisikkirlir

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
RSpec's `should render_template` is too vague which sometimes leads to confusion
Suppose we've got this in our controller spec: get :edit, id: r.id response.should render_template "edit" Looks perfectly clear, but don't get over-assured about it. The matcher expects the word "edit" **anywhere** in the template filename, and, if found, the example will pass. For instance, if the actual template rendered is called `no_permission_to_edit` (which clearly assumes that editing is **not** allowed), the example will still be green. A simple and straightforward **workaround** might be: response.should render_template "/edit" , which will only match templates whose names **start** from "edit". More in-depth **solution** to the problem related to vague template matching is **using the HTTP codes** to distinguish situations like allow/deny. Consider this: Controller (simplified, proof-of-concept): def edit if not permission_condition return render "no_permission_to_edit", status: :forbidden end # Allowed, render stuff as usual. ... end Spec: get :show, id: r.id response.status.should == 200 # Is allowed. get :edit, id: r.id response.status.should == 403 # Is denied. delete :destroy, id: r.id response.status.should == 403 # Is denied.
Namespace collisions in Ruby and Rails
In trying to test a model named Have using rspec, I ran into a problem because rspec defines its own Have class in Rspec::Matchers::Have.
After much googling, it turns out that ::Have explicitly references the top-level namespace's Have class, which is what I wanted in this case.
Hopefully this saves someone an hour or two.