dekiru 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6da61a0077b7b3bfc1d8d7218534e338decd1d8dfa148f88a3ea5ffd7d1bc1
4
- data.tar.gz: 204207fef71355046599563e241eef01c613fde164ec4ebd44c0ab4c4e05eb94
3
+ metadata.gz: 8c0bb6ed019dee9b851e2f68be25d4bb213a96c7d482fe9a1025ff89534809f2
4
+ data.tar.gz: 71ab7770a0b3d111f1fb62668bfff4a3bf3e23a548c1217a1d15da40edc74169
5
5
  SHA512:
6
- metadata.gz: 69d2b73da661888ee0a4da75d6c4e7dd97fcc9f9fba64ce7f5104ac79caa9191cdc0c9d714ae3ef8d07ce74f52638c273445f04cc7d6fa4972188ea8e9f816f2
7
- data.tar.gz: 96ee35a0094409e45a883227a8249ab8b5bea7fd614831c84ca6bac0bcbaca21c1006f7087bb7e083e97c2ac251325d3f56c5ebc840f667d29df12af4e2e5833
6
+ metadata.gz: 8930b878569914b971c14d5521091060ecf2079deec914a96e5d9ef9461e067df7b44d2d877988dbb40df15e94114dc05dda361c81985062427d4d7366d688fd
7
+ data.tar.gz: e30b62a917913f8abfaaa2aadf9b4d56c584d24e107401f4cd855e089aa0d440a5eca0bacdba7d812d3feb8a911c2b9cae8679607191af938deb1d53bc6a15f2
data/README.md CHANGED
@@ -48,6 +48,30 @@ end
48
48
  click_on 'Button in modal'
49
49
  ```
50
50
 
51
+ ## Capybara Matchers
52
+
53
+ 以下の設定をすると Capybara 用のマッチャーが使えるようになる。
54
+
55
+ ```ruby
56
+ require 'dekiru/capybara/matchers'
57
+ RSpec.configure do |config|
58
+ config.include Dekiru::Capybara::Matchers, type: :feature
59
+ end
60
+ ```
61
+
62
+ ### examples
63
+
64
+ ```ruby
65
+ # javascriptエラーがあったらテスト失敗するように
66
+ RSpec.configure do |config|
67
+ config.after(:each, type: :feature) do |example|
68
+ if example.metadata[:js] == true
69
+ expect(page).to have_no_js_errors
70
+ end
71
+ end
72
+ end
73
+ ```
74
+
51
75
  ## Rake Task
52
76
 
53
77
  以下の設定をすると Rake タスクの実行前後にログ出力されるようになる。(Ruby2.4 以降が必要)
@@ -87,8 +111,8 @@ Rake::Task['db:migrate'].enhance(['db:migrate:check_conflict']) if Rails.env.dev
87
111
 
88
112
  ## Contributing
89
113
 
90
- 1. Fork it
91
- 2. Create your feature branch (`git checkout -b my-new-feature`)
92
- 3. Commit your changes (`git commit -am 'Added some feature'`)
93
- 4. Push to the branch (`git push origin my-new-feature`)
94
- 5. Create new Pull Request
114
+ 1. Fork it
115
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
116
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
117
+ 4. Push to the branch (`git push origin my-new-feature`)
118
+ 5. Create new Pull Request
@@ -0,0 +1,30 @@
1
+ module Dekiru
2
+ module Capybara
3
+ module Matchers
4
+ class JsNoErrorMatcher
5
+ def matches?(page)
6
+ errors = page.driver.browser.manage.logs.get(:browser)
7
+ errors.find_all { |error| error.level == 'WARNING' }.each do |error|
8
+ STDERR.puts 'WARN: javascript warning'
9
+ STDERR.puts error.message
10
+ end
11
+
12
+ @severe_errors = errors.find_all { |error| error.level == 'SEVERE' }
13
+ @severe_errors.empty?
14
+ end
15
+
16
+ def description
17
+ 'have no js errors'
18
+ end
19
+
20
+ def failure_message
21
+ @severe_errors.map(&:message).join("\n")
22
+ end
23
+ end
24
+
25
+ def have_no_js_errors
26
+ JsNoErrorMatcher.new
27
+ end
28
+ end
29
+ end
30
+ end
@@ -3,11 +3,10 @@ module TaskWithLogger
3
3
  private
4
4
 
5
5
  def task(*args, &block)
6
- scope_path = Rake.application.current_scope.path
7
- new_block = proc do
8
- __echo__ "[START] #{scope_path}: #{args.inspect} (#{Time.current})"
9
- yield
10
- __echo__ "[END] #{scope_path}: #{args.inspect} (#{Time.current})"
6
+ new_block = proc do |_task, _args|
7
+ __echo__ "[START] #{_task.name} #{_args.to_h} (#{Time.current})"
8
+ yield(_task, _args)
9
+ __echo__ "[END] #{_task.name} #{_args.to_h} (#{Time.current})"
11
10
  end
12
11
  super(*args, &new_block)
13
12
  end
@@ -1,3 +1,3 @@
1
1
  module Dekiru
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dekiru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akihiro Matsumura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-23 00:00:00.000000000 Z
11
+ date: 2018-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http_accept_language
@@ -111,6 +111,7 @@ files:
111
111
  - dekiru.gemspec
112
112
  - lib/dekiru.rb
113
113
  - lib/dekiru/capybara/helpers.rb
114
+ - lib/dekiru/capybara/matchers.rb
114
115
  - lib/dekiru/controller_additions.rb
115
116
  - lib/dekiru/helper.rb
116
117
  - lib/dekiru/railtie.rb