magic_test 0.0.5 → 0.0.6

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: 75adfb4e31a3cddd41feccf5105643d887e6744e050a3cecd2e3944f48be7ddc
4
- data.tar.gz: 5fa8c00d0ba7a14cb1b95033f297af1988abe0c698e3b1e7b32882b0d9c23ef0
3
+ metadata.gz: 971c5c9bfcc383b0a3fd3a57e18350e9882fd1f6b1727981df23c1fc54c232b7
4
+ data.tar.gz: eb63dddfd320adfde98accbb7b4b0f431ca2ecfba9e3db06def573c50c67dc2c
5
5
  SHA512:
6
- metadata.gz: 2d5cc5f25c5198909f2a2fa3a7564871f79b750589a4a61b75d59f3b1e8e32a26ba515f852b6b22f4f6f67cd86a13bb1998eb2228aaca22b7b20fc4dda0a0cf4
7
- data.tar.gz: aa3b684389d75750883ec106f9f67293a00d31eba760c1ea5a6020906c3b4fdaf22cdcae921bf768f966210601fc15eb5a2935c2a4905dc4c1b17c908d23a1a2
6
+ metadata.gz: 1ceea8c811fa91e0ad393495631c73e327e185bd92f28bb5ec3a0e79fa258564bd1a21577de6c2007fd73ffcff05ca8082c6570028f07e83a5ccf81615eac43b
7
+ data.tar.gz: b8d706a0287f1a9d2436ae7dbfca791d61d1de564f6d9d95a5ec7109dfb4bf7548983892474e7d27bbf167afb1cad2156f7734ed759ba52e9acd5267c718e0b6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magic_test (0.0.5)
4
+ magic_test (0.0.6)
5
5
  capybara (~> 3.0)
6
6
  pry
7
7
  pry-stack_explorer
@@ -6,7 +6,7 @@
6
6
  document.addEventListener('DOMContentLoaded', fn);
7
7
  }
8
8
  }
9
-
9
+
10
10
  ready(function() {
11
11
  enableKeyboardShortcuts();
12
12
  });
@@ -23,9 +23,9 @@
23
23
  document.addEventListener('keydown', keydown, false);
24
24
 
25
25
  function generateAssertion() {
26
- var text = selectedText();
27
- if (text.trim().length > 0) {
28
- var action = "assert page.has_content?('" + text.replace("'", "\\\'") + "')";
26
+ var text = selectedText().trim();
27
+ if (text.length > 0) {
28
+ var action = "assert page.has_content? '" + text.replace("'", "\\\'") + "'";
29
29
  var testingOutput = JSON.parse(sessionStorage.getItem("testingOutput"));
30
30
  var target = "";
31
31
  var options = "";
@@ -4,8 +4,7 @@ module MagicTest
4
4
  selected_text = page.evaluate_script("window.selectedText()")
5
5
  return if selected_text.blank?
6
6
 
7
- # TODO this feels like it's going to end up burning people who have other support files in `test` or `spec` that don't include `helper` in the name.
8
- filepath, line = caller.select { |s| s.include?("/test/") || s.include?("/spec/") }.reject { |s| s.include?("helper") }.first.split(":")
7
+ filepath, line = get_last_caller(caller)
9
8
 
10
9
  contents = File.open(filepath).read.lines
11
10
  chunks = contents.each_slice(line.to_i - 1 + @test_lines_written).to_a
@@ -22,24 +21,9 @@ module MagicTest
22
21
  page.evaluate_script("trackKeystrokes()")
23
22
  end
24
23
 
25
- def get_last
26
- history_lines = Readline::HISTORY.to_a.last(20)
27
- i = 2
28
- last = history_lines.last(2).first
29
- last_block = [last]
30
- if last == "end" || last.first(4) == "end "
31
- i += 1
32
- last_block.unshift(history_lines.last(i).first)
33
- until !last_block.first.match(/^(\s+)/) & [0]
34
- i += 1
35
- last_block.unshift(history_lines.last(i).first)
36
- end
37
- end
38
- last_block
39
- end
40
-
41
24
  def flush
42
- filepath, line = caller.select { |s| s.include?("/test/") }.reject { |s| s.include?("helper") }.first.split(":")
25
+ filepath, line = get_last_caller(caller)
26
+
43
27
  contents = File.open(filepath).read.lines
44
28
  chunks = contents.each_slice(line.to_i - 1 + @test_lines_written).to_a
45
29
  indentation = chunks[1].first.match(/^(\s*)/)[0]
@@ -67,7 +51,8 @@ module MagicTest
67
51
  end
68
52
 
69
53
  def ok
70
- filepath, line = caller.select { |s| s.include?("/test/") }.reject { |s| s.include?("helper") }.first.split(":")
54
+ filepath, line = get_last_caller(caller)
55
+
71
56
  puts "(writing that to `#{filepath}`.)"
72
57
  contents = File.open(filepath).read.lines
73
58
  chunks = contents.each_slice(line.to_i - 1 + @test_lines_written).to_a
@@ -100,5 +85,31 @@ module MagicTest
100
85
  retry
101
86
  end
102
87
  end
88
+
89
+ private
90
+
91
+ def get_last
92
+ history_lines = Readline::HISTORY.to_a.last(20)
93
+ i = 2
94
+ last = history_lines.last(2).first
95
+ last_block = [last]
96
+ if last == "end" || last.first(4) == "end "
97
+ i += 1
98
+ last_block.unshift(history_lines.last(i).first)
99
+ until !last_block.first.match(/^(\s+)/) & [0]
100
+ i += 1
101
+ last_block.unshift(history_lines.last(i).first)
102
+ end
103
+ end
104
+
105
+ last_block
106
+ end
107
+
108
+ # TODO this feels like it's going to end up burning people who have other support files in `test` or `spec` that don't include `helper` in the name.
109
+ def get_last_caller(caller)
110
+ caller.select { |s| s.include?("/test/") || s.include?("/spec/") }
111
+ .reject { |s| s.include?("helper") }
112
+ .first.split(":").first(2)
113
+ end
103
114
  end
104
115
  end
@@ -1,3 +1,3 @@
1
1
  module MagicTest
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver