fracture 0.11.3 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/fracture/fracture.rb +7 -7
- data/lib/fracture/matchers/matcher.rb +1 -1
- data/lib/fracture/version.rb +1 -1
- data/spec/fracture_spec.rb +2 -2
- data/spec/matcher_spec.rb +15 -5
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/lib/fracture/fracture.rb
CHANGED
@@ -69,8 +69,8 @@ class Fracture
|
|
69
69
|
all.keys - list_to_s(Array(fractures).flatten)
|
70
70
|
end
|
71
71
|
|
72
|
-
def do_check
|
73
|
-
page_parsed = Nokogiri::HTML.parse(page)
|
72
|
+
def do_check page_parsed, label
|
73
|
+
# page_parsed = Nokogiri::HTML.parse(page)
|
74
74
|
|
75
75
|
if text?
|
76
76
|
page_parsed.text.include?(label)
|
@@ -93,7 +93,7 @@ class Fracture
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def self.test_fractures(page, is_not, fracture_labels, reverse_fracture_labels=[])
|
96
|
-
|
96
|
+
page_parsed = Nokogiri::HTML.parse( self.get_body(page) )
|
97
97
|
failures = {}
|
98
98
|
failures[:should] = []
|
99
99
|
failures[:should_not] = []
|
@@ -101,11 +101,11 @@ class Fracture
|
|
101
101
|
fracture = Fracture.find(fracture_label)
|
102
102
|
fracture.items.each do |label|
|
103
103
|
if is_not
|
104
|
-
if fracture.do_check(
|
104
|
+
if fracture.do_check(page_parsed, label)
|
105
105
|
failures[:should_not] << {fracture_label: fracture_label, label: label}
|
106
106
|
end
|
107
107
|
else
|
108
|
-
unless fracture.do_check(
|
108
|
+
unless fracture.do_check(page_parsed, label)
|
109
109
|
failures[:should] << {fracture_label: fracture_label, label: label}
|
110
110
|
end
|
111
111
|
end
|
@@ -115,11 +115,11 @@ class Fracture
|
|
115
115
|
fracture = Fracture.find(fracture_label)
|
116
116
|
fracture.items.each do |label|
|
117
117
|
unless is_not
|
118
|
-
if fracture.do_check(
|
118
|
+
if fracture.do_check(page_parsed, label)
|
119
119
|
failures[:should_not] << {fracture_label: fracture_label, label: label}
|
120
120
|
end
|
121
121
|
else
|
122
|
-
unless fracture.do_check(
|
122
|
+
unless fracture.do_check(page_parsed, label)
|
123
123
|
failures[:should] << {fracture_label: fracture_label, label: label}
|
124
124
|
end
|
125
125
|
end
|
@@ -87,7 +87,7 @@ end
|
|
87
87
|
RSpec::Matchers.define :have_a_form do
|
88
88
|
match do |page|
|
89
89
|
page = Nokogiri::HTML.parse(Fracture.get_body(page))
|
90
|
-
@edit_found = page.at("input[type='hidden'][name='_method'][value='put']")
|
90
|
+
@edit_found = page.at("input[type='hidden'][name='_method'][value='put']") || page.at("input[type='hidden'][name='_method'][value='patch']")
|
91
91
|
@has_form = page.at("form[method='post']")
|
92
92
|
#TODO refactor this
|
93
93
|
#@found_action = page.at("form[action]").try(:attributes).try(:fetch, "action", nil).try(:value)
|
data/lib/fracture/version.rb
CHANGED
data/spec/fracture_spec.rb
CHANGED
@@ -91,8 +91,8 @@ describe Fracture do
|
|
91
91
|
describe "test_fracture"
|
92
92
|
|
93
93
|
describe ".do_check" do
|
94
|
-
it("should find it") { @first.do_check("z a b", "a").should be_true }
|
95
|
-
it("should not find it") { @first.do_check("z b", "a").should be_false }
|
94
|
+
it("should find it") { @first.do_check(Nokogiri::HTML.parse("z a b"), "a").should be_true }
|
95
|
+
it("should not find it") { @first.do_check(Nokogiri::HTML.parse("z b"), "a").should be_false }
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
data/spec/matcher_spec.rb
CHANGED
@@ -66,12 +66,22 @@ BODY
|
|
66
66
|
it("should not be an edit") { expect { @page.should have_a_form.that_is_edit }.to raise_error(RSpec::Expectations::ExpectationNotMetError, /Form is not an edit/) }
|
67
67
|
end
|
68
68
|
context "that_is_edit" do
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
context "method is put" do
|
70
|
+
before { @page += "<input type='hidden' name='_method' value='put'>" }
|
71
|
+
it "should not be a new form" do
|
72
|
+
expect { @page.should have_a_form.that_is_new }.to raise_error(RSpec::Expectations::ExpectationNotMetError, /Form is an edit/)
|
73
|
+
end
|
74
|
+
it("should be an edit form") { @page.should have_a_form.that_is_edit }
|
75
|
+
it("should have a form") { @page.should have_a_form }
|
76
|
+
end
|
77
|
+
context "method is patch" do
|
78
|
+
before { @page += %q[<input name="_method" type="hidden" value="patch" />] }
|
79
|
+
it "should not be a new form" do
|
80
|
+
expect { @page.should have_a_form.that_is_new }.to raise_error(RSpec::Expectations::ExpectationNotMetError, /Form is an edit/)
|
81
|
+
end
|
82
|
+
it("should be an edit form") { @page.should have_a_form.that_is_edit }
|
83
|
+
it("should have a form") { @page.should have_a_form }
|
72
84
|
end
|
73
|
-
it("should be an edit form") { @page.should have_a_form.that_is_edit }
|
74
|
-
it("should have a form") { @page.should have_a_form }
|
75
85
|
end
|
76
86
|
context "with_path_of" do
|
77
87
|
it "should match path" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fracture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|