Use Any_instance_of In Rspec

tips of rails stub which is called any_instance_of

How To Use Kaminari From Array

I always forget way of use rails pagination library (kaminari) with array

How To Check Method Calling In Rspec

You can check a method is called or not by using receive in rspec. describe "#method" do it "should call method_b" do @user = Persion.new expect(@user).to...

How To Add Extra Data In Draper

If you want to add extra data in draper you can use :context option. person.rb class Persion < Draper::Decorator is_admin? context[:role] == 'admin' end end...

Html Escape With Rails I18n

String is always html escaped in 'config/locales/en.yml' 'config/locales/en.yml' en: hello_message: "Hello %{user_name}" hello.html.erb <%=...

Recommendation To Use Local_assigns.has_key?

You can check loal definition using defined? and local_assigns.has_key? local_assigns.has_key? is more simple than defined?. You can write one line. <% if...

Rails Pagination - Kaminari

Kaminari is popular pagination gem. https://github.com/amatsuda/kaminari Basic Usage prepare target @articles = Articles.page(params[:page]) # or @articles...

Test Csrf In Feature Test Using Capybara

Rails app disable request forgery protection in test environment by default. So csrf token dose not appear in app using <%= csrf_meta_tags %> or form_for...

Try In Ruby

Try method If you get user.name and user is nil the NoMethodError is occurred. # user is nil name = user.name # NoMethodError !!!!1 You had better use try...

Things To Be Aware Of When Change Capybara Default_wait_time

About Capybara.default_wait_time According to api document... find will wait for a set amount of time and continuously retry finding the element until...

Older