minitest-rails-capybara 0.0.2 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,16 @@
1
+ === 0.1 / 2012-08-02
2
+
3
+ * Defer to minitest-capybara for Capybara integration
4
+ * Add support for Capybara matchers using minitest-matchers
5
+
6
+ https://github.com/blowmage/minitest-rails-capybara/compare/v0.0.2...v0.1
7
+
8
+ === 0.0.2 / 2012-07-09
9
+
10
+ * Correct loading issue
11
+
12
+ https://github.com/blowmage/minitest-rails-capybara/compare/v0.0.1...v0.0.2
13
+
1
14
  === 0.0.1 / 2012-07-07
2
15
 
3
16
  * 1 major enhancement
data/Manifest.txt CHANGED
@@ -8,4 +8,7 @@ Rakefile
8
8
  lib/minitest-rails-capybara.rb
9
9
  lib/minitest/rails/capybara.rb
10
10
  minitest-rails-capybara.gemspec
11
- test/test_minitest_rails_capybara.rb
11
+ test/rails_helper.rb
12
+ test/test_dsl.rb
13
+ test/test_matchers.rb
14
+ test/test_sanity.rb
data/README.rdoc CHANGED
@@ -10,15 +10,20 @@ This installs the following gems:
10
10
 
11
11
  minitest
12
12
  minitest-rails
13
+ minitest-matchers
14
+ minitest-capybara
13
15
  capybara
14
16
 
15
17
  == Configure
16
18
 
17
- Follow the instructions to configure <tt>minitest-rails</tt>. Then add <tt>minitest-rails-capybara</tt> to the <tt>:test</tt> and <tt>:development</tt> groups in Gemfile:
19
+ Follow the instructions to configure <tt>minitest-rails</tt>. Then add <tt>minitest-rails-capybara</tt> to the <tt>:test</tt> group in Gemfile:
18
20
 
19
- group :test, :development do
20
- gem 'minitest-rails'
21
- gem 'minitest-rails-capybara'
21
+ group :development, :test do
22
+ gem "minitest-rails"
23
+ end
24
+
25
+ group :test do
26
+ gem "minitest-rails-capybara"
22
27
  end
23
28
 
24
29
  Add the following to your <tt>minitest_helper.rb</tt> file to the <tt>test</tt> directory.
@@ -40,7 +45,18 @@ You can now use Capybara in your acceptance tests!
40
45
  require "minitest_helper"
41
46
 
42
47
  class CanAccessHomeTest < MiniTest::Rails::ActionDispatch::IntegrationTest
43
- test "the homepage has content" do
48
+ def test_homepage_has_content
49
+ visit root_path
50
+ assert page.has_content?("Home#index")
51
+ end
52
+ end
53
+
54
+ Or, using the Spec DSL:
55
+
56
+ require "minitest_helper"
57
+
58
+ describe "Can Access Home Acceptance Test" do
59
+ it "has content" do
44
60
  visit root_path
45
61
  assert page.has_content?("Home#index")
46
62
  end
@@ -54,6 +70,23 @@ https://groups.google.com/group/minitest-rails
54
70
 
55
71
  == License
56
72
 
57
- Copyright © 2012 Mike Moore.
58
-
59
- Released under the MIT license. See `LICENSE` for details.
73
+ Copyright (c) 2012 Mike Moore
74
+
75
+ Permission is hereby granted, free of charge, to any person obtaining
76
+ a copy of this software and associated documentation files (the
77
+ "Software"), to deal in the Software without restriction, including
78
+ without limitation the rights to use, copy, modify, merge, publish,
79
+ distribute, sublicense, and/or sell copies of the Software, and to
80
+ permit persons to whom the Software is furnished to do so, subject to
81
+ the following conditions:
82
+
83
+ The above copyright notice and this permission notice shall be
84
+ included in all copies or substantial portions of the Software.
85
+
86
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
87
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
88
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
89
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
90
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
91
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
92
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -11,15 +11,15 @@ Hoe.spec 'minitest-rails-capybara' do
11
11
  developer 'Mike Moore', 'mike@blowmage.com'
12
12
 
13
13
  self.summary = 'Capybara integration for MiniTest::Rails.'
14
- self.description = 'Adds Capybara to acceptance tests in Minitest::Rails.'
14
+ self.description = 'Adds Capybara to acceptance tests in MiniTest::Rails.'
15
15
  self.urls = ['http://blowmage.com/minitest-rails-capybara']
16
16
 
17
17
  self.history_file = "CHANGELOG.rdoc"
18
18
  self.readme_file = "README.rdoc"
19
19
  self.testlib = :minitest
20
20
 
21
- extra_deps << ['minitest-rails']
22
- extra_deps << ['capybara']
21
+ dependency 'minitest-rails', '~> 0.1'
22
+ dependency 'minitest-capybara', '~> 0.1'
23
23
  end
24
24
 
25
25
  # vim: syntax=ruby
@@ -1,3 +1,9 @@
1
- module Minitest::Rails::Capybara
2
- VERSION = '0.0.2'
3
- end
1
+ require "minitest-rails"
2
+
3
+ module MiniTest
4
+ module Rails
5
+ module Capybara
6
+ VERSION = "0.1"
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,10 @@
1
1
  require "minitest/rails"
2
+ # Load minitest-matchers and fix Capybara::RSpecMatchers
3
+ require "minitest-capybara"
2
4
  require "capybara/rails"
3
5
 
4
6
  class MiniTest::Rails::ActionDispatch::IntegrationTest
5
7
  include Rails.application.routes.url_helpers
8
+ include Capybara::RSpecMatchers
6
9
  include Capybara::DSL
7
- end
10
+ end
@@ -2,40 +2,40 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "minitest-rails-capybara"
5
- s.version = "0.0.2.20120709105721"
5
+ s.version = "0.1.20120802135256"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mike Moore"]
9
- s.date = "2012-07-09"
10
- s.description = "Adds Capybara to acceptance tests in Minitest::Rails."
9
+ s.date = "2012-08-02"
10
+ s.description = "Adds Capybara to acceptance tests in MiniTest::Rails."
11
11
  s.email = ["mike@blowmage.com"]
12
12
  s.extra_rdoc_files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc"]
13
- s.files = [".autotest", ".gemtest", "CHANGELOG.rdoc", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "lib/minitest-rails-capybara.rb", "lib/minitest/rails/capybara.rb", "minitest-rails-capybara.gemspec", "test/test_minitest_rails_capybara.rb"]
13
+ s.files = [".autotest", ".gemtest", "CHANGELOG.rdoc", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "lib/minitest-rails-capybara.rb", "lib/minitest/rails/capybara.rb", "minitest-rails-capybara.gemspec", "test/rails_helper.rb", "test/test_dsl.rb", "test/test_matchers.rb", "test/test_sanity.rb"]
14
14
  s.homepage = "http://blowmage.com/minitest-rails-capybara"
15
15
  s.rdoc_options = ["--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = "minitest-rails-capybara"
18
18
  s.rubygems_version = "1.8.24"
19
19
  s.summary = "Capybara integration for MiniTest::Rails."
20
- s.test_files = ["test/test_minitest_rails_capybara.rb"]
20
+ s.test_files = ["test/test_dsl.rb", "test/test_matchers.rb", "test/test_sanity.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  s.specification_version = 3
24
24
 
25
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<minitest-rails>, [">= 0"])
27
- s.add_runtime_dependency(%q<capybara>, [">= 0"])
26
+ s.add_runtime_dependency(%q<minitest-rails>, ["~> 0.1"])
27
+ s.add_runtime_dependency(%q<minitest-capybara>, ["~> 0.1"])
28
28
  s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
29
29
  s.add_development_dependency(%q<hoe>, ["~> 3.0"])
30
30
  else
31
- s.add_dependency(%q<minitest-rails>, [">= 0"])
32
- s.add_dependency(%q<capybara>, [">= 0"])
31
+ s.add_dependency(%q<minitest-rails>, ["~> 0.1"])
32
+ s.add_dependency(%q<minitest-capybara>, ["~> 0.1"])
33
33
  s.add_dependency(%q<rdoc>, ["~> 3.10"])
34
34
  s.add_dependency(%q<hoe>, ["~> 3.0"])
35
35
  end
36
36
  else
37
- s.add_dependency(%q<minitest-rails>, [">= 0"])
38
- s.add_dependency(%q<capybara>, [">= 0"])
37
+ s.add_dependency(%q<minitest-rails>, ["~> 0.1"])
38
+ s.add_dependency(%q<minitest-capybara>, ["~> 0.1"])
39
39
  s.add_dependency(%q<rdoc>, ["~> 3.10"])
40
40
  s.add_dependency(%q<hoe>, ["~> 3.0"])
41
41
  end
@@ -0,0 +1,30 @@
1
+ require "minitest/autorun"
2
+ require "action_controller/railtie"
3
+
4
+ class TestApp < Rails::Application
5
+ config.secret_token = "821c600ece97fc4ba952d67655b4b475"
6
+ initialize!
7
+ routes.draw do
8
+ root to: 'hello#world'
9
+ end
10
+ end
11
+ class HelloController < ActionController::Base
12
+ def world
13
+ render inline: "<!DOCTYPE html><title>TestApp</title>
14
+ <h1>Hello <span>World</span></h1>
15
+ <nav><ul><li><a href='/'>home</a></li></ul></nav>
16
+ <p><label>Email Address<input type='text'></label></p>
17
+ <button>random button</button>
18
+ <label>going<input type='checkbox' checked='checked'></label>
19
+ <label>avoid<input type='checkbox'></label>"
20
+ end
21
+ end
22
+
23
+ Rails.application = TestApp
24
+
25
+ require "minitest/rails/capybara"
26
+
27
+ Capybara.session_name = nil
28
+ Capybara.default_driver = nil
29
+ Capybara.use_default_driver
30
+ Capybara.app = TestApp
data/test/test_dsl.rb ADDED
@@ -0,0 +1,20 @@
1
+ require "rails_helper"
2
+
3
+ describe "Capybara DSL Acceptance Test" do
4
+
5
+ it "can call using_wait_time" do
6
+ Capybara.expects(:using_wait_time).with(6)
7
+ using_wait_time(6)
8
+ end
9
+
10
+ it "can call page" do
11
+ Capybara.expects(:current_session)
12
+ page
13
+ end
14
+
15
+ it "can call using_session" do
16
+ Capybara.expects(:using_session).with(:name)
17
+ using_session(:name)
18
+ end
19
+
20
+ end
@@ -0,0 +1,145 @@
1
+ require "rails_helper"
2
+
3
+ describe "Capybara Matchers Acceptance Test" do
4
+
5
+ describe "have_content" do
6
+ it "has page with content" do
7
+ visit root_path
8
+ assert_have_content page, "Hello World"
9
+ refute_have_content page, "Goobye All!"
10
+ page.must_have_content "Hello World"
11
+ page.wont_have_content "Goobye All!"
12
+ end
13
+
14
+ describe "with subject" do
15
+ before { visit(root_path) }
16
+ subject { page }
17
+
18
+ it { must have_content("Hello World") }
19
+ it { wont have_content("Goobye All!") }
20
+ must { have_content("Hello World") }
21
+ wont { have_content("Goobye All!") }
22
+ end
23
+ end
24
+
25
+ describe "have_selector" do
26
+ it "has page with heading" do
27
+ visit root_path
28
+ assert_have_selector page, "h1"
29
+ refute_have_selector page, "h3"
30
+ page.must_have_selector "h1"
31
+ page.wont_have_selector "h3"
32
+ end
33
+
34
+ describe "with subject" do
35
+ before { visit(root_path) }
36
+ subject { page }
37
+
38
+ it { must have_selector("h1") }
39
+ it { wont have_selector("h3") }
40
+ must { have_selector("h1") }
41
+ wont { have_selector("h3") }
42
+ end
43
+ end
44
+
45
+ describe "have_link" do
46
+ it "has a link to home" do
47
+ visit root_path
48
+ assert_have_link page, "home"
49
+ refute_have_link page, "away"
50
+ page.must_have_link "home"
51
+ page.wont_have_link "away"
52
+ end
53
+
54
+ describe "with subject" do
55
+ before { visit(root_path) }
56
+ subject { page }
57
+
58
+ it { must have_link("home") }
59
+ it { wont have_link("away") }
60
+ must { have_link("home") }
61
+ wont { have_link("away") }
62
+ end
63
+ end
64
+
65
+ describe "have_field" do
66
+ it "has a button to submit" do
67
+ visit root_path
68
+ assert_have_field page, "Email Address"
69
+ refute_have_field page, "Bank Account"
70
+ page.must_have_field "Email Address"
71
+ page.wont_have_field "Bank Account"
72
+ end
73
+
74
+ describe "with subject" do
75
+ before { visit(root_path) }
76
+ subject { page }
77
+
78
+ it { must have_field("Email Address") }
79
+ it { wont have_field("Bank Account") }
80
+ must { have_field("Email Address") }
81
+ wont { have_field("Bank Account") }
82
+ end
83
+ end
84
+
85
+ describe "have_button" do
86
+ it "has a button to login" do
87
+ visit root_path
88
+ assert_have_button page, "random button"
89
+ refute_have_button page, "missing button"
90
+ page.must_have_button "random button"
91
+ page.wont_have_button "missing button"
92
+ end
93
+
94
+ describe "with subject" do
95
+ before { visit(root_path) }
96
+ subject { page }
97
+
98
+ it { must have_button("random button") }
99
+ it { wont have_button("missing button") }
100
+ must { have_button("random button") }
101
+ wont { have_button("missing button") }
102
+ end
103
+ end
104
+
105
+ describe "have_checked_field" do
106
+ it "has a button to submit" do
107
+ visit root_path
108
+ assert_have_checked_field page, "going"
109
+ refute_have_checked_field page, "avoid"
110
+ page.must_have_checked_field "going"
111
+ page.wont_have_checked_field "avoid"
112
+ end
113
+
114
+ describe "with subject" do
115
+ before { visit(root_path) }
116
+ subject { page }
117
+
118
+ it { must have_checked_field("going") }
119
+ it { wont have_checked_field("avoid") }
120
+ must { have_checked_field("going") }
121
+ wont { have_checked_field("avoid") }
122
+ end
123
+ end
124
+
125
+ describe "have_unchecked_field" do
126
+ it "has a button to submit" do
127
+ visit root_path
128
+ assert_have_unchecked_field page, "avoid"
129
+ refute_have_unchecked_field page, "going"
130
+ page.must_have_unchecked_field "avoid"
131
+ page.wont_have_unchecked_field "going"
132
+ end
133
+
134
+ describe "with subject" do
135
+ before { visit(root_path) }
136
+ subject { page }
137
+
138
+ it { must have_unchecked_field("avoid") }
139
+ it { wont have_unchecked_field("going") }
140
+ must { have_unchecked_field("avoid") }
141
+ wont { have_unchecked_field("going") }
142
+ end
143
+ end
144
+
145
+ end
@@ -0,0 +1,8 @@
1
+ require "minitest/autorun"
2
+ require "minitest-rails-capybara"
3
+
4
+ class TestMiniTestRailsCapybara < MiniTest::Unit::TestCase
5
+ def test_sanity
6
+ assert MiniTest::Rails::Capybara::VERSION
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-rails-capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,40 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest-rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '0.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: '0.1'
30
30
  - !ruby/object:Gem::Dependency
31
- name: capybara
31
+ name: minitest-capybara
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: '0.1'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: '0.1'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rdoc
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -75,7 +75,7 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: '3.0'
78
- description: Adds Capybara to acceptance tests in Minitest::Rails.
78
+ description: Adds Capybara to acceptance tests in MiniTest::Rails.
79
79
  email:
80
80
  - mike@blowmage.com
81
81
  executables: []
@@ -95,7 +95,10 @@ files:
95
95
  - lib/minitest-rails-capybara.rb
96
96
  - lib/minitest/rails/capybara.rb
97
97
  - minitest-rails-capybara.gemspec
98
- - test/test_minitest_rails_capybara.rb
98
+ - test/rails_helper.rb
99
+ - test/test_dsl.rb
100
+ - test/test_matchers.rb
101
+ - test/test_sanity.rb
99
102
  homepage: http://blowmage.com/minitest-rails-capybara
100
103
  licenses: []
101
104
  post_install_message:
@@ -123,4 +126,6 @@ signing_key:
123
126
  specification_version: 3
124
127
  summary: Capybara integration for MiniTest::Rails.
125
128
  test_files:
126
- - test/test_minitest_rails_capybara.rb
129
+ - test/test_dsl.rb
130
+ - test/test_matchers.rb
131
+ - test/test_sanity.rb
@@ -1,8 +0,0 @@
1
- require "test/unit"
2
- require "minitest/rails/capybara"
3
-
4
- class TestMinitest::Rails::Capybara < Test::Unit::TestCase
5
- def test_sanity
6
- flunk "write tests or I will kneecap you"
7
- end
8
- end