Skip to content

Instantly share code, notes, and snippets.

@HusseinMorsy
Created August 5, 2008 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HusseinMorsy/4050 to your computer and use it in GitHub Desktop.
Save HusseinMorsy/4050 to your computer and use it in GitHub Desktop.
Beispiel für Story
Zur Demonstration von Stories, wird eine einfache Klasse zur MwSt. Berechnung erstellt.
Story: Calculate german Mehrwertsteuer
As a secretary
I want to calculate Mehrwertsteuer
So that i can write Invoices to our Customer
Scenario: mwst calculation of 1 EUR
Given an amount of 1 EUR
When calculate mwst
Then the result should be 0.19 EUR
Scenario: brutto calculation of 1 EUR
Given an amount of 1 EUR
When calculate brutto
Then the result should be 1.19 EUR
Scenario: netto calculation of 1.19 EUR
Given an amount of 1.19 EUR
When calculate netto
Then the result should be 1 EUR
Scenario: brutto calculation of 25.5 EUR
Given an amount of 25.5 EUR
When calculate brutto
Then the result should be 30.345 EUR
# Erweitert die Klasse Float um MwSt berechnung
class Float
def mwst
self * 0.19
end
def brutto
self * 1.19
end
def netto
self/1.19
end
end
steps_for(:mwst_calculations) do
Given "an amount of $value EUR" do |value|
@amount = value.to_f
end
When "calculate mwst" do
@result = @amount.mwst
end
When "calculate brutto" do
@result = @amount.brutto
end
When "calculate netto" do
@result = @amount.netto
end
Then "the result should be $value EUR" do |value|
@result.should == value.to_f
end
end
require 'rubygems'
require 'spec/story'
dir = File.dirname(__FILE__)
require File.expand_path("#{dir}/../mwst")
require File.expand_path("#{dir}/mwst_steps.rb")
with_steps_for(:mwst_calculations) do
run File.expand_path("#{dir}/mwst")
end
Beispiel für Story
Zur Demonstration von Stories, wird eine einfache Klasse zur MwSt. Berechnung erstellt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment