fracture 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fracture/fracture.rb +14 -12
- data/lib/fracture/version.rb +1 -1
- data/spec/fracture_spec.rb +43 -1
- metadata +2 -2
data/lib/fracture/fracture.rb
CHANGED
@@ -64,19 +64,7 @@ class Fracture
|
|
64
64
|
all.keys - list_to_s(Array(fractures).flatten)
|
65
65
|
end
|
66
66
|
|
67
|
-
#def do_check page, label
|
68
|
-
# #page = page.response.body if page.is_a? CompaniesController
|
69
|
-
# page = page.response.body if page.respond_to?(:response)
|
70
|
-
# page = Nokogiri::HTML.parse(page)
|
71
|
-
# if text?
|
72
|
-
# page.text.include?(label)
|
73
|
-
# else
|
74
|
-
# page.at label
|
75
|
-
# end
|
76
|
-
#end
|
77
67
|
def do_check page, label
|
78
|
-
page = page.response.body if page.respond_to?(:response)
|
79
|
-
|
80
68
|
page_parsed = Nokogiri::HTML.parse(page)
|
81
69
|
|
82
70
|
if text?
|
@@ -87,6 +75,7 @@ class Fracture
|
|
87
75
|
end
|
88
76
|
|
89
77
|
def self.test_fractures(page, is_not, fracture_labels, reverse_fracture_labels=[])
|
78
|
+
page = self.get_body(page)
|
90
79
|
failures = {}
|
91
80
|
failures[:should] = []
|
92
81
|
failures[:should_not] = []
|
@@ -121,4 +110,17 @@ class Fracture
|
|
121
110
|
failures.merge!(passed: (failures[:should].empty? && failures[:should_not].empty?))
|
122
111
|
failures
|
123
112
|
end
|
113
|
+
|
114
|
+
def self.get_body(page)
|
115
|
+
case
|
116
|
+
when page.respond_to?(:response) # Controller
|
117
|
+
page.response.body
|
118
|
+
when page.respond_to?(:body)
|
119
|
+
page.body
|
120
|
+
when page.kind_of?(String)
|
121
|
+
page
|
122
|
+
else
|
123
|
+
raise 'Page sent is not valid'
|
124
|
+
end
|
125
|
+
end
|
124
126
|
end
|
data/lib/fracture/version.rb
CHANGED
data/spec/fracture_spec.rb
CHANGED
@@ -72,4 +72,46 @@ describe Fracture do
|
|
72
72
|
it("should not find it") { @first.do_check("z b", "a").should be_false }
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
|
+
context 'check if page is html or Controller or Integration class' do
|
77
|
+
let(:html) { '<html><body></body></html>' }
|
78
|
+
|
79
|
+
class ControllerTest
|
80
|
+
def initialize html
|
81
|
+
@html = html
|
82
|
+
end
|
83
|
+
|
84
|
+
def response
|
85
|
+
self
|
86
|
+
end
|
87
|
+
|
88
|
+
def body
|
89
|
+
@html
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class IntegrationTest
|
94
|
+
def initialize html
|
95
|
+
@html = html
|
96
|
+
end
|
97
|
+
|
98
|
+
def body
|
99
|
+
@html
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#get_body' do
|
104
|
+
it('just return html when sent') do
|
105
|
+
Fracture.get_body(html).should == html
|
106
|
+
end
|
107
|
+
|
108
|
+
it('get response.body from Controller') do
|
109
|
+
Fracture.get_body(ControllerTest.new(html)).should == html
|
110
|
+
end
|
111
|
+
|
112
|
+
it('get response.body from Integration') do
|
113
|
+
Fracture.get_body(IntegrationTest.new(html)).should == html
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
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.
|
4
|
+
version: 0.10.0
|
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: 2013-03-
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|