Ruby on Rails - learning from zero.

Nov 20

Testing your jquery mobile application with cucumber - part 2

As we know jQuery Mobile uses alot of javascript. This mean that our page will change realy often. JM adds a lot of classes to our dom elements. I assure that the best way to test this is writing separate steps for those which occurs frequently in ours mobile scenarios. Let’s look at this example:

(Note that as I writing this I am using rails 3.1.2 + cucumber 1.1.2)

Here we set Before and After @mobile tag. It’s important to set default driver to rack_test - selenium is much slower and we don’t realy need this in ours desktop version tests.

It’s time for some tests and steps for them. Note that for files which contain’s mobile tests we use @mobile tag.

We are ready to run tests!
cucumber features/mobile_welcome.feature

Now your firefox(by default)/whatever browser interprets javascript :)

Oct 26

Updating from 3.0.x to 3.1.0 - ArgumentError (dump format error (user class))

When updating from rails 3.0.x to 3.1.0 you might have problems with old SESSION_KEY which occurs with this error

ArgumentError (dump format error (user class))

To fix it, clear your session :)

I read that “rake db:sessions:clear” will help but in my case I needed "rake db:tmp:clear"

Oct 22

Testing your jquery mobile application with cucumber

If you had read my how-to about jquery mobile + desktop version you may wonder how I test these applications. As I try to code with BDD I use Cucumber for testing, so I will show you example test written in cucumber.

First, we need to add paths for our cucumber scenario:

Second, it’s time to write tests :), Example:

I assumed that you have properly set up jquery mobile with rails.

As you see I write tests for mobile and desktop in separate files - I recommend that to you. In this example it may look that desktop and mobile tests are the same but, trust me later your DOM elements will differ from deskop version.

Aug 10

Add favourite through link

When your application has favourites functionality you may often want to add favourite not by simple form but through link located somewhere in item which you want to add. You dont need to do some strange ‘display: none’ tricks to each of inputs. Better way is just link with params.

Example:

Mar 28

jquery mobile + desktop version in one view

If you want to make desktop/mobile version and your app doesn’t need any new content in desktop version there is nice method to do it. 

First we need to store somewhere info about what version our user want.

The next thing is loading javascripts/stylesheets based on session[:mobile] value.

Now write views basing on jquery mobile doc’s or this tut http://fuelyourcoding.com/getting-started-with-jquery-mobile-rails-3

Now you can style jquery mobile elements like this:
[data-role=”content”] { … }

Or just add your own ids/classes.

Jan 07

A few words about my progress

I had problems with learning rails - maybe because I had no idea what to do. That’s why I joined the open source project - Simple News Aggregation which allowed me to check my knowledge. I got an opportunity to see how the work method looks like - the client and me as a developer.

Client is an experienced developer - Piotr Misiurek. Our communication is done mainly by mail and pivotaltracker - really nice tool for project managing. Piotr sends me tickets (the things he want in project), I am doing them, Peter is checking my work, and accept it or sends me feedback with info what i have to change.

Progress can be seen - I know much more about the architecture of rails, but i still have problems with tests, because earlier I had not worried about them, and I think that is rather the biggest problem for new one.

The whole code you can see here: github, news about project: 200OK (If you are interested in, this company are looking for new ones willing to learn by doing real apps, but you need minimal skills using rails).

Sep 04

Hello World!

My name is Kuba. I am seventeen years old and i just started my adventure with programming. I selected ruby language and rails framework because they are nice (as the whole community is). On this blog i will write about things related with ruby and rails.