Web development blog

Uncategorized

Ultimate rspec matcher to test named_scope or scoped

Jul.11, 2010

After having a good practice on using Ultimate rspec matcher to test validation I think it’s time to implement one for testing named scopes - custom finders. Testing these finders is daily task. Here is how it can be done with minimum amount of code and maximum readability. (continue reading…)
1 Comment :, , , , more...

Ultimate rspec matcher to test validation

Jun.30, 2010

After a first thousand of tests using Rspec I fount it very annoying to repeat my self testing the standard code as spec code is usually twice longer than code it test. I’ve started to look for a way to simplify the patterns and make it reusable. Among other nice rspec tricks there is possibility to write custom Rspec matchers. Spec the validation is just two lines of code for each attribute now. (continue reading…)
3 Comments :, , , , more...

Advanced non-flat controllers hierarchy with rails

Jun.08, 2010

REST became the best practice for organizing CRUD server side interface. But what to do when we have something more than hello-world application that goes forward from data CRUD and provides many presentations of the same data with different filters and different layouts?
(continue reading…)
Leave a Comment :, , , , more...

DOM element class - css reference or javascript reference?

Apr.20, 2010

Designer have used element class attribute for CSS styling for ages. Nowadays classes are also used in javascript selectors. This overlapping cause additional problems: Changes in js may cause broken design and changes in design may cause broken js. The last one may be hard to detect especially when design and css are handled by different person. (continue reading…)
5 Comments :, , , , , more...

Ruby1.8: ‘private’ doesn’t give expected level of privacy

Apr.05, 2010

The classic OOP pattern usually called encapsulation implemented in ruby with private and protected keywords methods. The distinction between API and implementation works great with both. The problem is that private doesn’t hide method for inherited classes. (continue reading…)
2 Comments :, , , , more...

A dream to develop application that I will use

Mar.29, 2010

Developing sites for communities you never join, enterprise applications for company you never work in, services you never find useful… a serious problem of IT industry. All misunderstanding between customers and developers come from that reason.

It would be so great if we could always feel ourselves as a user of our applications and make something useful, but not spend time on improving features that won’t be familiar. Being a user of the developed application makes it really possible to develop ergonomic and pretty design.

Unfortunately most of the companies are ignoring that simple rule and unfortunately in some cases it is hard to follow. But anyway that is the only one way to build the best product.
1 Comment :, , , more...

Advanced SQL and named scopes stack with ActiveRecord

Jan.24, 2010

If you ever work with rails application that is a little bit more complex then a simple CRUD you would know that some of the ActiveRecord magic doesn’t work for complex SQL queries. I am primary talking about named scopes stack feature.
(continue reading…)
1 Comment :, , , , , more...

Vim as IDE - new development era for me

Dec.01, 2009

I was using Vim to do the minor editing in config files for ages. Vim is advanced on basic navigation and editing operations. However I was always prefer IDE for programming because of it’s specific to language navigation(’go to definition’ feature is awesome!), integrated debugger. But while gaining the experience I noticed that all advanced features began to be less important then basic ones. And you should try Vim if you feel the same.
(continue reading…)
1 Comment :, more...

Objects behaviour inheritance with RSpec

Oct.27, 2009

About half of a year ago I was writing about object interface and Liskov Substitution Princeple. In short: Any class instance that extends the base class should pass all unit tests behaviour tests written for base class instance. It was a surprise for me that this concept has already been implemented in RSpec.

(continue reading…)
3 Comments :, , , , more...

Double select from a single table in complex SQL query.

Jun.02, 2009

When I start learning SQL I have to write a lot of nested queries when working on complex select statements from a single table. Now, I feel more comfortable with it and show how to avoid nesting. There are cases when you have to compare one row of the table with all others to get the result:
  • Select next element to current by the value of some field
  • Select records that are unique by some complex expression
  • Select all records that have the same parameter as given record.
You can get rid of nesting in all above cases. Let’s review the example. (continue reading…)
Leave a Comment :, , , more...

The Content of this blog can be published anywhere with the link to original source.