Created
August 29, 2016 05:21
-
-
Save ivancorrales/9ecea796cb1321b7fec3f930e4408954 to your computer and use it in GitHub Desktop.
This file contains 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
defmodule ExkorpionDemo.MathOperationsTest do | |
use Exkorpion | |
def sum(a,b) do | |
a + b | |
end | |
def subs a, b do | |
a - b | |
end | |
scenario "testing sum operation works as expected" do | |
it "sum positive numbers works as expected" do | |
%{ | |
given: fn -> %{a: 1, b: 2} end, | |
when: fn ctx -> | |
%{c: ctx.a + ctx.b} | |
end, | |
then: fn ctx -> | |
assert ctx.c === 3 | |
end | |
} | |
end | |
it "sum negative numbers and it should work as expected" do | |
%{ | |
given: fn -> | |
%{a: -1, b: -2} | |
end, | |
when: fn ctx -> | |
%{c: sum(ctx.a, ctx.b)} | |
end, | |
then: fn ctx -> | |
assert ctx.c === -3 | |
end | |
} | |
end | |
it "does multiple operations depending on vairable input" do | |
%{ | |
with: fn -> | |
[ | |
%{param1: 2, param2: 3, result: 5}, | |
%{param1: 3, param2: -2, result: 1} | |
] | |
end, | |
given: fn ctx -> | |
%{a: ctx.param1, b: ctx.param2} | |
end, | |
when: fn ctx -> | |
%{c: sum(ctx.a, ctx.b)} | |
end, | |
then: fn ctx -> | |
assert ctx.c === ctx.result | |
end | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment