Skip to content

Commit

Permalink
Adding work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kleer committed Oct 14, 2016
1 parent b9f4feb commit 434676c
Show file tree
Hide file tree
Showing 27 changed files with 697 additions and 3 deletions.
2 changes: 2 additions & 0 deletions mortal-kombat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
webrat.log
coverage/
1 change: 1 addition & 0 deletions mortal-kombat/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color --format doc --require spec_helper
1 change: 1 addition & 0 deletions mortal-kombat/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3
11 changes: 11 additions & 0 deletions mortal-kombat/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# A sample Gemfile
source "https://rubygems.org"

gem "sinatra" #web framework
gem 'rspec' #unit testing
gem 'simplecov' #coverage report
gem 'simplecov-console' #coverage console report
gem 'cucumber' # aceptance testting
gem 'capybara' # framework to inspect web components
gem 'rack-test'# default web driver for capybara
gem 'better_errors' #better log errors on web
95 changes: 95 additions & 0 deletions mortal-kombat/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
ansi (1.5.0)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
builder (3.2.2)
capybara (2.8.0)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.1.1)
cucumber (2.4.0)
builder (>= 2.1.2)
cucumber-core (~> 1.5.0)
cucumber-wire (~> 0.0.1)
diff-lcs (>= 1.1.3)
gherkin (~> 4.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (1.5.0)
gherkin (~> 4.0)
cucumber-wire (0.0.1)
diff-lcs (1.2.5)
docile (1.1.5)
erubis (2.7.0)
gherkin (4.0.0)
hirb (0.7.3)
json (2.0.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
multi_json (1.12.1)
multi_test (0.1.2)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
pkg-config (1.1.7)
rack (1.6.4)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.2)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-console (0.3.1)
ansi
hirb
simplecov
simplecov-html (0.10.0)
sinatra (1.4.7)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
tilt (2.0.5)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
better_errors
capybara
cucumber
rack-test
rspec
simplecov
simplecov-console
sinatra

BUNDLED WITH
1.12.5
25 changes: 25 additions & 0 deletions mortal-kombat/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'sinatra'
require 'better_errors'

configure :development do
use BetterErrors::Middleware
BetterErrors.application_root = File.expand_path('..', __FILE__)
end

enable :sessions
set :session_secret, 'thisIsAKleerSecret'

get '/' do
erb :index
end

post '/iniciar' do
erb :characters
end

post '/combate' do
session["personaje"] = params['personaje']
session["oponente"] = params['oponente']

erb :combat
end
46 changes: 46 additions & 0 deletions mortal-kombat/features/combatir.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Feature:
Como jugador quiero combatir mi oponente
para ganar una partida y tener la oportunidad de hacer un fatality

Scenario: Con un combate iniciado quiero poder dar un golpe alto
Given que abrí el juego
When seleccioné start
And veo "Sub-Zero"
And veo "Scorpion"
And selecciono "Kombat!"
And veo "Fight!"
And debo ver la vida "Sub-Zero: 100" y "Scorpion: 100"
Then debo ver el panel de golpes de "personaje" con "golpe alto"

Scenario: Quiero herir a mi oponente con un golpe alto
Given que abrí el juego
When seleccioné start
And veo "Sub-Zero"
And veo "Scorpion"
And selecciono "Kombat!"
And veo "Fight!"
And debo ver la vida "Sub-Zero: 100" y "Scorpion: 100"
And selecciono golpe alto de personaje
Then la vida de oponente debe ser "Scorpion: 90"

Scenario: Cuando la vida del oponente se acabe quiero ganar el combate
Given que abrí el juego
When seleccioné start
And veo "Sub-Zero"
And veo "Scorpion"
And selecciono "Kombat!"
And veo "Fight!"
And debo ver la vida "Scorpion: 0"
Then debo ver "Winner"

Scenario: Cuando gane el combate quiero ver la pantalla de Finish Him!
Given que abrí el juego
When seleccioné start
And veo "Sub-Zero"
And veo "Scorpion"
And selecciono "Kombat!"
And veo "Fight!"
And debo ver la vida "Scorpion: 0"
And debo ver "Winner"
And selecciono "Winner"
Then debo ver "Finish Him"
20 changes: 20 additions & 0 deletions mortal-kombat/features/iniciarCombate.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature:
Como jugador
Quiero iniciar un combate

Scenario: quiero iniciar el combate
Given que abrí el juego
When seleccioné start
And veo "Sub-Zero"
And veo "Scorpion"
And selecciono "Kombat!"
Then debo ver "Fight!"

Scenario: quiero ver la vida de mi personaje
Given que abrí el juego
When seleccioné start
And veo "Sub-Zero"
And veo "Scorpion"
And selecciono "Kombat!"
And veo "Fight!"
Then debo ver la vida "Sub-Zero: 100" y "Scorpion: 100"
42 changes: 42 additions & 0 deletions mortal-kombat/features/iniciarJuego.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Feature:
Como jugador
Quiero seleccionar personajes

Scenario: quiero ver el nombre del juego
Given que abrí el juego
Then debo ver "Mortal Kombat"

Scenario: quiero poder iniciar el juego
Given que abrí el juego
And seleccioné start
Then debo ver "Choose your character"

Scenario: quiero poder seleccionar mi personaje
Given que abrí el juego
When seleccioné start
And veo "Choose your character"
Then debo ver "Pick your warrior"

Scenario: quiero poder seleccionar mi rival
Given que abrí el juego
When seleccioné start
And veo "Choose your character"
Then debo ver "Pick your enemy"

Scenario: quiero iniciar el combate
Given que abrí el juego
When seleccioné start
And veo "Pick your warrior"
Then debo ver "Kombat!"

Scenario: quiero seleccionar "Sub-Zero" como mi personaje
Given que abrí el juego
When seleccioné start
And veo "Pick your warrior"
Then debo ver "Sub-Zero"

Scenario: quiero seleccionar "Scorpion" como mi rival
Given que abrí el juego
When seleccioné start
And veo "Pick your enemy"
Then debo ver "Scorpion"
45 changes: 45 additions & 0 deletions mortal-kombat/features/step_definitions/my_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Given(/^que abrí el juego$/) do
visit '/'
end

Then(/^debo ver "([^"]*)"$/) do |text|
expect(page.body).to match /#{text}/m
end

Given(/^seleccioné start$/) do
click_button("iniciar")
end

When(/^veo "([^"]*)"$/) do |text|
expect(page.body).to match /#{text}/m
end

Given(/^que veo "([^"]*)"$/) do |text|
expect(page.body).to match /#{text}/m
end

When(/^selecciono "([^"]*)"$/) do |arg1|
click_button("Kombat!")
end

Then(/^debo ver la vida "([^"]*)" y "([^"]*)"$/) do |personaje, oponente|
expect(find("#vida-personaje").text).to match /#{personaje}/m
expect(find("#vida-oponente").text).to match /#{oponente}/m
end

Then(/^debo ver el panel de golpes de "([^"]*)" con "([^"]*)"$/) do |peleador, golpe|
expect(find("#panel-golpes-#{peleador}").text).to match /#{peleador}/m
expect(find("#golpe-alto-#{peleador}").text).to match /#{golpe}/m
end

When(/^selecciono golpe alto de personaje$/) do
click_button("#golpe-alto-personaje")
end

Then(/^la vida de oponente debe ser "([^"]*)"$/) do |oponente|
expect(find("#vida-oponente").text).to match /#{oponente}/m
end

When(/^debo ver la vida "([^"]*)"$/) do |oponente|
expect(find("#vida-oponente").text).to match /#{oponente}/m
end
48 changes: 48 additions & 0 deletions mortal-kombat/features/step_definitions/template_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Given /^I open the web app$/ do
visit '/'
end

Given /^I post to the web app$/ do
visit '/', :post, "field_name=value"
end

When /^I click on "(.*)"$/ do |text|
click_link(text)
end

Then /^I should see "(.*)"$/ do |text|
expect(page.body).to match /#{text}/m
end

When /^I provide "(.*)" as "(.*)"$/ do |field, value|
fill_in(field, :with => value)
end

When /^I press "(.*)"$/ do |name|
click_button(name)
end

#Then I should see the image "google.png"
#<img src="google.png" alt="google">
Then(/^I should see the image "(.*?)"$/) do |image_name|
expect(page).to have_xpath("//img[@src=\"#{image_name}\"]")
end

# Check the content of a specific table cell
# To use this, every cell should have a unique ID like XX:YY (1:3)
Then(/^I should see "(.*?)" at the cell (\d+),(\d+)$/) do |text, x, y|
cell = "##{x}-#{y}"
expect(find(cell).text).to match /#{text}/m
end


#other options:
#find_field('First Name').value
#find_link('Hello', :visible => :all).visible?
#find_button('Send').click

#find(:xpath, "//table/tr").click
#find("#overlay").find("h1").click
#all('a').each { |a| a[:href] }

#see more: https://github.com/jnicklas/capybara
22 changes: 22 additions & 0 deletions mortal-kombat/features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'simplecov'
SimpleCov.start
# Sinatra
require File.join(File.dirname(__FILE__), *%w[.. .. app])
# Force the application name because polyglot breaks the auto-detection logic.
Sinatra::Application.app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])

require 'rspec/expectations'
require 'capybara/cucumber'


class MyWorld
include Capybara::DSL
include RSpec::Expectations
include RSpec::Matchers
end


Capybara.app = Sinatra::Application

World{MyWorld.new}

Empty file added mortal-kombat/lib/.keep
Empty file.
Empty file added mortal-kombat/public/.keep
Empty file.
10 changes: 10 additions & 0 deletions mortal-kombat/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'simplecov'
require 'simplecov-console'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console,
]
SimpleCov.start do
add_filter ".bundle"
add_filter "template_steps"
end
Empty file added mortal-kombat/views/.keep
Empty file.
Loading

0 comments on commit 434676c

Please sign in to comment.