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...

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...

Time Object In Ruby

Time object in ruby can not parse Time string(e.g. 2015-05-29T19:59:48+09:00) by default. # return Time objet with "2015-01-01 00:00:00 +0900"...

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...

How To Set Subdomain In Rails Rspec

context "subdomain test" do it "should return subdomain" do request.host = "subdomain." + request.host expect(get_subdomain).to eq("subdomain") end end

How To Find Invisible Element Using Capybara

Capybara don't find invisible element. page.find("#delete-button") In this case if #delete-button element has display: hidden or any other invisible style...

Older