background preloader

Better Specs { rspec guidelines with ruby }

Better Specs { rspec guidelines with ruby }

vojtajina/ng-directive-testing 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

Rails Conf 2013 BDD and Acceptance Testing with RSpec & Capybara 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) 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 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.

Port Scanning Techniques -sS (TCP SYN scan) SYN scan is the default and most popular scan option for good reasons. It can be performed quickly, scanning thousands of ports per second on a fast network not hampered by restrictive firewalls. It is also relatively unobtrusive and stealthy since it never completes TCP connections. This technique is often referred to as half-open scanning, because you don't open a full TCP connection. -sT (TCP connect scan) TCP connect scan is the default TCP scan type when SYN scan is not an option. When SYN scan is available, it is usually a better choice. -sU (UDP scans) While most popular services on the Internet run over the TCP protocol, UDP services are widely deployed. UDP scan is activated with the -sU option. UDP scan works by sending a UDP packet to every targeted port. A big challenge with UDP scanning is doing it quickly. Nmap detects rate limiting and slows down accordingly to avoid flooding the network with useless packets that the target machine will drop.

RSpec | PeepCode Screencasts ▶ We’ve been acquired by Pluralsight! ▶ Upgrade your account to Pluralsight ▶ More details… Filter by tag: Ruby on Rails · Ruby · Javascript · Play by Play · Unix · RSpec · Deployment · Pdf · Design · Cocoa · iPhone · Node · Databases · Productivity · Git RSpec 2: with Rails 4 and Ruby 2 (Part 3 of 3) RSpec 2: Tools (Part 2 of 3) RSpec 2: The Basics (Part 1 of 3) Use the Cucumber RSpec Controllers and Tools RSpec Mocks and Models RSpec Basics rb: Rspec views with Rails 3 For a long time, i didn't try with creating apps with BDD or TDD.So i decided to go with rspec, after reading the Rails Views from The Rspec Book.A view spec is a collection of code examples for a particular view template.View specs live in spec/views and render view templates in isolation. Let's generate a fresh app with rails version 3.0.6, rspec 2.3.0 & rspec-rails 2.3.1.As we are using rspec, so remove the test folder from the rails project direcory. If you type rails generate, the only RSpec generator you'll actually see is rspec:install. First i have generated my model with title and description attributes for creating a simple form.rails g model post title:string description:text rake db:migrate rake db:test:prepare Second, i have generated my post controller with actions index, show, new, create, update and delete. Now run the spec: ruby -S bundle exec rspec spec/views/posts/new.html.erb_spec.rb. ruby -S bundle exec rspec spec/views/posts/show.html.erb_spec.rb.

How To Conduct An Effective IT Security Risk Assessment Measuring risk is a key to justifying new security spending. Here's a road map for doing it [Excerpted from "How to Conduct an Effective IT Security Risk Assessment," a new report posted this week on Dark Reading's Risk Management Tech Center.] Many security and compliance projects begin with a simple idea: assess the organization's risk of vulnerabilities and breaches. An effective security risk assessment can prevent breaches, reduce the impact of realized breaches, and keep your company's name from appearing in the spotlight for all the wrong reasons. It's important to note that not every IT security risk assessment is alike -- or even remotely close. There are basically three risk management components: 1. 2. 3. The presence of these three high-level processes is constant in all risk assessment methodologies, although what they are called may vary. Traditional risk assessment includes general IT-related issues such as accidental outages, hardware failures, and uptime. More Insights

Documentation for rspec-rails (2.12.2) rspec-rails is a testing framework for Rails 3.x and 4.x. Use rspec-rails 1.x for Rails 2.x. Installation Add rspec-rails to both the :development and :test groups in the Gemfile: group :development, :test do gem 'rspec-rails', '~> 2.0'end Download and install by running: bundle install Initialize the spec/ directory (where specs will reside) with: rails generate rspec:install To run your specs, use the rspec command: bundle exec rspec bundle exec rspec spec/models bundle exec rspec spec/controllers/accounts_controller_spec.rb Specs can also be run via rake spec, though this command may be slower to start than the rspec command. In Rails 4, you may want to create a binstub for the rspec command so it can be run via bin/rspec: bundle binstubs rspec-core Generators Once installed, RSpec will generate spec files instead of Test::Unit test files when commands like rails generate model and rails generate controller are used. You may also invoke invoke RSpec generators independently. Model Specs Upgrade note