
vojtajina/ng-directive-testing LimeJS HTML5 Game Framework Start Testing Your Migrations. (Right Now) Migrations are a necessary part of any Rails project. At some point, you need to modify the structure of your database, normalize data that exists within those tables, or refactor the architecture entirely. The migrations for these tasks can vary in complexity from simple “add_column” statements to extreme SQL with nested joins and subselects. To be blunt, you can fark your data pretty easily by fat-fingering a migration. So how do we avoid this? In our daily routine as Agile developers, we follow a simple workflow to avoid these situations. Suggested Workflow I currently use RSpec for testing. Of course, you’ll need to dig into ActiveRecord internals to know how to write your tests. At this point, it may seem pointless to write a spec for this migration. Let’s dig in a little deeper, and see if I can’t convince you to start testing your migrations, right now. Example Scenario: Delete Stale Records Let’s take the following scenario and look at a migration that is just dying for a test.
Rails Tutorial · Devise with RSpec and Cucumber Devise with RSpec and Cucumber Introduction Ruby on Rails tutorial showing how to create a Rails 3.2 application using Devise with RSpec and Cucumber. Devise provides ready-made authentication and user management. The combination of Devise, RSpec, and Cucumber is the foundation for many real-world Rails applications. Is It for You? This tutorial is for experienced Rails developers as well as startup founders or hobbyist coders who are new to Rails. Experienced developers will find the complete application on GitHub; this tutorial provides the detail and background to understand the implementation in depth. For Rails beginners, this tutorial describes each step that you must follow to create the application. This is one in a series of Rails example apps and tutorials from the RailsApps Project. This example application uses ActiveRecord and a SQLite database. For more complex applications that use Devise, CanCan, and Twitter Bootstrap, see: How to Support the Project Before You Start Assumptions
Ruby for Newbies: Testing with Rspec Ruby is a one of the most popular languages used on the web. We're running a Session here on Nettuts+ that will introduce you to Ruby, as well as the great frameworks and tools that go along with Ruby development. In this episode, you’ll learn about testing your Ruby code with Rspec, one of the best testing libraries in the business. If you’ve read my recent tutorial on JasmineJS, you’ll probably notice several similarities in Rspec. Actually, the similarities are in Jasmine: Jasmine was created with Rspec in mind. We’re going to look at how to can use Rspec to do TDD in Ruby. It’s pretty easy to install Rspec. That easy. Now, let’s set up a small project. Here’s what your project directory should look like: We put the specifications (or specs) in a spec folder; we have one spec file for each class. (Have you met require_relative yet? You may not be familiar with the YAML module; YAML is a simple text database that we’ll use to store data. Let’s start with the tests for the Book class.
Rails Conf 2013 BDD and Acceptance Testing with RSpec & Capybara HTML5 Canvas Particles Fountain Explosion with Gravity | Code Theory One of my previous posts talked about implementing gravity in our canvas experiments. Eventually, we made a realistic bouncing ball. We’ll kind of extend that experiment to make a quick fountain explosion on canvas obeying gravity. Demo I have made a demo as a codecast. Understanding the Logic First, there’s all those basic code where we get the 2d context of canvas and set our gravity value along with particles count. The initial velocities on both axis are randomly generated. It is important to note that vy must be negative initially. Finally, let’s talk a bit about the main part of the code that does the animation along with other tasks like applying gravity, repositioning the particles when they move off the canvas and clearing off the canvas to prevent the particle trails from showing up. Initially, we clear the entire canvas in renderFrame so that the particles do not leave trails when moving. Just re-setting the x and y positions is not enough. Still confused ? Final Words Share:
CSS animations and transitions performance: looking inside the browser | Web Platform Team Blog You’ve probably used CSS Animations or CSS Transitions in a project. (If not, check out CSS-Trick’s almanac entries on animations and transitions.) Some of your animations might have performed smoothly. Other might have appeared choppy. In this article, we’ll explore how browsers handle CSS Animations and CSS Transitions, so you can develop intuition around whether an animation is likely to perform well — before writing any code! Browser Internals Let’s pop the hood of the browser, and look around. Modern browsers typically have two important threads of execution. The main threadThe compositor thread Typically, the main thread is responsible for: Running your JavaScript.Calculating your HTML elements’ CSS styles.Laying out your page.Painting your elements into one or more bitmaps.Handing these bitmaps over to the compositor thread. Typically, the compositor thread is responsible for: The main thread can be busy for long periods of time running your JavaScript or painting a large element.
#275 How I Test Here I show how I would add tests to the password reset feature created in the previous episode. I use RSpec, Capybara, Factory Girl, and Guard to make request, model, and mailer specs. Download: source codeProject Files in Zip (92.2 KB)mp4Full Size H.264 Video (26.4 MB)m4vSmaller H.264 Video (16.1 MB)webmFull Size VP8 Video (18.1 MB)ogvFull Size Theora Video (37.8 MB) #71 Testing Controllers with RSpec Controllers are tricky to test, and there's no perfect way to do it. In this episode you will see how I test controllers, and my reasoning behind it. Download: mp4Full Size H.264 Video (18.7 MB)m4vSmaller H.264 Video (12.1 MB)webmFull Size VP8 Video (39 MB)ogvFull Size Theora Video (26.3 MB)
Angular Modules and RequireJS best practices? Well I'm as blind as a bat with this stuff right now but if I can make progress I'll certainly post it for you! I'm not doing ETE testing yet – trying to plug in unit tests first. I think I got past the problem my gist is referring to and have a new one (the problem I was having was due to the fact that someone (ME) forgot to add the service.js.coffee file to the karma config file… once I did that I got past that part of it. Basically I have no idea what I need to put in there or how to do it… I have a controller that has this signature: @DsetCtrl = ($scope, $resource, dimResource) -> I have a service that looks a bit like this: angular.module "Naph", ["ngResource", "$strap.directives", "ng-rails-csrf", "EitDirectives", "EitServices"] angular.module("EitServices", []).factory "dimResource", ($resource, $rootScope) -> (obviously a bunch of code truncated out and I'm just showing the signatures of both) beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) { scope = $rootScope.
Absolutely No Machete Juggling » Scala Second Impressions In December, I posted about my early thoughts on Scala after using it for a short time. Initially, I thought that using Scala didn't buy very much - the functional style could be adopted in in Java, and the syntax and libraries could be ugly. Since that time, I've been using Scala almost exclusively, and I wish to revise my view: Scala is awesome. While some of my initial thoughts still stand, particularly that Scala APIs often overuse operator overloading, much of my perception has shifted otherwise. A great deal of my perception shift has been due to familiarity and training. Read the entirety of Odersky et. al.' All of these resources, combined with a continued daily use of Scala, led to me using Scala in a much meatier way than previously, enabling me to write some extremely expressive code. I really like how strict Scala is in terms of the compiler. Pattern matching is simply awesome. There are a few nags I have about Scala.