Comments (2)
This issue came up a while ago: GH-26. I think the root problem is about mismatched expectations.
Since Speclj is based on RSpec, I assumed that it
components worked just like RSpec; when they are run they attach themselves to their current context. For example, this works in RSpec:
describe "it blocks" do
def self.run_me
it "runs this test" do
1.should == 2
end
it "and it runs this test" do
2.should == 1
end
end
run_me
end
$ rspec it_spec.rb
FF
Failures:
1) it blocks runs this test
Failure/Error: 1.should == 2
expected: 2
got: 1 (using ==)
# ./it_spec.rb:7:in `block in run_me'
2) it blocks and it runs this test
Failure/Error: 2.should == 1
expected: 1
got: 2 (using ==)
# ./it_spec.rb:11:in `block in run_me'
Finished in 0.00088 seconds
2 examples, 2 failures
Failed examples:
rspec ./it_spec.rb:6 # it blocks runs this test
rspec ./it_spec.rb:10 # it blocks and it runs this test
However, Speclj differs. it
components do not attach themselves to the current context. Instead, describe
components will attach any components that are passed to it. So, in @skatenerd 's example, only the last example is passed to the describe
block; resulting in a test that never runs.
from speclj.
Right. A Context (describe block) is a collection of Examples (it blocks). So when your test code is evaluated, Speclj collects a sequence of Contexts, which in turn collect a sequence of Examples; but none of the tests are “Executed” yet. This is good for a couple reasons.
- It fits the functional paradigm. Executing the tests generates side effects. Speclj postpones that as long as possible.
- The tests can be re-run. They’re just a bunch of functions stored in an persistent collection. Custom Runners can take advantage of this fact like the Vigilant (auto) runner does.
Knowing this, the use of ‘let’ should seem suspicious. Because the bindings are only valid when the specs are evaluated. You may not get what you want at execution time. Speclj provides components that you’ll prefer to use (‘with’ ‘before’ ‘after’ …)
That said, it is often useful to use a ‘for’ form to generate multiple examples. So long as your specs are wrapped in a list, which is what the ‘for’ form does, Speclj will flatten the nested structure.
On Jan 22, 2014, at 9:22 AM, Myles Megyesi [email protected] wrote:
This issue came up a while ago: GH-26. I think the root problem is about mismatched expectations.
Since Speclj is based on RSpec, I assumed that it components worked just like RSpec; when they are run they attach themselves to their current context. For example, this works in RSpec:
describe "it blocks" do
def self.run_me
it "runs this test" do
1.should == 2
endit "and it runs this test" do 2.should == 1 end
end
run_me
end
$ rspec it_spec.rb
FFFailures:
it blocks runs this test
Failure/Error: 1.should == 2
expected: 2
got: 1 (using ==)./it_spec.rb:7:in `block in run_me'
it blocks and it runs this test
Failure/Error: 2.should == 1
expected: 1
got: 2 (using ==)./it_spec.rb:11:in `block in run_me'
Finished in 0.00088 seconds
2 examples, 2 failuresFailed examples:
rspec ./it_spec.rb:6 # it blocks runs this test
rspec ./it_spec.rb:10 # it blocks and it runs this test
However, Speclj differs. it components do not attach themselves to the current context. Instead, describe components will attach any components that are passed to it. So, in @skatenerd 's example, only the last example is passed to the describe block; resulting in a test that never runs.—
Reply to this email directly or view it on GitHub.
from speclj.
Related Issues (20)
- Add support for regex's with should-throw?
- Unable to open file '/dev/stdout' HOT 1
- Ring auto-reload: Unable to resolve var: speclj.stub/*stubbed-invocations* in this context HOT 1
- Hook for exception reporting
- Home page: Sorce code -> Source code
- Use a less error-prone test for cljs
- Autotest runs tests twice when specifying reporter HOT 1
- There's no spec-specific Leiningen profile HOT 2
- Documentation not working on the site
- 'Expected' vs 'got' HOT 2
- Could not find variable require HOT 2
- context feature HOT 1
- "lein spec" uses a different namespace relative to "lein spec -a"
- Introduction of cemerick/url as project dependency breaks speclj HOT 1
- "let" around multiple specs causes only last spec to execute HOT 1
- NullPointerException using `should-invoke` when test ought to pass HOT 1
- should= with nil floats yields java.lang.NullPointerException
- directory name with space in it HOT 2
- cljs howto broken
- Running a single test from the repl
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from speclj.