magic_test 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/views/magic_test/_context_menu.html +4 -4
- data/lib/magic_test/support.rb +31 -20
- data/lib/magic_test/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 971c5c9bfcc383b0a3fd3a57e18350e9882fd1f6b1727981df23c1fc54c232b7
|
4
|
+
data.tar.gz: eb63dddfd320adfde98accbb7b4b0f431ca2ecfba9e3db06def573c50c67dc2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ceea8c811fa91e0ad393495631c73e327e185bd92f28bb5ec3a0e79fa258564bd1a21577de6c2007fd73ffcff05ca8082c6570028f07e83a5ccf81615eac43b
|
7
|
+
data.tar.gz: b8d706a0287f1a9d2436ae7dbfca791d61d1de564f6d9d95a5ec7109dfb4bf7548983892474e7d27bbf167afb1cad2156f7734ed759ba52e9acd5267c718e0b6
|
data/Gemfile.lock
CHANGED
@@ -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.
|
28
|
-
var action = "assert page.has_content?
|
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 = "";
|
data/lib/magic_test/support.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
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
|
data/lib/magic_test/version.rb
CHANGED