This file contains 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
#language: es | |
Característica: administrador introduce moción | |
Como administrador de circunscripción | |
Quiero introducir mociones | |
Para que los ciudadanos puedan votarlas | |
Antecedentes: usuario logeado quiere introducir moción | |
Dado que el usuario logeado es "pepito" | |
Y quiere introducir una moción con título "Aprobar presupuesto para farolas" | |
Y con contenido "Se compraran 100 farolas a 50€ cada una a la empresa Farolillos S.A." |
This file contains 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
#language: es | |
Característica: ciudadano realiza votación directa | |
Como ciudadano | |
Quiero votar mociones directamente | |
Para influir en las decisiones que me interesan | |
Antecedentes: administrador ha introducido la moción | |
<pendiente> | |
Escenario: |
This file contains 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 Scrapper | |
# Dada la busqueda configurada | |
# Para cada página | |
# Para cada enlace de propuesta | |
# explora enlaces de propuestas | |
# actualiza propuestas en base de datos | |
def initialize() | |
@agent = Mechanize.new | |
@agent.history_max = 10 |
This file contains 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 Distancia { | |
Integer valor | |
String unidad | |
boolean equals(Object otro) { | |
return true | |
} | |
Integer plus(Object otro) { | |
return 10 |
This file contains 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 DistanciaTest extends GroovyTestCase { | |
def d1, d2 | |
void setUp() { | |
d1 = new Distancia(valor:5, unidad:"m") | |
d2 = new Distancia(valor:5, unidad:"m") | |
} | |
void testSumaOk() { | |
assertEquals("Deben sumarse correctamente", d1+d2, 10) |
This file contains 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 CreateGrupos < ActiveRecord::Migration | |
def change | |
create_table :grupos do |t| | |
t.string :nombre | |
t.timestamps | |
end | |
end | |
end |
This file contains 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
lennon = Persona.find_by_nombre("John Lennon") | |
lennon.grupo = Grupo.find_by_nombre("Ramones") | |
lennon.save |
This file contains 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 chop(valor, lista) | |
case(lista.size) | |
when 0 then return -1 | |
when 1 then return (lista[0] != valor)? -1: 0 | |
else | |
mitad = lista.size/2 | |
if lista[mitad] > valor | |
return chop(valor, lista[0..mitad - 1]) | |
else | |
posicion = chop(valor, lista[mitad..lista.size]) |
This file contains 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
data = Array.new | |
File.foreach("weather.dat") { |line| | |
if line =~ /^\s+([0-9]+)\s+([0-9]+)[*]?\s+([0-9]+)[*]?/ then | |
data << {:day => Integer($1), :spread => Integer($2) - Integer($3)} | |
end | |
} | |
puts data.min { |a,b| a[:spread] <=> b[:spread] } |
This file contains 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
data = Array.new | |
File.foreach("football.dat") { |line| | |
if line =~ /^\s+[0-9]+[.]\s([a-zA-Z_]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+-\s+([0-9]+)/ then | |
data << { :team => $1, :goal_diff => (Integer($2) - Integer($3)).abs } | |
end | |
} | |
puts data.min { |a,b| a[:goal_diff] <=> b[:goal_diff] } |
OlderNewer