Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Created October 7, 2008 00:21
Show Gist options
  • Save dchelimsky/15192 to your computer and use it in GitHub Desktop.
Save dchelimsky/15192 to your computer and use it in GitHub Desktop.
module OnOptionExample
GIVENS = {}
def self.given name, &block
GIVENS[name] = block
end
given "@value = 10" do
@value = 10
end
given "@value = 11" do
@value = 11
end
Spec::Example::ExampleGroupMethods::on_option(:given) do |option, example|
example.instance_eval(&GIVENS[option])
end
describe "on option", :given => "@value = 10" do
it "should run the group option" do
@value.should == 10
end
it "should prefer the example option", :given => "@value = 11" do
@value.should == 11
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment