Skip to content

Instantly share code, notes, and snippets.

@chrislerum
Created April 21, 2010 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislerum/373483 to your computer and use it in GitHub Desktop.
Save chrislerum/373483 to your computer and use it in GitHub Desktop.
sp spec/my_stuff.rb
use #assign instead of #populate for future versions
| it "really changes something" do | ./spec/my_stuff.rb:9
| \ calling Spec::Example::ExampleGroupMethods::it
Spec::Example::ExampleGroupMethods::it (/Users/chris/.rvm/gems/ruby-1.8.7-p72@cm/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:73) (line):
| | (description = "really changes something"; options = {}; backtrace =...
def example(description=nil, options={}, backtrace=nil, &implementation)
-> example_proxy = ExampleProxy.new(description, options, backtrace || caller(0)[1])
example_proxies << example_proxy
example_implementations[example_proxy] = implementation || pending_implementation
example_proxy
end
def pending_implementation
lambda { raise(Spec::Example::NotYetImplementedError) }
end
alias_method :it, :example
alias_method :specify, :example
# Use this to temporarily disable an example.
def xexample(description=nil, opts={}, &block)
Kernel.warn("Example disabled: #{description}")
end
alias_method :xit, :xexample
alias_method :xspecify, :xexample
def run(run_options)
examples = examples_to_run(run_options)
notify(run_options.reporter) unless examples.empty?
return true if examples.empty?
return dry_run(examples, run_options) if run_options.dry_run?
define_methods_from_predicate_matchers
success, before_all_instance_variables = run_before_all(run_options)
| | \ calling Spec::Example::ExampleProxy::initialize
Spec::Example::ExampleProxy::initialize (/Users/chris/.rvm/gems/ruby-1.8.7-p72@cm/gems/rspec-1.3.0/lib/spec/example/example_proxy.rb:8) (line):
| | | (description = "really changes something"; options = {}; location = ...
def initialize(description=nil, options={}, location=nil) # :nodoc:
-> @description, @options, @location = description, options, location
end
# Optional hash passed to the example declaration
attr_reader :options
# This is the docstring passed to the <tt>it()</tt> method or any
# of its aliases
attr_reader :description
# The file and line number at which the represented example
# was declared. This is extracted from <tt>caller</tt>, and is therefore
# formatted as an individual line in a backtrace.
attr_reader :location
# Deprecated - use location()
def backtrace
Spec.deprecate("ExampleProxy#backtrace","ExampleProxy#location")
location
end
# Convenience method for example group - updates the value of
# <tt>description</tt> and returns self.
def update(description) # :nodoc:
@description = description
self
end
def ==(other) # :nodoc:
(other.description == description) & (other.location == location)
| | / returning from Spec::Example::ExampleProxy::initialize
Spec::Example::ExampleGroupMethods::it (/Users/chris/.rvm/gems/ruby-1.8.7-p72@cm/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:74) (line):
| | (description = "really changes something"; options = {}; backtrace =...
def example(description=nil, options={}, backtrace=nil, &implementation)
example_proxy = ExampleProxy.new(description, options, backtrace || caller(0)[1])
-> example_proxies << example_proxy
example_implementations[example_proxy] = implementation || pending_implementation
example_proxy
end
def pending_implementation
lambda { raise(Spec::Example::NotYetImplementedError) }
end
alias_method :it, :example
alias_method :specify, :example
# Use this to temporarily disable an example.
def xexample(description=nil, opts={}, &block)
Kernel.warn("Example disabled: #{description}")
end
alias_method :xit, :xexample
alias_method :xspecify, :xexample
def run(run_options)
examples = examples_to_run(run_options)
notify(run_options.reporter) unless examples.empty?
return true if examples.empty?
return dry_run(examples, run_options) if run_options.dry_run?
define_methods_from_predicate_matchers
success, before_all_instance_variables = run_before_all(run_options)
| | \ calling Spec::Example::ExampleGroupMethods::example_proxies
Spec::Example::ExampleGroupMethods::example_proxies (/Users/chris/.rvm/gems/ruby-1.8.7-p72@cm/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:141) (line):
def example_proxies # :nodoc:
-> @example_proxies ||= []
end
def example_implementations # :nodoc:
@example_implementations ||= {}
end
def examples(run_options=nil) #:nodoc:
(run_options && run_options.reverse) ? example_proxies.reverse : example_proxies
end
def number_of_examples #:nodoc:
example_proxies.length
end
def example_group_hierarchy
@example_group_hierarchy ||= ExampleGroupHierarchy.new(self)
end
def nested_descriptions
example_group_hierarchy.nested_descriptions
end
def include_constants_in(mod)
include mod if (Spec::Ruby.version.to_f >= 1.9) & (Module === mod) & !(Class === mod)
end
def let(name, &block)
define_method name do
@assignments ||= {}
| | / returning from Spec::Example::ExampleGroupMethods::example_proxies
Spec::Example::ExampleGroupMethods::it (/Users/chris/.rvm/gems/ruby-1.8.7-p72@cm/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:75) (line):
| | (description = "really changes something"; options = {}; backtrace =...
def example(description=nil, options={}, backtrace=nil, &implementation)
example_proxy = ExampleProxy.new(description, options, backtrace || caller(0)[1])
example_proxies << example_proxy
-> example_implementations[example_proxy] = implementation || pending_implementation
example_proxy
end
def pending_implementation
lambda { raise(Spec::Example::NotYetImplementedError) }
end
alias_method :it, :example
alias_method :specify, :example
# Use this to temporarily disable an example.
def xexample(description=nil, opts={}, &block)
Kernel.warn("Example disabled: #{description}")
end
alias_method :xit, :xexample
alias_method :xspecify, :xexample
def run(run_options)
examples = examples_to_run(run_options)
notify(run_options.reporter) unless examples.empty?
return true if examples.empty?
return dry_run(examples, run_options) if run_options.dry_run?
define_methods_from_predicate_matchers
success, before_all_instance_variables = run_before_all(run_options)
| | \ calling Spec::Example::ExampleGroupMethods::example_implementations
Spec::Example::ExampleGroupMethods::example_implementations (/Users/chris/.rvm/gems/ruby-1.8.7-p72@cm/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:145) (line):
def example_implementations # :nodoc:
-> @example_implementations ||= {}
end
def examples(run_options=nil) #:nodoc:
(run_options && run_options.reverse) ? example_proxies.reverse : example_proxies
end
def number_of_examples #:nodoc:
example_proxies.length
end
def example_group_hierarchy
@example_group_hierarchy ||= ExampleGroupHierarchy.new(self)
end
def nested_descriptions
example_group_hierarchy.nested_descriptions
end
def include_constants_in(mod)
include mod if (Spec::Ruby.version.to_f >= 1.9) & (Module === mod) & !(Class === mod)
end
def let(name, &block)
define_method name do
@assignments ||= {}
@assignments[name] ||= instance_eval(&block)
end
end
| | / returning from Spec::Example::ExampleGroupMethods::example_implementations
Spec::Example::ExampleGroupMethods::it (/Users/chris/.rvm/gems/ruby-1.8.7-p72@cm/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:76) (line):
| | (description = "really changes something"; options = {}; backtrace =...
def example(description=nil, options={}, backtrace=nil, &implementation)
example_proxy = ExampleProxy.new(description, options, backtrace || caller(0)[1])
example_proxies << example_proxy
example_implementations[example_proxy] = implementation || pending_implementation
-> example_proxy
end
def pending_implementation
lambda { raise(Spec::Example::NotYetImplementedError) }
end
alias_method :it, :example
alias_method :specify, :example
# Use this to temporarily disable an example.
def xexample(description=nil, opts={}, &block)
Kernel.warn("Example disabled: #{description}")
end
alias_method :xit, :xexample
alias_method :xspecify, :xexample
def run(run_options)
examples = examples_to_run(run_options)
notify(run_options.reporter) unless examples.empty?
return true if examples.empty?
return dry_run(examples, run_options) if run_options.dry_run?
define_methods_from_predicate_matchers
success, before_all_instance_variables = run_before_all(run_options)
| / returning from Spec::Example::ExampleGroupMethods::it
String
- really changes something (FAILED - 1)
1)
'String really changes something' FAILED
result should have initially been "woo hoo\n", but was "woo hoo"
./spec/my_stuff.rb:10:
Finished in 0.009541 seconds
1 example, 1 failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment