rails_edge_test 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0e38b1e7ec84c4bdb1e394dbd7eecfeb91979568c35459801ba61525ced08fe0
4
+ data.tar.gz: 35b6a89fd3c6b338807185d82970ff69302c90474dc784430312f1d9ad06e905
5
+ SHA512:
6
+ metadata.gz: 7fef201d44f5040a5eb71da3b7d109cdeeca95400c26dae312a471f3730ff4432bf767aa499762aa924d36e0e92c69ee62260574cbd76baba8648c9990bd035a
7
+ data.tar.gz: 416483fcba129b1a092dcf7b98c1a216308b48d8c7e6ba0a11159ad892f0fab58eac98ca659b99bbba621ea98aac46a297df809ad2861f584889cde9170c7adf
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /spec/tmp/*
11
+ !/spec/tmp/.keep
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
15
+
16
+ # RubyMine
17
+ /.idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.4
5
+ - 2.4.3
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 1.16.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # The Changelog
2
+
3
+ ## Version 0.3.0: Mar 7, 2018
4
+ User can generate edges, one file at a time, by passing filename into new exe/generate_edges
5
+ `bundle exec generate_edges path/to/my_edge.rb`
6
+
7
+ Replaced rake task with RailsEdgeTest::Runner
8
+
9
+ ## Version 0.2.2: Feb 20, 2018
10
+ Beginning of this changelog.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at josh@noredink.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_edge_test.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Joshua Leven
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # RailsEdgeTest
2
+
3
+ There is a particular type of integration testing that we have found very fruitful. We:
4
+ - load up our front-end with its virtual dom,
5
+ - assert expectations by querying the virtual dom, and
6
+ - interact with our application by simulating events on elements in the virtual dom
7
+
8
+ We have found these browser-less integration tests to be orders of magnitude faster than typical capybara integration tests, with minimal downsides. One of the biggest drawbacks to this approach is that we must maintain the json we expect from the backend in a form that is available to these tests, typically a json file (or Elm file with a json blob). Maintaining the blob causes two problems:
9
+ 1. The blob can easily become out-of-sync with our backend, and
10
+ 2. There is no specification for how to recreate it when things do become out-of-sync.
11
+
12
+ This gem aims to solve these problems. The rails_edge_test gem allows us to:
13
+ - use Ruby code to explicitly specify each json blob our front-end tests require,
14
+ - re-generate these files, as needed, with a simple rake task.
15
+
16
+ We write what we call "edge specs," Ruby files that specify the json edge between our front- and back-end by using our Rails models and controller actions directly. These are written using a DSL evocative of an RSpec spec. They allow us to generate json blob files which we commit to our repo, and access from our front-end integration tests. Over time, as our APIs develop, we can simply rerun our edge specs in order to update these json blobs based on existing specifications.
17
+
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile, and make sure it's available to your test environment:
22
+
23
+ ```ruby
24
+ gem 'rails_edge_test'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install rails_edge_test
34
+
35
+ ## Usage
36
+
37
+ For example:
38
+
39
+ ```ruby
40
+ # spec/edge/rails_controller_edge.rb
41
+
42
+ include RailsEdgeTest::Dsl
43
+
44
+ controller HomeController do
45
+ action :show do
46
+ let(:user) { create :user }
47
+
48
+ edge "first time user" do
49
+ user
50
+ perform_get
51
+
52
+ # generates Edge.HomeController.Show.FirstTimeUser with `json` function
53
+ produce_elm_file('FirstTimeUser')
54
+ end
55
+
56
+ edge "returning user" do
57
+ user
58
+ create :post, user: user
59
+ perform_get
60
+
61
+ # generates Edge.HomeController.Show.ReturningUser with `json` function
62
+ produce_elm_file('ReturningUser')
63
+ end
64
+ end
65
+ end
66
+ ```
67
+
68
+ Edge specifications, like the above, should be put in subfolders of `/edge` and must be named `*_edge.rb`.
69
+
70
+ ## Generating files
71
+
72
+ When you want to generate your edge json files, run this:
73
+
74
+ `bundle exec generate_edges`
75
+
76
+ You can also pass in a file path relative to the edge root path (usually spec/edge):
77
+ `bundle exec generate_edges rails_controller_edge.rb`
78
+
79
+ ## Some helpful setup
80
+
81
+ You may want to use some or all of this setup:
82
+
83
+ ```ruby
84
+ # config/initializers/rails_edge_test.rb
85
+
86
+ if defined?(RailsEdgeTest)
87
+ RailsEdgeTest.configure do |config|
88
+ config.edge_root_path = Rails.root.join('edge', 'spec')
89
+ config.elm_path = Rails.root.join('ui', 'tests')
90
+ config.include(FactoryGirl::Syntax::Methods)
91
+
92
+ config.before_suite { DatabaseCleaner.strategy = :transaction }
93
+ config.before_each { DatabaseCleaner.start }
94
+ config.after_each { DatabaseCleaner.clean }
95
+
96
+ config.printer = RailsEdgeTest::Printers::Tree
97
+ end
98
+ end
99
+ ```
100
+
101
+ ```ruby
102
+ # edge/edge_helper.rb
103
+
104
+ include RailsEdgeTest::Dsl
105
+
106
+ Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each {|f| require f}
107
+ ```
108
+
109
+ ```ruby
110
+ # edge/<the name of your file>_edge.rb
111
+
112
+ require Rails.root.join('edge', 'spec', 'edge_helper')
113
+
114
+ #...
115
+ ```
116
+
117
+
118
+ ## Development
119
+
120
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
121
+
122
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
123
+
124
+ ## Contributing
125
+
126
+ Bug reports and pull requests are welcome on GitHub at https://github.com/NoRedInk/rails_edge_test. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
127
+
128
+
129
+ ## License
130
+
131
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
132
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rails_edge_test"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'open3'
4
+ require 'rails_edge_test'
5
+
6
+ rails_root = File.expand_path("../", ENV["BUNDLE_GEMFILE"])
7
+
8
+ RailsEdgeTest::Runner.load_rails_environment!(rails_root)
9
+ RailsEdgeTest::Runner.go!(ARGV)
@@ -0,0 +1,56 @@
1
+ module RailsEdgeTest
2
+ class Configuration
3
+ attr_accessor :elm_path, :edge_root_path, :printer
4
+
5
+ def initialize
6
+ self.elm_path = Rails.root.join('spec')
7
+ self.edge_root_path = Rails.root.join('spec', 'edge')
8
+ self.printer = Printers::Boring
9
+ @before_suite_blocks = []
10
+ @before_each_blocks = []
11
+ @after_each_blocks = []
12
+ end
13
+
14
+ # Provide any Module here with methods you would like to be able to
15
+ # access from within an `edge` block.
16
+ # @param [Module] mod - a module to be included into all `edge` blocks
17
+ def include(mod)
18
+ Dsl::Edge.include mod
19
+ end
20
+
21
+ # Provide a block to be executed once before running any `edge` blocks
22
+ def before_suite(&block)
23
+ @before_suite_blocks << block
24
+ end
25
+
26
+ # Provide a block to be executed before running each `edge` block
27
+ def before_each(&block)
28
+ @before_each_blocks << block
29
+ end
30
+
31
+ # Provide a block to be executed after running each `edge` block
32
+ def after_each(&block)
33
+ @after_each_blocks << block
34
+ end
35
+
36
+ def wrap_suite_execution(&block)
37
+ @before_suite_blocks.each do |before_suit_block|
38
+ before_suit_block.call
39
+ end
40
+
41
+ block.call
42
+ end
43
+
44
+ def wrap_edge_execution(&edge)
45
+ @before_each_blocks.each do |before_each_block|
46
+ before_each_block.call
47
+ end
48
+
49
+ edge.call
50
+
51
+ @after_each_blocks.each do |after_each_block|
52
+ after_each_block.call
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,30 @@
1
+ module RailsEdgeTest::Dsl
2
+ Action = Struct.new(:name, :controller_class) do
3
+ def initialize(*args)
4
+ super
5
+ @edges = {}
6
+ @let_handler = LetHandler.new
7
+ end
8
+
9
+ def edge(description, &block)
10
+ edge = Edge.new(description, name, controller_class)
11
+ @edges[edge] = block
12
+ end
13
+
14
+ def let(title, &block)
15
+ @let_handler.add_definition(title, &block)
16
+ end
17
+
18
+ def generate(title, &block)
19
+ @let_handler.add_definition("generate_#{title}", &block)
20
+ end
21
+
22
+ def __edges
23
+ @edges
24
+ end
25
+
26
+ def __let_handler
27
+ @let_handler
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ module RailsEdgeTest::Dsl
2
+ Controller = Struct.new(:controller_class) do
3
+ def initialize(*args)
4
+ super
5
+ @actions = []
6
+ end
7
+
8
+ def action(name, &block)
9
+ new_action = Action.new(name, controller_class)
10
+ new_action.instance_exec(&block)
11
+ @actions << new_action
12
+ end
13
+
14
+ def __actions
15
+ @actions
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,95 @@
1
+ require 'action_dispatch'
2
+ require 'action_controller'
3
+ require 'action_controller/test_case'
4
+
5
+ module RailsEdgeTest::Dsl
6
+ Edge = Struct.new(:description, :action, :controller_class) do
7
+
8
+ def initialize(*args)
9
+ super
10
+ @let_cache = {}
11
+ end
12
+
13
+ delegate :session, to: :request
14
+
15
+ def request
16
+ @request ||= ActionController::TestRequest.new
17
+ end
18
+
19
+ def controller
20
+ @controller ||= controller_class.new
21
+ end
22
+
23
+ def response
24
+ @response
25
+ end
26
+
27
+ def perform_get(parameters = {})
28
+ request.assign_parameters(
29
+ ::Rails.application.routes,
30
+ controller_class.controller_path,
31
+ action.to_s,
32
+ parameters
33
+ )
34
+
35
+ @response = controller.dispatch(action, request)
36
+ end
37
+
38
+ def produce_elm_file(module_name, ivar: nil)
39
+ json = produce_json(ivar: ivar)
40
+ json = json.gsub("\\", "\\\\\\\\") # unbelievably, this replaces \ with \\
41
+
42
+ filepath = File.join(
43
+ RailsEdgeTest.configuration.elm_path,
44
+ 'Edge',
45
+ controller_class.name.gsub('::','/')
46
+ )
47
+
48
+ full_module_name =
49
+ "#{controller_class.name.gsub('::','.')}.#{module_name}"
50
+
51
+ data = <<~ELM
52
+ module Edge.#{full_module_name} exposing (json)
53
+
54
+
55
+ json : String
56
+ json =
57
+ """
58
+ #{json}
59
+ """
60
+ ELM
61
+
62
+ write_file(filepath, module_name+'.elm', data)
63
+ end
64
+
65
+ private
66
+ def produce_json(ivar: nil)
67
+ unless response
68
+ fail "Must perform a request (for example `perform_get`) before attempting to produce a json file."
69
+ end
70
+ if response.is_a?(Array) && response[0] >= 300
71
+ fail "Request did not result in a successful (2xx) response!"
72
+ end
73
+
74
+ ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false
75
+ if ivar
76
+ controller.
77
+ send(:instance_variable_get, ivar).
78
+ to_json
79
+ else
80
+ response[2].body
81
+ end
82
+ end
83
+
84
+ def write_file(filepath, filename, data)
85
+ FileUtils.mkdir_p(filepath)
86
+
87
+ filepath = File.join(filepath, filename)
88
+
89
+ File.open(filepath, 'w') do |f|
90
+ f.write(data)
91
+ f.flush
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,22 @@
1
+ module RailsEdgeTest::Dsl
2
+ class LetHandler
3
+ attr_reader :let_blocks
4
+
5
+ def initialize
6
+ @let_blocks = {}
7
+ end
8
+
9
+ def add_definition(title, &block)
10
+ @let_blocks[title] = block
11
+ end
12
+
13
+ def execute(title)
14
+ block = @let_blocks[title]
15
+ unless block
16
+ fail NoMethodError, "no method or let block defined with name #{title}"
17
+ end
18
+
19
+ block.call
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,61 @@
1
+ module RailsEdgeTest
2
+ module Dsl
3
+ def controller(controller_class, &block)
4
+ controller = RailsEdgeTest::Dsl::Controller.new(controller_class)
5
+ controller.instance_exec(&block)
6
+ Dsl.add(controller)
7
+ end
8
+
9
+ class << self
10
+ def reset!
11
+ @controllers = []
12
+ end
13
+
14
+ def execute!
15
+ printer = RailsEdgeTest.configuration.printer.new
16
+ printer.begin_suite
17
+
18
+ RailsEdgeTest.configuration.wrap_suite_execution do
19
+
20
+ @controllers.each do |controller|
21
+ printer.begin_controller(controller)
22
+
23
+ controller.__actions.each do |action|
24
+ printer.begin_action(action)
25
+
26
+ action.__edges.each do |edge, block|
27
+ printer.begin_edge(edge)
28
+
29
+ RailsEdgeTest.configuration.wrap_edge_execution do
30
+ define_lets(edge, action.__let_handler)
31
+ edge.instance_exec(&block)
32
+ end
33
+
34
+ printer.end_edge
35
+ end
36
+
37
+ printer.end_action
38
+ end
39
+
40
+ printer.end_controller
41
+ end
42
+
43
+ end
44
+ printer.end_suite
45
+ end
46
+
47
+ def add(controller)
48
+ @controllers << controller
49
+ end
50
+
51
+ private
52
+ def define_lets(edge, lets_handler)
53
+ lets_handler.let_blocks.each do |title, block|
54
+ edge.define_singleton_method(title) do
55
+ @let_cache[title] ||= instance_eval(&block)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,39 @@
1
+ module RailsEdgeTest::Printers
2
+ class Boring
3
+ def initialize
4
+ @count = 0
5
+ end
6
+
7
+ def begin_suite
8
+ puts ""
9
+ end
10
+
11
+ def end_suite
12
+ puts "\n#{@count} edge specs executed."
13
+ end
14
+
15
+ def begin_controller(_controller)
16
+ print "."
17
+ end
18
+
19
+ def end_controller
20
+
21
+ end
22
+
23
+ def begin_action(_action)
24
+ print "."
25
+ end
26
+
27
+ def end_action
28
+
29
+ end
30
+
31
+ def begin_edge(_edge)
32
+ print "."
33
+ end
34
+
35
+ def end_edge
36
+ @count += 1
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ module RailsEdgeTest::Printers
2
+ class Silent
3
+ def begin_suite
4
+ end
5
+
6
+ def end_suite
7
+ end
8
+
9
+ def begin_controller(_controller)
10
+ end
11
+
12
+ def end_controller
13
+ end
14
+
15
+ def begin_action(_action)
16
+ end
17
+
18
+ def end_action
19
+ end
20
+
21
+ def begin_edge(_edge)
22
+ end
23
+
24
+ def end_edge
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,42 @@
1
+ module RailsEdgeTest::Printers
2
+ class Tree
3
+ def initialize
4
+ @count = 0
5
+ end
6
+
7
+ def begin_suite
8
+ puts ""
9
+ puts "Generating Edges..."
10
+ puts "-------------------"
11
+ puts ""
12
+ end
13
+
14
+ def end_suite
15
+ puts "\n#{@count} edge specs executed."
16
+ end
17
+
18
+ def begin_controller(controller)
19
+ puts controller.controller_class.name
20
+ end
21
+
22
+ def end_controller
23
+ puts ""
24
+ end
25
+
26
+ def begin_action(action)
27
+ puts " #{action.name}"
28
+ end
29
+
30
+ def end_action
31
+ end
32
+
33
+ def begin_edge(edge)
34
+ print " #{edge.description}"
35
+ end
36
+
37
+ def end_edge
38
+ puts " ... done"
39
+ @count += 1
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ module RailsEdgeTest
2
+ module Runner
3
+ module_function
4
+ def go!(args = [])
5
+ unless Rails.env.test?
6
+ puts "Failure! Unable to set Rails environment to test."
7
+ exit
8
+ end
9
+
10
+ RailsEdgeTest::Dsl.reset!
11
+
12
+ glob_path = '**/*_edge.rb'
13
+
14
+ if args.length > 0
15
+ glob_path = args.shift
16
+ end
17
+
18
+ glob = File.join(
19
+ RailsEdgeTest.configuration.edge_root_path,
20
+ glob_path
21
+ )
22
+
23
+ Dir.glob(glob).each do |file|
24
+ load file
25
+ end
26
+
27
+ RailsEdgeTest::Dsl.execute!
28
+ end
29
+
30
+ def load_rails_environment!(rails_root)
31
+ ENV["RAILS_ENV"]="test"
32
+ rails_app_path = File.join(rails_root, "config/application")
33
+ require rails_app_path
34
+
35
+ Rails.application.require_environment!
36
+
37
+ require "rake"
38
+ Rails.application.load_tasks
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module RailsEdgeTest
2
+ VERSION = "0.3.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ require "rails_edge_test/version"
2
+ require "rails_edge_test/dsl"
3
+ require "rails_edge_test/dsl/controller"
4
+ require "rails_edge_test/dsl/action"
5
+ require "rails_edge_test/dsl/edge"
6
+ require "rails_edge_test/dsl/let_handler"
7
+ require "rails_edge_test/configuration"
8
+ require "rails_edge_test/runner"
9
+ require "rails_edge_test/printers/boring"
10
+ require "rails_edge_test/printers/silent"
11
+ require "rails_edge_test/printers/tree"
12
+
13
+ module RailsEdgeTest
14
+ module_function
15
+ def configure(&block)
16
+ block.call configuration
17
+ end
18
+
19
+ def configuration
20
+ @configuration ||= Configuration.new
21
+ end
22
+ end
23
+
24
+ # TODO:
25
+ # - Flesh out the README
26
+ # - Refactor LetHelper to define a Module, and include it when necessary
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_edge_test/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_edge_test"
8
+ spec.version = RailsEdgeTest::VERSION
9
+ spec.authors = ["Joshua Leven"]
10
+ spec.email = ["josh@noredink.com"]
11
+
12
+ spec.summary = %q{Generate json for front-end testing using your rails backend.}
13
+ spec.description = %q{Keep your backend and front-end specs in sync! The rails_edge_test gem provides a dsl and rake task that uses your Rails app to generate json and appropriate wrapper files for use in your front-end testing.}
14
+ spec.homepage = "https://github.com/NoRedInk/rails_edge_test"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables << "generate_edges"
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "actionpack", "~> 4.2"
25
+
26
+ spec.add_development_dependency "rails", "~> 4.2"
27
+ spec.add_development_dependency "sqlite3", "~> 1.3"
28
+ spec.add_development_dependency "bundler", "~> 1.14"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_edge_test
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Leven
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: Keep your backend and front-end specs in sync! The rails_edge_test gem
98
+ provides a dsl and rake task that uses your Rails app to generate json and appropriate
99
+ wrapper files for use in your front-end testing.
100
+ email:
101
+ - josh@noredink.com
102
+ executables:
103
+ - generate_edges
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".travis.yml"
110
+ - CHANGELOG.md
111
+ - CODE_OF_CONDUCT.md
112
+ - Gemfile
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - bin/console
117
+ - bin/setup
118
+ - exe/generate_edges
119
+ - lib/rails_edge_test.rb
120
+ - lib/rails_edge_test/configuration.rb
121
+ - lib/rails_edge_test/dsl.rb
122
+ - lib/rails_edge_test/dsl/action.rb
123
+ - lib/rails_edge_test/dsl/controller.rb
124
+ - lib/rails_edge_test/dsl/edge.rb
125
+ - lib/rails_edge_test/dsl/let_handler.rb
126
+ - lib/rails_edge_test/printers/boring.rb
127
+ - lib/rails_edge_test/printers/silent.rb
128
+ - lib/rails_edge_test/printers/tree.rb
129
+ - lib/rails_edge_test/runner.rb
130
+ - lib/rails_edge_test/version.rb
131
+ - rails_edge_test.gemspec
132
+ homepage: https://github.com/NoRedInk/rails_edge_test
133
+ licenses:
134
+ - MIT
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.7.3
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: Generate json for front-end testing using your rails backend.
156
+ test_files: []