Sha256: 13396a9132552a3e115f075068db56484ac01643bde40c73690c88ea8587b0ba
Contents?: true
Size: 625 Bytes
Versions: 2
Compression:
Stored size: 625 Bytes
Contents
module Examples def context_from_example(file, &block) context "example #{file}" do silently {eval File.read("examples/#{file}.rb")} variables = instance_variables.reject {|var| var.to_s =~ /metadata$/} values = variables.inject({}) do |buffer, name| method_name = name.to_s.gsub(/@/, "") let(method_name) {instance_variable_get(name)} buffer.merge method_name => instance_variable_get(name) end before :all do values.each {|name, value| instance_variable_set "@#{name}", value} end instance_eval &block if block end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
transcriber-0.0.3 | spec/support/examples.rb |
transcriber-0.0.2 | spec/support/examples.rb |