Skip to content

Instantly share code, notes, and snippets.

@andrewpthorp
Created December 13, 2012 04:38
Show Gist options
  • Save andrewpthorp/4274062 to your computer and use it in GitHub Desktop.
Save andrewpthorp/4274062 to your computer and use it in GitHub Desktop.
Give me your opinions:
# Explicit contexts
describe ".some_method?" do
context "when <condition is met>" do
it "should be true" do
@foo.condition = "met"
@foo.should be_some_method
end
end
context "when <condition is not met>" do
it "should be false" do
@foo.conditions = "not met"
@foo.should_not be_some_method
end
end
end
# Implicit contexts
describe ".some_method?" do
it "should be true when <condition is met>" do
@foo.conditions = "met"
@foo.should be_some_method
end
it "shoulbd be false when <condition is not met>" do
@foo.conditions = "not met"
@foo.should_not be_some_method
end
end
@andrewpthorp
Copy link
Author

I tend to type out the contexts explicitly, but it seems heavy handed for these single test contexts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment