> Ruby on Rails - Vinova - Page 38

Testing for javascript alerts with Cucumber & Capybara

Using Cumcumber + Capybara to run automated testing is a TRENDY now. But you might have trouble finding a way to assert a javascript alert, for e.g. a link created by the link_to … :confirm => “Are you sure?” and similar. Don’t worry, here is a work around to confirm Javascript alert and dialog in your Capybara tests, simply override alert and confirm methods: Given /^I will confirm on next step$/ do begin evaluate_script(“window.alert = function(msg) { return true; }”) evaluate_script(“window.confirm = function(msg) { return true; }”) rescue Capybara::NotSupportedByDriverError end end Rescue here is added in case, you run want to run your tests without javascript (e.g. default capybara driver). If you run feature without javascript simply nothing will happen. Moreover, using this technique you can simulate moving mouse over some elements. It is useful, when you have links that appears when certain div is under the mouse cursor. Then /^I move mouse over “([^”]*)”$/ do |label| begin Capybara.current_session.driver.browser.execute_script(“$(‘#{label}’).mouseover();”) rescue Capybara::NotSupportedByDriverError end end That’s it. Happy testing...

Go-Trendy.com revamp!

We have just launched the new website revamp of our client: Go-Trendy.com. Go-Trendy is an online trendy fashion shop focusing on Hong Kong, Japanese and Korean fashion. Total time taken for us to revamp this website is 1 week. Here is final product: Homepage: Products...

Alice in Wonderland – Facebook legend living in S’pore

“The only way to achieve the impossible is to believe it’s possible.” – from “Alice in Wonderland” Eduardo Saverin – Facebook legend living in Singapore Tham Yuen-C Straits Times Site’s co-founder set up a software development firm here last year, but has maintained a low profile. The other Facebook legend – the one who fell out with co-founder Mark Zuckerberg – has set up a software development company in Singapore. Mr Zuckerberg is chief executive officer of the world’s most popular social networking site. His former collaborator, Mr Eduardo Saverin, 28, is one of three people behind Web technologies company Anideo, with offices in Singapore and Miami, Florida. The Brazil-born billionaire is said to have been living in Singapore since last year, and the Singapore outfit of his firm was registered under his name in October last year. His two partners are fellow Harvard University graduates, one of whom had worked with him on a job search site in 2005. Since technology site TechCrunch posted a blog last Thursday about him being in Singapore, netizens – here and abroad – have been speculating about his whereabouts. A film, The Social Network, based on the story of the two co-founders, is currently showing in cinemas around the world. Mr Saverin is portrayed in the movie as the more affable and charming character, in contrast to its depiction of Mr Zuckerberg as a socially inept geek who is also the more cunning of the two. Mr Saverin was Mr Zuckerberg’s partner in 2004 when, as Harvard students, they started thefacebook.com, a website that evolved into Facebook. But the duo fell out...

Using ActiveRecord to access Microsoft SQL Server via ODBC

Recently I need to insert 400+ rows of data into an eight year old MSSQL 2000 and MSSQL 2008 database. It’s really a pain in the ass if I have to do it by hand or learning a new tool to do it. Luckily, I can use ActiveRecord to do that easily thanks to activerecord-sqlserver-adapter and and auto table field mapping of ActiveRecord. Here is a quick step-by-step guide: Install Ruby on Windows machine (that run SQL server). Download One-Click Ruby Installer for Windows for Ruby 1.8.6 P26 at http://rubyforge.org/frs/download.php/29263/ruby186-26.exe And install it. If you use the default setting, it will setup ruby at c:ruby folder with rubygem 0.9.3 Update RubyGems Open “Command Prompt” cd c:rubybin gem update –system Install ActiveRecord with SQLServer Adapter gem install activerecord-sqlserver-adapter –source=http://gems.rubyonrails.org If the installation result is: Successfully installed activesupport-2.2.2 Successfully installed activerecord-2.2.2 Successfully installed activerecord-sqlserver-adapter-1.0.0.9250 3 gems installed Create a DSN (Data Source Name) Luckily I can reuse DNS from current ASP project so I don’t need to create new one. If you have to, you can follow guideline in [1]. Setup connection and create property ActiveRecord based classes require “active_record” ActiveRecord::Base.establish_connection( :adapter => “sqlserver”, :mode => “odbc”, :username => “yourusername”, :password => “yourpassword”, :dsn => “yourDSN” ) class AnyNameYouWant < ActiveRecord::Base set_table_name “TableNeedToAccess” set_primary_key “PrimaryID” end Start irb by: cd c:rubybin irb And paste above chuck of code in to irb. From now, you can use ActiveRecord based classes to read/write/add/remove SQL Server table as in a Rails script/console environment. I also got a problem with Time.mktime and need to some code adjust by hand Open c:rubylibrubygems1.8gemsactiverecord-sqlserver-adapter-1.0.0.9250libactive_recordconnection_adapterssqlserver_adapter.rb Replace “Time.mktime” by “Datetime.new”...

Rails 3.0 Upgrade Handbook

Guys, Rails 3.0 is now at the stage of beta release. Why not consider update your self with state-of-the-art technology? Below is the handbook that we think it will be very useful to you! Let’s check it out !! Inside you’ll find: Almost 120 pages of upgrade information A step-by-step guide to upgrading your app to Rails 3 High-level discussion of what’s new in Rails 3 Practical tips on using Rails 3’s new features to improve your code Real case studies of upgrading apps and plugins Detailed checklists for upgrading via:...
Malcare WordPress Security

website design singapore,design firms in singapore,web design company singapore,app developer singapore,singapore web development,developer in singapore,website development singapore,graphic designer in singapore,web development company singapore,mobile application developer singapore,web designer singapore,website designer singapore,ruby on rails developer singapore,mobile app development singapore,mobile app developer singapore,singapore web design services,app development singapore,ios app development singapore,android developer singapore,singapore web design,singapore app developer,mobile apps singapore,singapore website design,mobile apps development singapore,singapore mobile app developer,ios developer singapore,design agency singapore,web design singapore,web design services singapore,mobile developer singapore,mobile game developer singapore,web development singapore,developers in singapore,web application singapore,singapore mobile application developer,mobile application development singapore,website developer singapore