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
describe Order do | |
let(:product){stub(:product)} | |
let(:payment_gateway){stub(:payment_gateway)} | |
let(:order){Order.new(payment_gateway)} | |
it "confirm the order if the client has funds" do | |
product.stub(:price).and_return(50) | |
payment_gateway.stub(:user_has_funds).with(50).and_return(true) | |
order.buy(product).should be_true | |
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
require 'rspec' | |
class StringCalculator | |
def add(string) | |
return add(string_without_last_summand(string)) + last_summand(string) if more_than_one_summand?(string) | |
string.to_i | |
end | |
def string_without_last_summand(string) | |
string[0...last_separator_index(string)] | |
end | |
def last_summand(string) |
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 call(env) | |
set_user_language_variable(env) | |
set_include_language_banner_variable(env) | |
call_haml_serve(env) do |response, preferred_locale| | |
set_preferred_locale_cookie(response, preferred_locale) if AVAILABLE_LOCALES.include?(preferred_locale) | |
end | |
end | |
def set_user_language_variable(env) | |
if has_language_cookie?(env) |
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 call(env) | |
set_variables(env) | |
call_haml_serve(env) do |response, preferred_locale| | |
set_preferred_locale_cookie(response, preferred_locale) if AVAILABLE_LOCALES.include?(preferred_locale) | |
end | |
end | |
def set_variables(env) | |
if has_language_cookie?(env) |
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
#¿Posible escenario aún más expresivo? | |
Scenario: I visit the homepage with "es" set as preferred locale | |
Given I have selected "es" as preferred locale | |
When I request the home page | |
Then I should see the Spanish version of the site |
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
#Mi escenario | |
Scenario: I visit the homepage with the spanish cookie | |
Given I have selected spanish as default language | |
When I request the home page | |
Then I should see "software que amarás" | |
#Escenario con Aimee | |
Scenario: I visit the homepage with the spanish cookie | |
Given I have selected "es" as default locale | |
When I request the home page |
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
public class Cajero { | |
public void muestraLaPantallaPrincipal() { | |
Banco banco = new Banco(new OperacionesBancariasBancoManolito(), | |
this); | |
banco.obtenerCuenta(obtenCredenciales()); | |
} | |
public void cuentaObtenida(Cuenta cuenta) { | |
muestraInformacionDeLacuenta(cuenta); |
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
public class Banco { | |
private final OperacionesBancarias operacionesBancarias; | |
private final Cajero cajero; | |
public Banco(OperacionesBancarias operacionesBancarias, | |
Cajero cajero) { | |
this.operacionesBancarias = operacionesBancarias; | |
this.cajero = cajero; | |
} |
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
public class Banco { | |
private final OperacionesBancarias operacionesBancarias; | |
public Banco(OperacionesBancarias operacionesBancarias) { | |
this.operacionesBancarias = operacionesBancarias; | |
} | |
public Cuenta obtenerCuenta(Credenciales credenciales) { | |
Token token = operacionesBancarias.autenticar(credenciales); |
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
public class Banco { | |
private final OperacionesBancarias operacionesBancarias; | |
private final InteresadoEnAccesoACuenta suscriptor; | |
public Banco(OperacionesBancarias operacionesBancarias, | |
InteresadoEnAccesoACuenta suscriptor) { | |
this.operacionesBancarias = operacionesBancarias; | |
this.suscriptor = suscriptor; | |
} |