minitest-capybara 0.5.0 → 0.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc9e6e264a983fe8b89fcc5cc28d0a819cac7727
4
- data.tar.gz: 366b1b2240dbc23e334380ed58254e128159bc49
3
+ metadata.gz: cf433ae4ea66fa3f91baa744a5520f6baf2e6300
4
+ data.tar.gz: a182ecdd28fd191520bb70d9216efc80ee6c0e01
5
5
  SHA512:
6
- metadata.gz: 11f18c4f40001e1caed317f439bae415535c017e36fa78ee05ae568bbda557c4c7c6032af42c542aff29b557f5d1fbb67890c7aff9864076d9c57a02a92e7814
7
- data.tar.gz: 789d1559d8cc06d3f0c5d90bcb37b763504a24ecfe2ad69c3abcb9ea9558a32179daff66f5bdc078df9b5c6fd392a14ee33f287ec2bb69c225a770bb85ad12ff
6
+ metadata.gz: b046932cf800e23075e32736a8646d8e5e24dcb662fce30a837c39d5c1a9d0721c893711dd2b1a1a4e761d49d8e48019c85383f91dadb391151f204a58c5c542
7
+ data.tar.gz: 5a087f2d30cf3ce9815242b22349ad04a887b7b2083c699fba9b9bf6b2237009e680d4ce961344d320bfa0e9ae2dc2e93ac506fb3f0d3e25eeeb3d96717c7c52
data/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
1
  *.gem
2
2
  .bundle
3
- Gemfile.lock
4
3
  pkg/*
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ minitest-capybara (0.6.0.rc1)
5
+ capybara (~> 2.1.0)
6
+ minitest (~> 5.0)
7
+ rake
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ capybara (2.1.0)
13
+ mime-types (>= 1.16)
14
+ nokogiri (>= 1.3.3)
15
+ rack (>= 1.0.0)
16
+ rack-test (>= 0.5.4)
17
+ xpath (~> 2.0)
18
+ mime-types (2.2)
19
+ mini_portile (0.5.3)
20
+ minitest (5.3.2)
21
+ nokogiri (1.6.1)
22
+ mini_portile (~> 0.5.0)
23
+ rack (1.5.2)
24
+ rack-test (0.6.2)
25
+ rack (>= 1.0)
26
+ rake (10.2.2)
27
+ xpath (2.0.0)
28
+ nokogiri (~> 1.3)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ minitest-capybara!
data/README.md CHANGED
@@ -34,7 +34,24 @@ group :test do
34
34
  end
35
35
  ```
36
36
 
37
- Next, I like to create seperate test class for acceptance tests.
37
+ ```ruby
38
+ # features/my_feature.rb
39
+ require 'test_helper'
40
+
41
+ feature "My Super Feature" do
42
+ given(:lion) { ... }
43
+
44
+ background do
45
+ visit "/feature"
46
+ end
47
+
48
+ scenario "this awesome feature" do
49
+ page.must_have_content("Awesome Feature")
50
+ end
51
+ end
52
+ ```
53
+
54
+ Or if you prefer to create seperate test class for acceptance tests.
38
55
 
39
56
  ```ruby
40
57
  # test/test_helper.rb
@@ -57,7 +74,7 @@ class AcceptanceSpec < AcceptanceTest
57
74
  end
58
75
  ```
59
76
 
60
- Finally, you can use it like this:
77
+ and you can use it like this:
61
78
 
62
79
  ```ruby
63
80
  # test/acceptance/home_test.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0.rc1
@@ -34,7 +34,7 @@ module Capybara
34
34
  alias_method :assert_no_selector, :refute_selector
35
35
 
36
36
  ruby = ""
37
- (MiniTest::Capybara.assertions - %w[text content selector]).each do |assertion|
37
+ (Minitest::Capybara.assertions - %w[text content selector]).each do |assertion|
38
38
  ruby << <<-RUBY
39
39
  def assert_#{assertion}(*args)
40
40
  node, *args = prepare_args(args)
@@ -42,7 +42,7 @@ module Capybara
42
42
  end
43
43
  RUBY
44
44
  end
45
- (MiniTest::Capybara.refutations - %w[text content selector]).each do |refutation|
45
+ (Minitest::Capybara.refutations - %w[text content selector]).each do |refutation|
46
46
  ruby << <<-RUBY
47
47
  def refute_#{refutation}(*args)
48
48
  node, *args = prepare_args(args)
@@ -2,11 +2,11 @@ require "minitest/spec"
2
2
 
3
3
  module Capybara
4
4
  module Expectations
5
- MiniTest::Capybara.assertions.each do |assertion|
5
+ Minitest::Capybara.assertions.each do |assertion|
6
6
  infect_an_assertion "assert_#{assertion}", "must_have_#{assertion}", :reverse
7
7
  end
8
8
 
9
- MiniTest::Capybara.refutations.each do |refutation|
9
+ Minitest::Capybara.refutations.each do |refutation|
10
10
  infect_an_assertion "refute_#{refutation}", "wont_have_#{refutation}", :reverse
11
11
  end
12
12
 
@@ -1 +1,3 @@
1
+ require 'minitest/test'
1
2
  require 'minitest/capybara'
3
+ require 'minitest/features'
@@ -1,7 +1,7 @@
1
1
  require "minitest/capybara/version"
2
2
  require "capybara"
3
3
 
4
- module MiniTest
4
+ module Minitest
5
5
  module Capybara
6
6
  @@assertions = ::Capybara::Session::NODE_METHODS.grep(/^has_/).map { |s| s.to_s.match(/^has_(.*?)\?/)[1] }
7
7
  @@refutations = @@assertions.grep(/^no_/)
@@ -23,7 +23,7 @@ require "capybara/assertions"
23
23
  require "capybara/expectations"
24
24
 
25
25
  # :stopdoc:
26
- module MiniTest
26
+ module Minitest
27
27
  module Capybara
28
28
  def self.const_missing const
29
29
  if :Assertions == const
@@ -0,0 +1,2 @@
1
+ require 'minitest/features/acceptance_spec'
2
+ require 'minitest/features/dsl'
@@ -0,0 +1,6 @@
1
+ module Minitest
2
+ module AcceptanceSpec
3
+ include ::Capybara::DSL
4
+ include ::Capybara::Assertions
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ module Minitest
2
+ module Features
3
+ module DSL
4
+
5
+ include AcceptanceSpec
6
+
7
+ ##
8
+ # describe is 'defined' in Object
9
+ # therefore it is available anywhere
10
+ # so that allows us to simply
11
+ # alias feature to describe.
12
+ alias :feature :describe
13
+
14
+ end
15
+ end
16
+
17
+ module Spec::DSL
18
+ ##
19
+ # Pure simple old Ruby#Module alias method
20
+ #
21
+ alias :scenario :it
22
+ alias :background :before
23
+ alias :given :let
24
+ end
25
+
26
+ end
27
+
28
+ Object.send(:include, Minitest::Features::DSL)
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "capybara", "~> 2.1.0"
22
22
 
23
23
  s.add_runtime_dependency "rake"
24
- s.add_runtime_dependency "minitest", "~> 4.0"
24
+ s.add_runtime_dependency "minitest", "~> 5.0"
25
25
  end
@@ -11,23 +11,14 @@ describe "Assertions" do
11
11
  end
12
12
 
13
13
  it "defines all the assertions that Capybara does" do
14
- Minitest::Capybara.assertions.each do |assertion|
15
- assert self.respond_to?("assert_#{assertion}"),
16
- "The assertion assert_#{assertion} is not defined."
17
- end
14
+ assert_(:assertions)
18
15
  end
19
16
 
20
17
  it "defines all the refutations that Capybara does" do
21
- Minitest::Capybara.refutations.each do |refutation|
22
- assert self.respond_to?("refute_#{refutation}"),
23
- "The assertion refute_#{refutation} is not defined."
24
- end
18
+ refute_(:refutations)
25
19
  end
26
20
 
27
21
  it "defines all the negative assertions that Capybara does" do
28
- Minitest::Capybara.refutations.each do |refutation|
29
- assert self.respond_to?("assert_no_#{refutation}"),
30
- "The assertion assert_no_#{refutation} is not defined."
31
- end
22
+ assert_no_(:refutations)
32
23
  end
33
24
  end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ app = lambda { |env|
4
+ [200, { "X-Content-Type" => "Capybara" },"<div><h1>foo</h1><a href='/'>bar</a></div>"]
5
+ }
6
+
7
+ Capybara.app = app
8
+
9
+ feature "Assertions" do
10
+
11
+ background do
12
+ visit "/"
13
+ end
14
+
15
+ scenario "defines all assertions capybara does" do
16
+ assert_(:assertions)
17
+ end
18
+
19
+ scenario "defines all refutations that Capybara does" do
20
+ refute_(:refutations)
21
+ end
22
+
23
+ scenario "defines all negative assertions that Capybara does" do
24
+ assert_no_(:refutations)
25
+ end
26
+
27
+ end
@@ -11,16 +11,10 @@ describe "Expectations" do
11
11
  end
12
12
 
13
13
  it "defines all the must expectations that Capybara does" do
14
- Minitest::Capybara.assertions.each do |assertion|
15
- assert page.respond_to?("must_have_#{assertion}"),
16
- "The expectation must_have_#{assertion} is not defined."
17
- end
14
+ must_have_(:assertions)
18
15
  end
19
16
 
20
17
  it "defines all the wont expectations that Capybara does" do
21
- Minitest::Capybara.refutations.each do |refutation|
22
- assert page.respond_to?("wont_have_#{refutation}"),
23
- "The expectation wont_have_#{refutation} is not defined."
24
- end
18
+ wont_have_(:refutations)
25
19
  end
26
20
  end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ Capybara.app = lambda { |env| [200, {}, "<div><h1>foo</h1><a href='/'>bar</a></div>"] }
4
+
5
+ feature "Expectations" do
6
+
7
+ given(:bob) { "Hi 'am bob" }
8
+ background do
9
+ visit "/"
10
+ end
11
+
12
+ scenario "defines all the must expectations that Capybara does" do
13
+ must_have_(:assertions)
14
+ end
15
+
16
+ scenario "defines all the wont expectations that Capybara does" do
17
+ wont_have_(:refutations)
18
+ end
19
+
20
+ scenario "bob" do
21
+ bob.must_be_kind_of String
22
+ end
23
+
24
+ end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ feature "Testing Features" do
4
+
5
+ scenario "I am a scenario" do
6
+ :it_works.must_equal :it_works
7
+ end
8
+
9
+ scenario "it must include AcceptanceSpec" do
10
+ self.class.must_include Minitest::AcceptanceSpec
11
+ end
12
+
13
+ feature "must work if nested" do
14
+ scenario "it works" do
15
+ :it_works.must_equal :it_works
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ feature "Testing methods" do
22
+
23
+ given(:bob) { self.class }
24
+
25
+ scenario { bob.must_respond_to :background }
26
+
27
+ end
@@ -0,0 +1,56 @@
1
+ module Helper
2
+
3
+ def capybara(m)
4
+ Minitest::Capybara.send(m)
5
+ end
6
+
7
+ def notice(msg)
8
+ "The #{msg} is not defined."
9
+ end
10
+
11
+ ##
12
+ # method_name matches anything apart from have
13
+ # it must be an assertion
14
+ # if it matches it must be an expectation
15
+ #
16
+ def or_message(method_name, msg)
17
+ if method_name =! Regexp.new("have")
18
+ notice("assertions " + msg)
19
+ else
20
+ notice("expectation "+ msg)
21
+ end
22
+ end
23
+
24
+ ##
25
+ # Ask either self or page
26
+ #
27
+ def respond_to(m)
28
+ self.respond_to?(m) || page.respond_to?(m)
29
+ end
30
+
31
+ ##
32
+ # callee here works but __method__ would not.
33
+ # that's because callee changes accordingly as
34
+ # self changes.
35
+ # id2name simply converts a symbol to a string.
36
+ # _method_ creates a method to be looked up
37
+ # _method_ = "refute_method_name"
38
+ #
39
+ def assert_(method_name)
40
+ callee = send(:__callee__).id2name
41
+ capybara(method_name).each do |assertion|
42
+ _method_ = "#{callee}#{assertion}"
43
+
44
+ assert respond_to(_method_),
45
+ or_message(callee, _method_)
46
+ end
47
+ end
48
+
49
+ alias :refute_ :assert_
50
+ alias :assert_no_ :assert_
51
+ alias :must_have_ :assert_
52
+ alias :wont_have_ :assert_
53
+
54
+ end
55
+
56
+ Object.send(:include, Helper)
data/test/test_helper.rb CHANGED
@@ -1,2 +1,4 @@
1
1
  require "minitest/autorun"
2
+ require "support/helper"
2
3
  require "minitest/capybara"
4
+ require "minitest/features"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojciech Mach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-07 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '5.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.0'
54
+ version: '5.0'
55
55
  description: Capybara matchers support for minitest unit and spec
56
56
  email:
57
57
  - wojtek@wojtekmach.pl
@@ -62,6 +62,7 @@ files:
62
62
  - ".gitignore"
63
63
  - ".travis.yml"
64
64
  - Gemfile
65
+ - Gemfile.lock
65
66
  - LICENSE.txt
66
67
  - README.md
67
68
  - Rakefile
@@ -71,11 +72,18 @@ files:
71
72
  - lib/minitest-capybara.rb
72
73
  - lib/minitest/capybara.rb
73
74
  - lib/minitest/capybara/version.rb
75
+ - lib/minitest/features.rb
76
+ - lib/minitest/features/acceptance_spec.rb
77
+ - lib/minitest/features/dsl.rb
74
78
  - minitest-capybara.gemspec
75
79
  - test/capybara/assertions_test.rb
80
+ - test/capybara/assertions_using_features_spec.rb
76
81
  - test/capybara/expectations_test.rb
82
+ - test/capybara/expectations_using_features_spec.rb
77
83
  - test/minitest/base_node_test.rb
78
84
  - test/minitest/capybara_test.rb
85
+ - test/minitest/features_test.rb
86
+ - test/support/helper.rb
79
87
  - test/test_helper.rb
80
88
  homepage: ''
81
89
  licenses: []
@@ -91,18 +99,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
99
  version: '0'
92
100
  required_rubygems_version: !ruby/object:Gem::Requirement
93
101
  requirements:
94
- - - ">="
102
+ - - ">"
95
103
  - !ruby/object:Gem::Version
96
- version: '0'
104
+ version: 1.3.1
97
105
  requirements: []
98
106
  rubyforge_project: minitest-capybara
99
- rubygems_version: 2.1.5
107
+ rubygems_version: 2.2.2
100
108
  signing_key:
101
109
  specification_version: 4
102
110
  summary: Capybara matchers support for minitest unit and spec
103
111
  test_files:
104
112
  - test/capybara/assertions_test.rb
113
+ - test/capybara/assertions_using_features_spec.rb
105
114
  - test/capybara/expectations_test.rb
115
+ - test/capybara/expectations_using_features_spec.rb
106
116
  - test/minitest/base_node_test.rb
107
117
  - test/minitest/capybara_test.rb
118
+ - test/minitest/features_test.rb
119
+ - test/support/helper.rb
108
120
  - test/test_helper.rb