Thursday, April 23, 2009

received unexpected message :split [ an error in an rspec controller test ]

original code:

  it 'should add a flight given the correct data' do
    details = Factory.build(:flight).attributes

    @mock_flight.should_receive(:save).and_return(true)
    Flight.should_receive(:new).with(details).and_return(@mock_flight)

    post 'create', :flight => details
    response.should redirect_to( @mock_flight )
  end

correction:
-    response.should redirect_to( @mock_flight )
+   response.should redirect_to( flight_url(@mock_flight) )

notes:
-  @mock_flight is defined in a before(:all) block.
-  flight_url is generated by the following line in config/routes.rb:
        map.resources :flights

Monday, April 20, 2009

[Rails error] Unpacked Gem has no specification file.

Recently I started working on a new project. Every time I did anything from the command line, I got this irritating error message when rails loaded it's environment: 

config.gem: Unpacked gem [whatever] in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.

I run rake gems:refresh_specs. I get:

config.gem: Unpacked gem [whatever] in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.

and the problem isn't fixed.

The "specification file" it wants is, simply, gem_path/.specification

The first step to resolving this was to go to RubyForge to see if the gem _had_ a specification file. In my case, it did not.

So, to resolve the issue, I simply created a .specification file in the gem's root directory. As far as I can tell, this is the minimum information necessary:

--- !ruby/object:Gem::Specification 
name: archive-tar-minitar 
version: !ruby/object:Gem::Version 
  version: 0.5.2
require_paths:
- lib
platform: ruby

Thursday, April 16, 2009

"With all the Rights and Responsibilities ..." (a quotation)

"I've given you admin privileges [to a production site]... this way you can see everything. Please do not make any changes to the data."

- Shawn