Skip to content

Instantly share code, notes, and snippets.

@imtayadeway
Last active February 1, 2017 22:58
Show Gist options
  • Save imtayadeway/b87b3dd01bf3514d058113707d9f95f2 to your computer and use it in GitHub Desktop.
Save imtayadeway/b87b3dd01bf3514d058113707d9f95f2 to your computer and use it in GitHub Desktop.
Mystery Job
class Foo
class Bar
# uninitialized constant:
Baz
def self.bar
puts "hello from bar!"
end
end
end
class Foo
def self.foo
Bar.bar
end
end
RSpec.describe Foo do
it "does something" do
Foo.foo
end
it "does something else" do
Foo.foo
end
end
Randomized with seed 27098
FF
Failures:
1) Foo does something else
Failure/Error: Baz
NameError:
uninitialized constant Foo::Bar::Baz
# ./lib/foo/bar.rb:3:in `<class:Bar>'
# ./lib/foo/bar.rb:2:in `<class:Foo>'
# ./lib/foo/bar.rb:1:in `<top (required)>'
# ./lib/foo.rb:3:in `foo'
# ./spec/foo_spec.rb:7:in `block (2 levels) in <top (required)>'
2) Foo does something
Failure/Error: Bar.bar
NoMethodError:
undefined method `bar' for Foo::Bar:Class
# ./lib/foo.rb:3:in `foo'
# ./spec/foo_spec.rb:3:in `block (2 levels) in <top (required)>'
Finished in 0.63286 seconds (files took 4.93 seconds to load)
2 examples, 2 failures
Failed examples:
rspec ./spec/foo_spec.rb:6 # Foo does something else
rspec ./spec/foo_spec.rb:2 # Foo does something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment