Giter Club home page Giter Club logo

mundo-pepino's Introduction

MundoPepino

Welcome to MundoPepino!

First of all, please note that this README is also available and (still) much more complete in Spanish.

Presentation

Expresing our app behaviour with a natural language has to deal with the fact that one sentence can be expresed in many different ways.

This fact can easily drive us towards an explosion of the step definitions making the maintenance of our app more difficult.

At the same time, to describe an app there is a group of sentences that we're very likely to need, like for example those which refer to posible interactions of the user while browsing a site.

MundoPepino is a set of reusable step definitions to test Rails apps with Cucumber.

DISCLAIMER:

MundoPepino was originally implemented to write features in Spanish. Its code has been recently modified to support different languages (and, theoretically, at the same time if needed).

Currently only part of the original set of steps (and just a little of the documentation) has been translated to English. On the other hand features written in English don't have to manage the complexity added by translations of models and attributes. Cousin projects like pickle or email-spec are much more advanced to write features in English.

For other languages, before start your own implementation, it'd be nice if you:

  • start a new language in MundoPepino (we'll be glad to help you if you try), or
  • look for your language in similar i18n projects.

Resources

Definitions

Givens/Whens

Simple instance/s creation optionally with its/their name/s

Given three orchards called "H-01, H-02 y H-03"

more examples

Page request

Given I am on the homepage

more examples

Thens

I see (or not) a text

Then I should see the text "Hello!"

more examples

License

Copyright 2009, The Cocktail Experience. Fernando García Samblas <fernando.garcia at the-cocktail.com>

This is free software released under the GPL License (see license agreement in COPYING).

mundo-pepino's People

Contributors

nando avatar voodoorai2000 avatar gaizka avatar pacoguzman avatar

Stargazers

Ignacio Villaverde avatar Angus H. avatar  avatar automata infinito avatar AlejandroGQ avatar Carlos Bolaños avatar Jose Fortes avatar Javier Juarez avatar Rafa García avatar Dani Blanco avatar Paco Benavent avatar  avatar Alberto Perdomo avatar Manuel González Noriega avatar David Arango avatar  avatar  avatar  avatar Gumer Coronel avatar Jean-Michel Garnier avatar danigb avatar  avatar Manuel Muñoz Solera avatar Edu Fernández avatar Christos Zisopoulos avatar

Watchers

 avatar  avatar Manuel González Noriega avatar  avatar James Cloos avatar  avatar

mundo-pepino's Issues

Filling fields of nested attributes

R&R (Raul & Rai ;) says:

"And I fill email with "[email protected]" for student with name "Roland Moore""

When /^I replace (.+) (?:with|as) ['"](.*)["'] for #{model_names} with (.+) ['"](.*)["']$/i do |field_to_save, value_to_save, model_name, field_to_search, value_to_search|
  resource = model_name.to_model.send("find_by_#{field_to_search}", value_to_search)
  fill_in "#{model_name.to_model.name.underscore}_#{resource.id}_#{field_to_save}", 
          :with => value_to_save
end

'Cuando visito la página de la escuela "Patones"' no funciona

Da el mensaje de match duplicado. Tenemos que mirarlo.

En cambio, así sí que funciona:
Cuando visito la página del escuela "Patones"'

Error:

Ambiguous match of "visito la página de la escuela "Patones"":
      
      vendor/plugins/mundo-pepino/lib/definitions/es_ES.rb:89:in `/^(?:que )?visito (?:el|la) (?:p[áa]gina|portada|[íi]ndice|listado|colecci[óo]n) (?:del|de la) (.+) ['"](.+)["']$/i'
      vendor/plugins/mundo-pepino/lib/definitions/es_ES.rb:99:in `/^(?:que )?visito la p[áa]gina de ([\w\/]+) (?:de |de la |del )?(.+?)(?: (['"].+["']))?$/i'
      
      You can run again with --guess to make Cucumber be more smart about it
       (Cucumber::Ambiguous)

Definición de mapeo de URL a partir del sistema de rutas

Ahora en el mapeo de URLs metemos las rutas "hardcoded", sin usar el sistema de rutas. Por ejemplo, ahora tenemos:

String.url_mappings = {
/^la (portada|home)/i => '/',
/^la página de identificación/i => '/login'
}

lo ideal sería root_path en lugar de '/' y new_session_path en lugar de '/login'.

"Entonces veo etiqueta con valor" no admite el uso de clave I18n

P.e.:

Entonces debería ver la etiqueta div#notice con el texto "devise.sessions.signed_in,{:name => 'Carlos'}"

No es atrapada porque la expresión regular no permite que dentro del valor ("devise.sessions.signed_in,{:name => 'Carlos'}") existan comillas.

Soporte para aplicaciones multi-domino

Para testear estamos utilizando Webrat, con Cucumber y Mundo Pepino por encima, por lo que el problema venía con los típicos "visito la página de" o "calco el enlace X". Lo que hice fue modificar el código de Mundo Pepino para que al visitar una URL permitiera especificar el dominio, de manera muy tonta.

El código lo modifiqué en el fichero "lib/mundo_pepino/visits_history.rb", en el método do_visit. en lugar de la línea

visit url

Lo que tengo es

visit "http://#{Settings.app.default_host}#{url}"

Y luego en un step creado por mi lo que hago es poner valor a ese Settings.app.default_host

Dado /^que estamos en el site "(.+)"$/ do |site_name|

site = Site.find_by_title site_name
Settings.app["default_host"] = site.host

end

Problema con step tables y claves foráneas multi-palabra

Hola Nando,

Ante todo ¡muchas felicitaciones por en el nacimiento de la nueva peque! Espero que estéis los cuatro bien y disfrutándola mucho :)

He encontrado y solucionado un pequeño problema en la forma que Mundo Pepino maneja los nombres de claves foráneas en step tables. El problema causaba que una step table con un nombre de clave foránea como "post_id" fuese bien, pero uno como "forum_post_id" diese un error.

Simplemente, en el método parsed_attributes de mundo_pepino.rb, se usaba el método 'capitalize' sobre el nombre de la columna, que daba como nombre de la clase AR algo como 'Forum_post', en vez del deseado ForumPost, arrojando el consiguiente error (si el nombre de la fk no era compuesto funcionaba bien, ie. Post)

Simplemente hay que utilizar 'camelize', de forma que la línea 144 de mundo_pepino.rb queda así

      attributes[$1.to_sym] = eval($1.camelize).find(v.to_i)

Y creo que nada más. Es muy trivial, pero si quieres un patch apropiado me dices :)

Felicidades de nuevo y muchas gracias por el curro en Mundo Pepino

Tenemos en base de datos registros que pertenecen a un mismo modelo

Hola Nando,

Estoy volviendo a jugar con mundo pepino y vaya curro que le has dado. Y me ha surgido la idea de un step que podría molar. La idea sería:

Dado que tenemos un usuario llamado "Fred"
Cuando dicho usuario crea 2 blogs navegando por la aplicación
Entonces tenemos en la bbdd 2 blogs que tienen como autor a "Fred"

El último step es el que creo que molaría añadir, para el caso en que no se de un nombre a los blogs ya que en ese caso se podría hacer así.
Entonces el usuario "Fred" tiene en bbdd un blog "blog1"
Y el usuario "Fred" tiene en bbdd un blog "blog2"

¿Cómo lo ves?

Un saludo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.