This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FoosController < ActionController::Base | |
| end | |
| context "a controller test" do | |
| controlling :foos | |
| asserts("situation") { self }.respond_to(:get) | |
| asserts("situation") { self }.respond_to(:post) | |
| asserts("situation") { self }.respond_to(:put) | |
| asserts("situation") { self }.respond_to(:delete) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ... | |
| context "for a given user" do | |
| setup do | |
| topic.user = User.create(:name => "acme", :email => "[email protected]", | |
| :password => "h3ll0", :password_confirmation => "h3ll0") | |
| topic.description = "Foo Bar" | |
| topic.name = "foo_bar" | |
| topic.save! | |
| topic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| class Foo | |
| def a; true; end | |
| end | |
| n = 1_000_000 | |
| Benchmark.bm(30) do | b | | |
| instance = Foo.new | |
| b.report( "a simple method call" ) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # magical binding | |
| # | |
| module RiotA | |
| module AssertionMacros | |
| # def equals(expected) puts "yay"; end | |
| def equals(expected) true; end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class A | |
| def initialize | |
| super() | |
| puts "Hairy chins" | |
| end | |
| end | |
| B = Class.new(A) | |
| B.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def classpath(g) | |
| path = g.runtime_dependencies.inject([]) do |acc, dep| | |
| acc + classpath(Gem.source_index.find_name(dep.name, dep).first) | |
| end | |
| path << g.full_gem_path | |
| end | |
| classpath(Gem.source_index.find_name('radiant').first).join(':') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| ## | |
| # I want to document this block because it will end up creating a method | |
| my_class_method(:bar) do |foo| | |
| puts "I'm, doing something" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.8.0], MBARI 0x8770, Ruby Enterprise Edition 2009.10 | |
| # | |
| # Riot vs Shoulda vs Test::Unit | |
| # | |
| Rehearsal ---------------------------------------------- | |
| Riot 0.360000 0.000000 0.360000 ( 0.367155) | |
| Test::Unit 1.250000 0.010000 1.260000 ( 1.259351) | |
| Shoulda 1.290000 0.000000 1.290000 ( 1.315967) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/test/test_helper.rb b/test/test_helper.rb | |
| index 8ca9c51..8e13d5d 100644 | |
| --- a/test/test_helper.rb | |
| +++ b/test/test_helper.rb | |
| @@ -10,23 +10,28 @@ require 'toto' | |
| module Riot | |
| class Assertion | |
| assertion(:includes) do |actual, expected| | |
| - actual.include?(expected) || fail("expected #{actual} to include #{expected}") | |
| + actual.include?(expected) ? pass : fail("expected #{actual} to include #{expected}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # KEEPING HERE FOR POSTERITY (_gus) | |
| # Allows for a named_scope chain like this, | |
| # Business.owned_by(current_user).limit(10) | |
| # to be cleanly tested like this, | |
| # assert_named_scope_chain(Business, { :owned_by => current_user }, { :limit => 10 }) | |
| # rather than having to create nasty mock objects. | |
| def expected_named_scope_chain(*ordered_chain) | |
| results = [] | |
OlderNewer