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

Fix bug with DSLMixin #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lfdebrux
Copy link

@lfdebrux lfdebrux commented Oct 4, 2019

Creating a class that inherits from DSLMixin should allow it to use DSL methods, however instead I get a KeyError

Steps to reproduce bug

  1. Create a class that inherits from DSLMixin
  2. Instantiate the class
  3. Call a DSL method
>>> from capybara.dsl import DSLMixin

>>> class MyClass(DSLMixin):
...     pass
>>> mypage = MyClass()
>>> mypage.assert_selector('link', 'Help')

Expected behaviour

The DSL method returns as if calling capybara.dsl.<method>

>>> mypage.assert_selector('link', 'Help')
True

Actual behaviour

A KeyError is raised

>>> mypage.assert_selector('link', 'Help')
*** KeyError: <MyClass object at 0x7f16a350d780>

Suggested fix

DSLMixin should result in methods being attached to the class, rather than functions, so that the DSL methods can be used from instances of classes that inherit from DSLMixin.

I've attached a fix below that includes tests showing the behaviour I would expect.

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

Successfully merging this pull request may close these issues.

1 participant