Skip to content

Instantly share code, notes, and snippets.

@PharaohKJ
Last active March 12, 2019 09:49

Revisions

  1. PharaohKJ revised this gist Mar 12, 2019. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions capybara-with-minitest-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -30,4 +30,18 @@ within でスコープを区切る
    pp [i, e.text]
    end
    end
    ```

    ネストもできる (https://github.com/gongo/maizebox/blob/master/examples/runner.rb)

    ```
    within(:css, 'aside') do
    within(:css, 'li.first-child') do
    page.attention_here
    end
    within(:css, 'li.third-child') do
    page.attention_to(find(:css, 'img'))
    end
    end
    ```
  2. PharaohKJ revised this gist Mar 12, 2019. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions capybara-with-minitest-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,17 @@ page.all('div', text: /\Aテキスト\z/)
    assert_selector('div', text: /\Aテキスト\z/, count: 1)
    page.all('tr.order-record').count
    assert_selector('.order-record', count: 2)
    ```

    ## 子ノードをセレクトしたい

    within でスコープを区切る

    ```
    element = page.all('tr.order-record')[0]
    within(element) do
    page.all('td').each_with_index do |e, i|
    pp [i, e.text]
    end
    end
    ```
  3. PharaohKJ revised this gist Mar 12, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions capybara-with-minitest-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,7 @@ https://github.com/mugi-uno/nezumi
    ```
    fill_in 'staff_password', with: 'password'
    click_on 'LOGIN'
    find_button('発注する').click # findでみつかるまでwaitが入る模様 -> see https://www.rubydoc.info/github/jnicklas/capybara/Capybara%2FNode%2FFinders:find_button
    ```

    # セレクタ
  4. PharaohKJ revised this gist Mar 12, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions capybara-with-minitest-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,6 @@ https://github.com/mugi-uno/nezumi
    ```
    page.all('div', text: /\Aテキスト\z/)
    assert_selector('div', text: /\Aテキスト\z/, count: 1)
    page.all('tr.order-record').count
    assert_selector('.order-record', count: 2)
    ```
  5. PharaohKJ revised this gist Mar 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion capybara-with-minitest-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,4 @@ https://github.com/mugi-uno/nezumi
    ```
    page.all('div', text: /\Aテキスト\z/)
    assert_selector('div', text: /\Aテキスト\z/, count: 1)
    ``
    ```
  6. PharaohKJ renamed this gist Mar 12, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. PharaohKJ created this gist Mar 12, 2019.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # ツール

    https://github.com/mugi-uno/nezumi

    # 入力

    ```
    fill_in 'staff_password', with: 'password'
    click_on 'LOGIN'
    ```

    # セレクタ

    ```
    page.all('div', text: /\Aテキスト\z/)
    assert_selector('div', text: /\Aテキスト\z/, count: 1)
    ``