forked from antonmi/espec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request antonmi#235 from antonmi/let_in_generated_examples
Improve 'let' so it works in generated examples
- Loading branch information
Showing
2 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
defmodule LetInGeneratedExamples do | ||
use ESpec | ||
|
||
context "using let in nested contexts" do | ||
Enum.each [:a, :b, :c], fn(value) -> | ||
context "with value #{inspect value}" do | ||
let :x, do: unquote(value) | ||
|
||
it "should equal #{inspect value}" do | ||
x() |> should(eq unquote(value)) | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "using subject in nested contexts" do | ||
Enum.each [:a, :b, :c], fn(value) -> | ||
context "with value #{inspect value}" do | ||
subject(unquote(value)) | ||
|
||
it "should equal #{inspect value}" do | ||
should(eq unquote(value)) | ||
should(eq unquote(value)) | ||
end | ||
end | ||
end | ||
end | ||
end |