Wednesday, December 08, 2010

Moving from rspec 2.0.0.beta.18 to rspec 2.0.0.beta.22

This post is primarily for anyone who is using rspec 2.0.0.beta.18 as specified in the Ruby on Rails Tutorial and find that they hit upon the following problem:

Failure/Error: Unable to find C to read failed line
undefined method `get' for # do
include RSpec::Rails::RequestExampleGroup

Whenever they run the tests:
$ rspec spec/requests/layout_links_spec.rb
To fix this, I installed rspec 2.0.0.beta.22 by using the command:
$ gem install rspec -v 2.0.0.beta.22 --pre
Then I changed the version of rspec specified in my Gemfile as:
$ git diff Gemfile
WARNING: terminal is not fully functional
diff --git a/Gemfile b/Gemfile
index 28af226..865b9de 100644
--- a/Gemfile
+++ b/Gemfile
@@ -30,10 +30,11 @@ gem 'sqlite3-ruby', :require => 'sqlite3'
# end

group :development do
- gem 'rspec-rails', '2.0.0.beta.18'
+ gem 'rspec-rails', '2.0.0.beta.22'
end

group :test do
- gem 'rspec', '2.0.0.beta.18'
+ gem 'rspec', '2.0.0.beta.22'
end

warning: LF will be replaced by CRLF in Gemfile.
The file will have its original line endings in your working directory.
Then I installed this version of rspec using the command:
$ bundle install

Now I got a new error:
1) LayoutLinks should have a Home page at '/'
Failure/Error: response.should have_selector('title', :content => "Home")
undefined method `has_selector?' for #
# ./spec/requests/layout_links_spec.rb:6:in `block (2 levels) in '
Google suggested the solution in this page: Add "webrat" the Gemfile, do a bundle install and that should do it.

In my case, I had to uncomment the entry in the Gemfile.
$ git diff Gemfile
WARNING: terminal is not fully functional
diff --git a/Gemfile b/Gemfile
index 28af226..ea7d729 100644
--- a/Gemfile
+++ b/Gemfile
@@ -25,15 +25,16 @@ gem 'sqlite3-ruby', :require => 'sqlite3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
-# group :development, :test do
-# gem 'webrat'
-# end
+group :development, :test do
+ gem 'webrat'
+end

group :development do
- gem 'rspec-rails', '2.0.0.beta.18'
+ gem 'rspec-rails', '2.0.0.beta.22'
+# gem 'annotate-models', '1.0.4'
end

group :test do
- gem 'rspec', '2.0.0.beta.18'
+ gem 'rspec', '2.0.0.beta.22'
end

warning: LF will be replaced by CRLF in Gemfile.
The file will have its original line endings in your working directory.
That fixed it!

Cheers!
Karthick S.

Thursday, July 15, 2010

WAMPServer and Apache on Windows: Changing the port number

It all started when I wanted to create an application with MySQL as a backend. Since I am not well versed in MySQL, one of my colleagues suggested that I use phpmyadmin. He had a nice installation of phpmyadmin installed in the tools development server we have in our office and I tried it for sometime. Today morning, I decided to install phpmyadmin in my local machine so that I can work on my application when at home too. But there was no one around who had installed phpmyadmin in Windows. :(

After a few iterations in trying to get PHP, Apache and MySQL to talk to each other in Windows, I realized that I was going nowhere and hence decided to install one of the WAMP applications that are lying around online. I chose WampServer.

After installing WampServer, I noticed that it comes with phpmyadmin pre-installed. :)

Now this is the problem I faced. The default port for Apache as configured in the installation in WAMPServer was 80 and this was already being used by Skype. The following are the steps which I followed to change this port:
1) Left click on the WAMPServer tray icon and choose "Apache".
2) Open "httpd.conf".
3) In the file, search for "Listen 80". The "80" is the current port number.
4) Change it to whichever port number you want it to be. Choose a port that is not already in use.
5) "Restart All Services" by left-clicking on the tray icon again.
I got most of this information from this page.

This brought about another irritating albeit minor problem: If you notice in the image above, there are shortcuts to "Localhost" and "phpmyadmin" in this menu. These still use the port "80". Every time I click on these shortcuts, I get a page not found and then need to change the port.

How do I fix that one? I tried the steps in the page linked above, but that information seemed to be for some other version of WAMPServer.

So, here are the steps I found for WAMPServer Version 2.0:
1) Go to the folder in which you have installed WAMPServer (X:\Wamp, by default).
2) You should see a file "wampmanager.tpl" in this folder. Open it.
3) Search for "http://localhost/phpmyadmin/" and change it to "http://localhost:[YOURPORTNUM]/phpmyadmin/".
4) Save and close this file.
5) Restart WAMPServer.

That should fix it!

Cheers!
Karthick

Saturday, June 12, 2010

RoR page does not load on the browser

Hi, As usual, I tried to learn something of something new - Ruby on Rails. When I tried to create a brand new application as suggested in "Beginning Ruby on Rails", I hit upon a road block. The application would not load. And the log file said:
- Could not open library 'libsqlite3': The specified module could not be found.

- Could not open library 'libsqlite3.dll': The specified module could not be found.

- Could not open library 'sqlite3': The specified module could not be found.

- Could not open library 'sqlite3.dll': The specified module could not be found.
And lots of other things which I could just not understand.

After searching for a long time and taking help from our local ruby-on-rails expert (who had never done this in Windows), I found that this is a rare occurrence. Finally, when we found out the root cause, it was pretty simple. All I needed to do was to put sqlite3.exe and sqlite3.dll in my path.

Cheers!
Karthick S.