rspec-html-matchers 0.2.4 → 0.3.4

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.
@@ -1,3 +1,6 @@
1
+ before_script:
2
+ - "export DISPLAY=:99.0"
3
+ - "sh -e /etc/init.d/xvfb start"
1
4
  rvm:
2
5
  - 1.8.7
3
6
  - 1.9.2
@@ -7,6 +7,11 @@ unreleased(TODO)
7
7
  * improve documentation(look at changelog and code!)
8
8
  * add :without to have\_tag? like have_tag('div', :without => { :class => 'test' })
9
9
 
10
+ 0.3.4
11
+ -----
12
+
13
+ * capybara support
14
+
10
15
  0.2.4
11
16
  -----
12
17
 
data/README.md CHANGED
@@ -89,6 +89,12 @@ end
89
89
  '<p class="qwe rty" id="qwerty">Paragraph</p>'.should have_tag('p', :with => { :class => ['qwe', 'rty'] })
90
90
  ```
91
91
 
92
+ usage with capybara and cucumber:
93
+
94
+ page.should have_tag( ... )
95
+
96
+ where `page` is an instance of Capybara::Session
97
+
92
98
  Also included special matchers for form inputs:
93
99
  -----------------------------------------------
94
100
 
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  require 'bundler'
2
2
  require 'rspec/core/rake_task'
3
+ require 'cucumber/rake/task'
3
4
  Bundler::GemHelper.install_tasks
4
5
 
5
6
  gemspec = eval(File.read(Dir["*.gemspec"].first))
6
7
 
7
- task :default => :spec
8
+ task :default => [:spec, :cucumber]
8
9
 
9
10
  RSpec::Core::RakeTask.new(:spec) do |t|
10
11
  t.rspec_opts='--tag ~wip'
@@ -25,3 +26,8 @@ namespace :spec do
25
26
  t.rspec_opts=['-r simplecov']
26
27
  end
27
28
  end
29
+
30
+ Cucumber::Rake::Task.new(:cucumber) do |t|
31
+ t.fork = true
32
+ t.profile = 'default'
33
+ end
@@ -0,0 +1 @@
1
+ default: --strict features
@@ -0,0 +1,23 @@
1
+ Feature: Javascript generated content
2
+
3
+ Scenario: Test with js
4
+ Given I have following template:
5
+ """
6
+ <!DOCTYPE html>
7
+ <html>
8
+ <head>
9
+ <meta charset="utf-8">
10
+ <title>HTML5 Template</title>
11
+ </head>
12
+ <body>
13
+ <h1>Hello World!</h1>
14
+
15
+ <script type="text/javascript">
16
+ document.write('<p>Hello Another World!</p>');
17
+ </script>
18
+ </body>
19
+ </html>
20
+ """
21
+ When I open this template in browser
22
+ Then I should be able to match static content
23
+ And I should be able to match javascript generated content
@@ -0,0 +1,27 @@
1
+ Given /^I have following template:$/ do |string|
2
+ File.open($INDEX_HTML,'w+') do |file|
3
+ file.write(string)
4
+ end
5
+ end
6
+
7
+ When /^I open this template in browser$/ do
8
+ visit('/index.html')
9
+ end
10
+
11
+ Then /^I should be able to match static content$/ do
12
+ # capybara:
13
+ page.should have_content('Hello World!')
14
+ page.should have_css('h1')
15
+
16
+ # rspec2 matchers:
17
+ page.should have_tag('h1', :text => 'Hello World!')
18
+ end
19
+
20
+ Then /^I should be able to match javascript generated content$/ do
21
+ # capybara:
22
+ page.should have_content('Hello Another World!')
23
+ page.should have_css('p')
24
+
25
+ # rspec2 matchers:
26
+ page.should have_tag('p', :text => 'Hello Another World!')
27
+ end
@@ -0,0 +1,17 @@
1
+ require 'sinatra/base'
2
+ require 'capybara/cucumber'
3
+ require 'rspec-html-matchers'
4
+
5
+ $ASSETS_DIR = File.join(Dir.pwd,'assets')
6
+ $INDEX_HTML = File.join($ASSETS_DIR,'index.html')
7
+
8
+ class SimpleApp < Sinatra::Base
9
+ set :public_folder, $ASSETS_DIR
10
+ end
11
+
12
+ Capybara.default_driver = :selenium
13
+ Capybara.app = SimpleApp
14
+
15
+ After do
16
+ FileUtils.rm $INDEX_HTML
17
+ end
@@ -56,6 +56,8 @@ module RSpec
56
56
  def matches? document, &block
57
57
  @block = block if block
58
58
 
59
+ document = document.html if defined?(Capybara) && document.is_a?(Capybara::Session)
60
+
59
61
  case document
60
62
  when String
61
63
  @parent_scope = @current_scope = Nokogiri::HTML(document).css(@tag)
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rspec-html-matchers"
6
- s.version = '0.2.4'
6
+ s.version = '0.3.4'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["kucaahbe"]
9
9
  s.email = ["kucaahbe@ukr.net"]
@@ -24,5 +24,8 @@ DESC
24
24
  s.add_dependency 'nokogiri', '>= 1.4.4'
25
25
 
26
26
  s.add_development_dependency 'simplecov'
27
+ s.add_development_dependency 'cucumber'
28
+ s.add_development_dependency 'capybara'
29
+ s.add_development_dependency 'sinatra'
27
30
  s.add_development_dependency 'rake'
28
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-html-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -59,6 +59,54 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: cucumber
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: capybara
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: sinatra
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
62
110
  - !ruby/object:Gem::Dependency
63
111
  name: rake
64
112
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +147,10 @@ files:
99
147
  - assets/quotes.html
100
148
  - assets/search_and_submit.html
101
149
  - assets/special.html
150
+ - cucumber.yml
151
+ - features/ajax_generated_content.feature
152
+ - features/step_definitions/steps.rb
153
+ - features/support/env.rb
102
154
  - lib/rspec-html-matchers.rb
103
155
  - mikhalok.jpg
104
156
  - rspec-html-matchers.gemspec