rails_edge_test 1.1.0 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,165 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails_edge_test (1.2.2)
5
+ actionpack (>= 5.2.0, < 7.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.0.3.4)
11
+ actionpack (= 6.0.3.4)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.3.4)
15
+ actionpack (= 6.0.3.4)
16
+ activejob (= 6.0.3.4)
17
+ activerecord (= 6.0.3.4)
18
+ activestorage (= 6.0.3.4)
19
+ activesupport (= 6.0.3.4)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.3.4)
22
+ actionpack (= 6.0.3.4)
23
+ actionview (= 6.0.3.4)
24
+ activejob (= 6.0.3.4)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
27
+ actionpack (6.0.3.4)
28
+ actionview (= 6.0.3.4)
29
+ activesupport (= 6.0.3.4)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.3.4)
35
+ actionpack (= 6.0.3.4)
36
+ activerecord (= 6.0.3.4)
37
+ activestorage (= 6.0.3.4)
38
+ activesupport (= 6.0.3.4)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.3.4)
41
+ activesupport (= 6.0.3.4)
42
+ builder (~> 3.1)
43
+ erubi (~> 1.4)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.3.4)
47
+ activesupport (= 6.0.3.4)
48
+ globalid (>= 0.3.6)
49
+ activemodel (6.0.3.4)
50
+ activesupport (= 6.0.3.4)
51
+ activerecord (6.0.3.4)
52
+ activemodel (= 6.0.3.4)
53
+ activesupport (= 6.0.3.4)
54
+ activestorage (6.0.3.4)
55
+ actionpack (= 6.0.3.4)
56
+ activejob (= 6.0.3.4)
57
+ activerecord (= 6.0.3.4)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.3.4)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (>= 0.7, < 2)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ zeitwerk (~> 2.2, >= 2.2.2)
65
+ appraisal (2.3.0)
66
+ bundler
67
+ rake
68
+ thor (>= 0.14.0)
69
+ builder (3.2.4)
70
+ concurrent-ruby (1.1.7)
71
+ crass (1.0.6)
72
+ diff-lcs (1.4.4)
73
+ erubi (1.10.0)
74
+ globalid (0.4.2)
75
+ activesupport (>= 4.2.0)
76
+ i18n (1.8.5)
77
+ concurrent-ruby (~> 1.0)
78
+ loofah (2.8.0)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.7.1)
82
+ mini_mime (>= 0.1.1)
83
+ marcel (0.3.3)
84
+ mimemagic (~> 0.3.2)
85
+ method_source (1.0.0)
86
+ mimemagic (0.3.5)
87
+ mini_mime (1.0.2)
88
+ mini_portile2 (2.4.0)
89
+ minitest (5.14.2)
90
+ nio4r (2.5.4)
91
+ nokogiri (1.10.10)
92
+ mini_portile2 (~> 2.4.0)
93
+ rack (2.2.3)
94
+ rack-test (1.1.0)
95
+ rack (>= 1.0, < 3)
96
+ rails (6.0.3.4)
97
+ actioncable (= 6.0.3.4)
98
+ actionmailbox (= 6.0.3.4)
99
+ actionmailer (= 6.0.3.4)
100
+ actionpack (= 6.0.3.4)
101
+ actiontext (= 6.0.3.4)
102
+ actionview (= 6.0.3.4)
103
+ activejob (= 6.0.3.4)
104
+ activemodel (= 6.0.3.4)
105
+ activerecord (= 6.0.3.4)
106
+ activestorage (= 6.0.3.4)
107
+ activesupport (= 6.0.3.4)
108
+ bundler (>= 1.3.0)
109
+ railties (= 6.0.3.4)
110
+ sprockets-rails (>= 2.0.0)
111
+ rails-dom-testing (2.0.3)
112
+ activesupport (>= 4.2.0)
113
+ nokogiri (>= 1.6)
114
+ rails-html-sanitizer (1.3.0)
115
+ loofah (~> 2.3)
116
+ railties (6.0.3.4)
117
+ actionpack (= 6.0.3.4)
118
+ activesupport (= 6.0.3.4)
119
+ method_source
120
+ rake (>= 0.8.7)
121
+ thor (>= 0.20.3, < 2.0)
122
+ rake (13.0.1)
123
+ rspec (3.10.0)
124
+ rspec-core (~> 3.10.0)
125
+ rspec-expectations (~> 3.10.0)
126
+ rspec-mocks (~> 3.10.0)
127
+ rspec-core (3.10.0)
128
+ rspec-support (~> 3.10.0)
129
+ rspec-expectations (3.10.0)
130
+ diff-lcs (>= 1.2.0, < 2.0)
131
+ rspec-support (~> 3.10.0)
132
+ rspec-mocks (3.10.0)
133
+ diff-lcs (>= 1.2.0, < 2.0)
134
+ rspec-support (~> 3.10.0)
135
+ rspec-support (3.10.0)
136
+ sprockets (4.0.2)
137
+ concurrent-ruby (~> 1.0)
138
+ rack (> 1, < 3)
139
+ sprockets-rails (3.2.2)
140
+ actionpack (>= 4.0)
141
+ activesupport (>= 4.0)
142
+ sprockets (>= 3.0.0)
143
+ sqlite3 (1.4.2)
144
+ thor (1.0.1)
145
+ thread_safe (0.3.6)
146
+ tzinfo (1.2.8)
147
+ thread_safe (~> 0.1)
148
+ websocket-driver (0.7.3)
149
+ websocket-extensions (>= 0.1.0)
150
+ websocket-extensions (0.1.5)
151
+ zeitwerk (2.4.2)
152
+
153
+ PLATFORMS
154
+ ruby
155
+
156
+ DEPENDENCIES
157
+ appraisal (~> 2.3)
158
+ rails (~> 6.0.0)
159
+ rails_edge_test!
160
+ rake (~> 13.0)
161
+ rspec (~> 3.9)
162
+ sqlite3 (~> 1.4.0)
163
+
164
+ BUNDLED WITH
165
+ 2.1.4
@@ -15,7 +15,8 @@ module RailsEdgeTest
15
15
  # access from within an `edge` block.
16
16
  # @param [Module] mod - a module to be included into all `edge` blocks
17
17
  def include(mod)
18
- Dsl::Edge.include mod
18
+ Dsl::Controller.include(mod)
19
+ Dsl::Edge.include(mod)
19
20
  end
20
21
 
21
22
  # Provide a block to be executed once before running any `edge` blocks
@@ -50,6 +50,7 @@ module RailsEdgeTest
50
50
  end
51
51
 
52
52
  private
53
+
53
54
  def define_lets(edge, lets_handler)
54
55
  lets_handler.let_blocks.each do |title, block|
55
56
  edge.define_singleton_method(title) do
@@ -1,5 +1,5 @@
1
1
  module RailsEdgeTest::Dsl
2
- Action = Struct.new(:name, :controller_class) do
2
+ Action = Struct.new(:name, :controller) do
3
3
  def initialize(*args)
4
4
  super
5
5
  @edges = {}
@@ -7,7 +7,7 @@ module RailsEdgeTest::Dsl
7
7
  end
8
8
 
9
9
  def edge(description, &block)
10
- edge = Edge.new(description, name, controller_class)
10
+ edge = Edge.new(description, self)
11
11
  @edges[edge] = block
12
12
  end
13
13
 
@@ -26,5 +26,24 @@ module RailsEdgeTest::Dsl
26
26
  def __let_handler
27
27
  @let_handler
28
28
  end
29
+
30
+ def controller_class
31
+ controller.controller_class
32
+ end
33
+
34
+ # support calling methods defined in controller
35
+ def method_missing(method_name, *arguments, &block)
36
+ if controller.respond_to?(method_name)
37
+ controller.public_send(method_name, *arguments, &block)
38
+ else
39
+ super
40
+ end
41
+ end
42
+
43
+ # always define respond_to_missing? when defining method_missing:
44
+ # https://thoughtbot.com/blog/always-define-respond-to-missing-when-overriding
45
+ def respond_to_missing?(method_name, include_private = false)
46
+ controller.respond_to?(method_name) || super
47
+ end
29
48
  end
30
49
  end
@@ -7,7 +7,7 @@ module RailsEdgeTest::Dsl
7
7
  end
8
8
 
9
9
  def action(name, &block)
10
- new_action = Action.new(name, controller_class)
10
+ new_action = Action.new(name, self)
11
11
  new_action.instance_exec(&block)
12
12
  @actions << new_action
13
13
  end
@@ -3,19 +3,23 @@ require 'action_controller'
3
3
  require 'action_controller/test_case'
4
4
 
5
5
  module RailsEdgeTest::Dsl
6
- Edge = Struct.new(:description, :action, :controller_class) do
6
+ Edge = Struct.new(:description, :action) do
7
7
 
8
8
  def initialize(*args)
9
9
  super
10
10
  @let_cache = {}
11
11
  end
12
12
 
13
+ delegate :controller_class, to: :action
13
14
  delegate :session, to: :request
14
15
 
15
16
  def request
16
17
  @request ||= ActionController::TestRequest.create(controller_class)
17
18
  end
18
19
 
20
+ # In the context of the edge, we want `controller` to be the rails controller
21
+ # instead of our own RailsEdgeTest::Dsl::Controller. In this way the user can
22
+ # directly access the rails controller within their edge.
19
23
  def controller
20
24
  @controller ||= controller_class.new
21
25
  end
@@ -28,7 +32,7 @@ module RailsEdgeTest::Dsl
28
32
  request.assign_parameters(
29
33
  ::Rails.application.routes,
30
34
  controller_class.controller_path,
31
- action.to_s,
35
+ action.name.to_s,
32
36
  parameters.stringify_keys!,
33
37
  '',
34
38
  ''
@@ -38,7 +42,7 @@ module RailsEdgeTest::Dsl
38
42
  res.request = request
39
43
  end
40
44
 
41
- @response = controller.dispatch(action, request, response)
45
+ @response = controller.dispatch(action.name, request, response)
42
46
  end
43
47
 
44
48
  def produce_elm_file(module_name, ivar: nil)
@@ -69,6 +73,7 @@ module RailsEdgeTest::Dsl
69
73
  end
70
74
 
71
75
  private
76
+
72
77
  def produce_json(ivar: nil)
73
78
  unless response
74
79
  fail "Must perform a request (for example `perform_get`) before attempting to produce a json file."
@@ -100,5 +105,20 @@ module RailsEdgeTest::Dsl
100
105
  f.flush
101
106
  end
102
107
  end
108
+
109
+ # support calling methods defined in action
110
+ def method_missing(method_name, *arguments, &block)
111
+ if action.respond_to?(method_name)
112
+ action.public_send(method_name, *arguments, &block)
113
+ else
114
+ super
115
+ end
116
+ end
117
+
118
+ # always define respond_to_missing? when defining method_missing:
119
+ # https://thoughtbot.com/blog/always-define-respond-to-missing-when-overriding
120
+ def respond_to_missing?(method_name, include_private = false)
121
+ action.respond_to?(method_name) || super
122
+ end
103
123
  end
104
124
  end
@@ -19,7 +19,7 @@ module RailsEdgeTest
19
19
  )
20
20
  end
21
21
 
22
- Dir.glob(paths_to_load).each do |file|
22
+ Dir.glob(paths_to_load).sort.each do |file|
23
23
  load file
24
24
  end
25
25
 
@@ -1,3 +1,3 @@
1
1
  module RailsEdgeTest
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.3"
3
3
  end
@@ -0,0 +1,12 @@
1
+ # this is a copy of the dependencies listed in the gemspec,
2
+ # since bundix doesn't support reading the gemspec itself.
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'actionpack', '~> 5.2'
6
+
7
+ group :development do
8
+ gem 'rails', '~> 5.2'
9
+ gem 'sqlite3', '~> 1.4.0'
10
+ gem 'rake', '~> 13.0'
11
+ gem 'rspec', '~> 3.9'
12
+ end
@@ -0,0 +1,138 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actioncable (5.2.4.2)
5
+ actionpack (= 5.2.4.2)
6
+ nio4r (~> 2.0)
7
+ websocket-driver (>= 0.6.1)
8
+ actionmailer (5.2.4.2)
9
+ actionpack (= 5.2.4.2)
10
+ actionview (= 5.2.4.2)
11
+ activejob (= 5.2.4.2)
12
+ mail (~> 2.5, >= 2.5.4)
13
+ rails-dom-testing (~> 2.0)
14
+ actionpack (5.2.4.2)
15
+ actionview (= 5.2.4.2)
16
+ activesupport (= 5.2.4.2)
17
+ rack (~> 2.0, >= 2.0.8)
18
+ rack-test (>= 0.6.3)
19
+ rails-dom-testing (~> 2.0)
20
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
+ actionview (5.2.4.2)
22
+ activesupport (= 5.2.4.2)
23
+ builder (~> 3.1)
24
+ erubi (~> 1.4)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
27
+ activejob (5.2.4.2)
28
+ activesupport (= 5.2.4.2)
29
+ globalid (>= 0.3.6)
30
+ activemodel (5.2.4.2)
31
+ activesupport (= 5.2.4.2)
32
+ activerecord (5.2.4.2)
33
+ activemodel (= 5.2.4.2)
34
+ activesupport (= 5.2.4.2)
35
+ arel (>= 9.0)
36
+ activestorage (5.2.4.2)
37
+ actionpack (= 5.2.4.2)
38
+ activerecord (= 5.2.4.2)
39
+ marcel (~> 0.3.1)
40
+ activesupport (5.2.4.2)
41
+ concurrent-ruby (~> 1.0, >= 1.0.2)
42
+ i18n (>= 0.7, < 2)
43
+ minitest (~> 5.1)
44
+ tzinfo (~> 1.1)
45
+ arel (9.0.0)
46
+ builder (3.2.4)
47
+ concurrent-ruby (1.1.6)
48
+ crass (1.0.6)
49
+ diff-lcs (1.3)
50
+ erubi (1.9.0)
51
+ globalid (0.4.2)
52
+ activesupport (>= 4.2.0)
53
+ i18n (1.8.2)
54
+ concurrent-ruby (~> 1.0)
55
+ loofah (2.5.0)
56
+ crass (~> 1.0.2)
57
+ nokogiri (>= 1.5.9)
58
+ mail (2.7.1)
59
+ mini_mime (>= 0.1.1)
60
+ marcel (0.3.3)
61
+ mimemagic (~> 0.3.2)
62
+ method_source (1.0.0)
63
+ mimemagic (0.3.4)
64
+ mini_mime (1.0.2)
65
+ mini_portile2 (2.4.0)
66
+ minitest (5.14.0)
67
+ nio4r (2.5.2)
68
+ nokogiri (1.10.9)
69
+ mini_portile2 (~> 2.4.0)
70
+ rack (2.2.2)
71
+ rack-test (1.1.0)
72
+ rack (>= 1.0, < 3)
73
+ rails (5.2.4.2)
74
+ actioncable (= 5.2.4.2)
75
+ actionmailer (= 5.2.4.2)
76
+ actionpack (= 5.2.4.2)
77
+ actionview (= 5.2.4.2)
78
+ activejob (= 5.2.4.2)
79
+ activemodel (= 5.2.4.2)
80
+ activerecord (= 5.2.4.2)
81
+ activestorage (= 5.2.4.2)
82
+ activesupport (= 5.2.4.2)
83
+ bundler (>= 1.3.0)
84
+ railties (= 5.2.4.2)
85
+ sprockets-rails (>= 2.0.0)
86
+ rails-dom-testing (2.0.3)
87
+ activesupport (>= 4.2.0)
88
+ nokogiri (>= 1.6)
89
+ rails-html-sanitizer (1.3.0)
90
+ loofah (~> 2.3)
91
+ railties (5.2.4.2)
92
+ actionpack (= 5.2.4.2)
93
+ activesupport (= 5.2.4.2)
94
+ method_source
95
+ rake (>= 0.8.7)
96
+ thor (>= 0.19.0, < 2.0)
97
+ rake (13.0.1)
98
+ rspec (3.9.0)
99
+ rspec-core (~> 3.9.0)
100
+ rspec-expectations (~> 3.9.0)
101
+ rspec-mocks (~> 3.9.0)
102
+ rspec-core (3.9.1)
103
+ rspec-support (~> 3.9.1)
104
+ rspec-expectations (3.9.1)
105
+ diff-lcs (>= 1.2.0, < 2.0)
106
+ rspec-support (~> 3.9.0)
107
+ rspec-mocks (3.9.1)
108
+ diff-lcs (>= 1.2.0, < 2.0)
109
+ rspec-support (~> 3.9.0)
110
+ rspec-support (3.9.2)
111
+ sprockets (4.0.0)
112
+ concurrent-ruby (~> 1.0)
113
+ rack (> 1, < 3)
114
+ sprockets-rails (3.2.1)
115
+ actionpack (>= 4.0)
116
+ activesupport (>= 4.0)
117
+ sprockets (>= 3.0.0)
118
+ sqlite3 (1.4.2)
119
+ thor (1.0.1)
120
+ thread_safe (0.3.6)
121
+ tzinfo (1.2.7)
122
+ thread_safe (~> 0.1)
123
+ websocket-driver (0.7.1)
124
+ websocket-extensions (>= 0.1.0)
125
+ websocket-extensions (0.1.4)
126
+
127
+ PLATFORMS
128
+ ruby
129
+
130
+ DEPENDENCIES
131
+ actionpack (~> 5.2)
132
+ rails (~> 5.2)
133
+ rake (~> 13.0)
134
+ rspec (~> 3.9)
135
+ sqlite3 (~> 1.4.0)
136
+
137
+ BUNDLED WITH
138
+ 1.17.3