Closed wyattades closed 4 months ago
* add tracing on all Rspec commands (hard) * e.g. `expect(page).to have_content("foo")` * This was pretty easy on MiniTest because we only needed to look at methods starting with `assert_`, and all tests were direct methods of a `ActiveSupport::TestClass` class
If I understood your code correctly, that part should be as easy as
@step_at_methods =
Capybara::Session::DSL_METHODS.to_set +
[:expect] -
%i[ html body current_url etc ]
(there is an older should_... syntax, but that has been deprecated and hidden behind a feature flag years ago, so I don't think you need to support it)
The only problem I see is something like
def accept_cookies
expect(page).to have_css('.cookie-banner')
click_link_or_button('Accept')
end
it 'tracks the user after they accept cookies' do
# visit the page
accept_cookies
# expect tracking to happen
end
I'm not sure whether this would show up as an expectation, especially if the method is defined in a helper module in another file. Does Minitest have a similar problem?
The only problem I see is something like
def accept_cookies expect(page).to have_css('.cookie-banner') click_link_or_button('Accept') end it 'tracks the user after they accept cookies' do # visit the page accept_cookies # expect tracking to happen end
I'm not sure whether this would show up as an expectation, especially if the method is defined in a helper module in another file. Does Minitest have a similar problem?
you're right, my naive static analyzer doesn't parse custom methods like that as "steps". It looks at the AST of the test code, but doesn't "follow" method definitions. Maybe I could try this out in the future.
There is currently a manual workaround: Cyperful.add_step_at_methods(:accept_cookies)
.
Released the initial support for RSpec under v0.2.0. Open to feedback and bug reports, please let me know by opening new issues!
Context: Right now we only support MiniTest, because that's what I use for my projects :)
Tasks:
cyperful/minitest
&cyperful/rspec
describe
,it
,context
, etc.expect(page).to have_content("foo")
assert_
, and all tests were direct methods of aActiveSupport::TestClass
classUPDATE: I am actively working on this, a PoC should be ready soonish.