Docker error – error response from daemon: Cannot start container….is not within /var/lib/docker/aufs/mnt

Problem

You are trying to use an image from Docker in your Ubuntu 14.04 system, but you are getting a error like the following:

014/12/13 17:10:23 Error response from daemon: Cannot start container 4023610855c0551bdc44d0e602f20999c0527da3cfe010169707248887b3a1f0: /var/lib/docker/aufs/mnt/4023610855c0551bdc44d0e602f20999c0527da3cfe010169707248887b3a1f0 is not within /var/lib/docker/aufs/mnt/4023610855c0551bdc44d0e602f20999c0527da3cfe010169707248887b3a1f0

Solution

Your docker version is outdated (ie 1.0.1) so you would need to upgrade your docker installation.
There is a script for this (information from here):

After running the following you should be able to use your images as normal with: sudo docker run -t -i image/name bin/bash:

$ curl -s https://get.docker.io/ubuntu/ | sudo sh

Project ERROR: Unknown module(s) in QT: webkitwidgets

Problem

You are trying to bundle install a Gemfile that includes the capybara-webkit gem, in an Ubuntu system but you get the following error:

ERROR:  Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
Project ERROR: Unknown module(s) in QT: webkitwidgets

Solution

It seems that the latest ubuntu versions are using QT version 5 instead of 4. So in order to be able to install the gem you would need to install the qt development libraries for version 5 like:

sudo apt-get install libqt5webkit5-dev

minitest assert_routing with method included in path

Problem

When trying to use the minitest assert_routing with the first parameter representing the path as a hash that includes both the path and the method, and run the tests rails complains about SyntaxErrors.

When trying to use it as suggested in the ‘Rails 4 Test Prescriptions’ Pragmatic Programmers book (p. 172 – Minitest and Routing) which is:

assert_routing({ path: "/projects", method: "post" }, 
controller: "projects", action: "create")

the error is:

SyntaxError: 
/.../test/controllers/projects_controller_test.rb:12: 
syntax error, unexpected ',', expecting ')'
... '/projects', method: 'post' },  controller: 'projects', act...

even when trying to have the second parameter as a hash:

assert_routing({ path: "/projects", method: "post" }, 
{ controller: "projects", action: "create" })

the error is similar:

SyntaxError: 
/.../test/controllers/projects_controller_test.rb:12:
 syntax error, unexpected ',', expecting ')'
... '/projects', method: 'post' }, 
{ controller: 'projects', ac...

Solution

Seems that you need to pass the parameters enclosed in brackets, so the following would work:

assert_routing  ({ path: '/projects', method: 'post' }), 
({ controller: 'projects', action: 'create' })

Book Review: BDD in Action by John Ferguson Smart (Manning)

As the subtitle of the book ‘Behavior-driven development for the whole software lifecycle’ suggests, this is a book describing Behaviour Driven Development for the different phases of software development.

It starts with a very general description of BDD, the problems that it addresses, the general principles and the origins of it, as well as the pros and cons in different organisations and team scenarios. Throughout this general description there are plenty of references and links for anyone wishing to have more details.

This is followed by a real life project, that goes through the phases of requirement analysis, creation of the features, stories and examples and the distinction and differences between each of them. There are various techniques described, including Feature Injection for identifying business goals and supporting features, Impact Mapping for high-level requirement visualisation, Purpose-Based Alignment Model for judging how much effort you should put into different features, and the identification of stakeholders and their roles. There is also a description about Real Options and Deliberate Discovery principles.

There are more detailed examples to automating scenario steps, described in different languages (Java, Python, .NET, Javascript) and diffent tools (JBehave, Cucumber-JVM, Behave, SpecFlow and Cucumber-JS). These are used to go from executable specifications to automated acceptance tests. There two separate chapters following that, describing the two different ways for automating the acceptance criteria depending on whether they are for the UI layer or the non-UI requirements.

Last but not least, there is a chapter dedicated to explaining the relationship between BDD, TDD and Unit Testing, another one describing the idea of living documentation, as well as reporting and project management, and finally the role of BDD in continuous integration (CI) and continuous delivery.

Throughout the text there are a lot of diagrams to help explain the ideas better, as well as a lot of references for more detail. Even though most of the examples are based in Java, the principles, ideas and techniques are easily applied to other languages and tools.

So, in summary this is a very useful book for anyone wanting to learn how Behaviour Driven Development can be used in practise. There are different sections that are targeted to different roles from business stakeholders, to testers and to developers. Hopefully when your whole team reads this book, the whole idea of BDD can be understood better, and used to build the software right as well as build the right software.

Disclaimer: This book was reviewd under the Manning reviewers program.

Updating Phoenix from 0.3.1 to 0.4.0

Problem

You would like to upgrade to the latest version of Phoenix 0.4.0 from the previous version of 0.3.1. When you try to update the dependencies and try to start phoenix again (mix phoenix.start) you get the following error:

** (Mix) You're trying to run :your_app_name on Elixir v1.0.0-rc1 
but it has declared in its mix.exs file it supports 
only Elixir ~> 0.15.0

Solution

After upgrading your Elixir version to the latest (1.0.0-rc1), and updating the path to your elixir installation so that it uses the new one, clear the dependencies from your project:

mix deps.clear --all

Change the dependency in your mix.exs file to be as the following:

def project do
    [ app: :your_app_name,
      version: "0.0.1",
      elixir: "~> 1.0.0-rc1",
      elixirc_paths: ["lib", "web"],
      deps: deps ]
  end

and then get the dependencies again with:

mix deps.get

after that you should be able to start your phoenix project with tne new version.

Upgrading jquery-ui-rails from 4.2.1 to 0.5.0

Problem

You would like to upgrade your jquery-ui-rails gem from a version before 0.5.x to the latest version 0.5.0, but when you do that your tests are failing with error messages similar to the one below:

ActionView::Template::Error: 
couldn't find file 'jquery.ui.effect-blind'

Solution

According to the changelog the naming between 4.2.1 and 0.5.0 has changed jquery-ui-rails

So if you were using something like the following in your app/assets/javascripts/applications.js file (as used in the depot example in the Agile Web Development with Rails 4 book):

//= require jquery.ui.effect-blind

you would need to change it to the following after upgrading your jquery-ui-rails gem to ~> 0.5.0:

//= require jquery-ui/effect-blind

Upgrading from rspec-rails 2.x to rspec-rails 3.x

Problem

You would like to upgrade your rails project from using rspec-rails 2.x to the latest rspec-rails 3.x version. According to the rspec-rails documentation the new 3.x includes many breaking changes.

Solution

The full instructions for upgrading from rspec-rails 2.x to rspec-rails 3.x are here, but you may not need to complete all the steps described in there.
So you could try with the following shorter steps:

  • Run your rspec tests and make sure that they all pass
  • Upgrade your rspec-rails to the version 2.99 provided by the rspec-rails team
  • Run your rspec tests again, and you should have deprecation warnings. Usually that would consist of:
    spec-rails 3 will no longer automatically infer an 
    example group's spec type from the file location. 
    You can explicitly opt-in to this feature using 
    this snippet:
    
    RSpec.configure do |config|
      config.infer_spec_type_from_file_location!
    end

    which you could add to your spec/spec_helper.rb file

  • Run your rspec tests again and this time they should have no deprecation warnings
  • If they all pass then upgrade to the latest rspec-rails (ie 3.0.1).
  • Run your rspec tests again, and this time you should normally have one deprecation warning:
    Requiring `rspec/autorun` when running RSpec via the `rspec` 
    command is deprecated. 
    Called from /xxx/xx/lib/active_support/dependencies.rb:247:
    in `require'.
  • Delete the line require ‘rspec/autorun’ from your spec/spec_helper.rb file
  • Rerun your tests and they should all be passing in rspec-rails 3.x now

bin/rails:6: warning: already initialized constant APP_PATH

Problem

You are getting the error:

bin/rails:6: warning: already initialized constant APP_PATH

when you are trying to start the local webserver with rails s.

Solution

That happens when are using the bootstrap rails gem as in:

gem 'anjlab-bootstrap-rails', require: 'bootstrap_rails'

It is important that the bootstap rails uses in the require is used with a dash and NOT an underscore.
So when you write the the gem as follows:

gem 'anjlab-bootstrap-rails', require: 'bootstrap-rails'

and restart your server you should no longer have the error message.

find out the status of rails application migrations

Problem

You would like to know at any moment the status of your migrations, if they have been applied, rolled back etc.

Solution

There is a very usefull rake task that can give you the list of your migrations withouth having to look at your schema.rb file:

rake db:migrate:status

Status   Migration ID    Migration Name
--------------------------------------------------
   up     20140528102449  Create products
   up     20140613150126  Create carts
   up     20140613151119  Create line items
   up     20140617215027  Add quantity to line items
   up     20140617220031  Combine items in cart
   up     20140620131542  Create orders
   up     20140620131605  Add order to line item