Created
August 5, 2008 11:08
-
-
Save HusseinMorsy/4050 to your computer and use it in GitHub Desktop.
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
Beispiel für Story | |
Zur Demonstration von Stories, wird eine einfache Klasse zur MwSt. Berechnung erstellt. |
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
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 | |
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
# 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 |
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
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 |
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 '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 |
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
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