-
-
Save rafbm/5019918 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
describe ReportsController do | |
describe :create do | |
before do | |
@payload = { :version => "1.0.0" } | |
end | |
it "succeeds with present serial" do | |
@payload[:serial] = "123abc" | |
post reports_path, @payload.to_json | |
last_response.should be_ok | |
last_response.status.should eq 200 | |
end | |
it "fails with missing serial" do | |
@payload[:serial] = nil | |
post reports_path, @payload.to_json | |
last_response.should_not be_ok | |
last_response.status.should eq 400 | |
end | |
end | |
end |
…srait le fun que les comments de gists s’updatent automagiquement comme les issues…
Toujours possible de faire ça si t’as une shitload d’expectations :
it "fails with missing serial" do
@payload[:serial] = nil
post reports_path, @payload.to_json
last_response.instance_eval do
should_not be_ok
status.should eq 400
JSON.parse(body)["errors"].should include?("Missing serial number")
end
end
__evil laugh**
Dans cet exemple, est-ce que RSpec roule le
before
avant leit
et avant leits
?
Yep. Le before
est exécuté une fois avant le it
et une fois avant le its
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mmh je comprends. Ça ne m’a jamais agacé qu’un test qui fail arrête d’évaluer les autres expectations. Je trouve que ça a parfaitement du sens que certains tests contiennent plusieurs expectations.
Dans cet exemple, est-ce que RSpec roule le
before
avant leit
et avant leits
?