Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Handle strings as well as symbols for method stubs. #23

Merged
merged 1 commit into from

2 participants

@pat

Yes, I usually write my method stubs using symbols, but wandered from that path with some simple metaprogramming. RSpec's fine with strings, but rspec-fire wasn't when it came to running my full test suite - it insisted the methods did not exist on the real classes.

Perhaps the implementation's not quite right, or the tests don't need to happen everywhere - I leave that to your tweaking, given you know your code better than I.

@pat pat Handle strings as well as symbols for method stubs.
Yes, I usually write my method stubs using symbols, but wandered from that path with some simple metaprogramming. RSpec's fine with strings, but rspec-fire wasn't when it came to running my full test suite - it insisted the methods did not exist on the real classes.
0907ec7
@xaviershay
Owner

That's great, thanks Pat.

@xaviershay xaviershay merged commit e02f325 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 14, 2012
  1. @pat

    Handle strings as well as symbols for method stubs.

    pat authored
    Yes, I usually write my method stubs using symbols, but wandered from that path with some simple metaprogramming. RSpec's fine with strings, but rspec-fire wasn't when it came to running my full test suite - it insisted the methods did not exist on the real classes.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +1 −1  lib/rspec/fire.rb
  2. +3 −0  spec/fire_double_spec.rb
View
2  lib/rspec/fire.rb
@@ -177,7 +177,7 @@ def implemented_methods(doubled_class, checked_methods)
end
def unimplemented_methods(doubled_class, expected_methods, checked_methods)
- expected_methods -
+ expected_methods.map(&:to_sym) -
implemented_methods(doubled_class, checked_methods)
end
View
3  spec/fire_double_spec.rb
@@ -58,11 +58,14 @@ def clear_config
describe 'doubled class is not loaded' do
let(:doubled_object) { fire_double("UnloadedObject") }
should_allow(:undefined_method)
+ should_allow('undefined_method')
end
describe 'doubled class is loaded' do
should_allow(:defined_method)
+ should_allow('defined_method')
should_not_allow(:undefined_method)
+ should_not_allow('undefined_method')
end
end
Something went wrong with that request. Please try again.