Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSpec 3 Shared Examples Support #63

Open
tpendragon opened this issue Dec 24, 2014 · 5 comments
Open

RSpec 3 Shared Examples Support #63

tpendragon opened this issue Dec 24, 2014 · 5 comments

Comments

@tpendragon
Copy link
Contributor

Not sure if this is specific to RSpec 3 - I'm trying to use Bogus and have two classes that have similar contracts (as one's a subclass of another). I'd normally put these in a shared example group and run those contract tests on both - but when I do that, Bogus doesn't pick up that the methods ran. Thoughts?

@tpendragon
Copy link
Contributor Author

So this is because the described_class is overriden by Bogus and so doesn't match. I had to do this.

RSpec.shared_examples "a term" do
  let(:id) { "Creator" }
  let(:resource) { resource_class.new(id) }
end

RSpec.describe Term do
  verify_contract(:term)
  it_behaves_like "a term" do
    let(:resource_class) { Term }
  end
end

@psyho
Copy link
Owner

psyho commented Jan 2, 2015

Thanks for reporting the issue. I just released version 0.1.6 which should have a fix for overwriting #described_class in RSpec 3.* (it was a problem I encountered in our integration tests). I'd really appreciate it, if you tried running your tests with updated bogus version and see if it fixed your issue as well.

@tpendragon
Copy link
Contributor Author

@psyho No go. The described_class didn't get overwritten.

let(:resource_class) { described_class }

didn't even work.

@psyho
Copy link
Owner

psyho commented Jan 5, 2015

That's a shame, I'll look into this in more detail then. Thanks for checking.

@psyho
Copy link
Owner

psyho commented Jan 9, 2015

I've spent some time debugging this issue today, and it looks like there's no reliable way to overwrite described_class in RSpec 3. I think I'm going to introduce a new helper method, like bogus_described_class and stop overwriting described_class altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants