Comments (5)
Could you link to any/all sources you are referring to?
I am also interested in what others have to say.
from betterspecs.
I was surfing for how to remove an expectation from a method, so Google:
rspec how do I remove an expectation
and you will see the list of hits.
One hit is http://stackoverflow.com/questions/25308667/how-to-reset-expectations-on-a-mocked-class-method
The first comment to the question starts the conversation. The answer also implies (to my eyes) that adding expectations in a before hook should not be done.
from betterspecs.
IMO, I think before, after, background, etc should be reserved for setting up a scenario. If you are expecting the same thing 10 times, why not make it its own test? You can add a comment where you assume that expectation to be true later one.
Do you have an example from your own work you'd like to share?
from betterspecs.
before, after, background, etc should be reserved for setting up a scenario
👍
from betterspecs.
I'm not sure how much you want to see.
describe "#print" do
let(:options) { instance_double("Options") }
let(:context) {
instance_double("Context").tap do |context|
expect(context).to receive(:done)
expect(context).to receive(:in_list).and_return(false)
end
}
context "with no filters" do
it "should print but produce no output" do
instance.print(context)
end
end
end
The print routine always calls in_list and done in this scenario so I put those expectations inside the let.
from betterspecs.
Related Issues (20)
- Move from Heroku to Github Pages HOT 50
- Adapt all "translation pages" to the new layout HOT 1
- Use an i18n tool to maintain translations HOT 9
- Merge latest PR changes into gh-pages HOT 14
- Bring back "Resources" section to gh-pages HOT 1
- Move translated texts to corresponding YAML file HOT 3
- Homepage stored in GitHub metadata is not a URL HOT 3
- one-liner `should` syntax should be 'GOOD' HOT 5
- Usage of described_class HOT 2
- Our very first issue! Yay! #1
- Provide a version for Chai.js HOT 4
- Feature / integration / acceptance spec styles HOT 2
- Invalid SSL certificate for https://www.betterspecs.org HOT 2
- Old Content HOT 1
- Call for maintainer HOT 11
- Help needed to launch the new version of Betterspecs HOT 9
- Broken link on "Here a nice presentation explaining how to mix them together."
- Integration specs: what about of using expectations inside "let" blocks
- Link to self-hosted, non-Relishapp RSpec documentation
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 betterspecs.