siringa 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5650e083c7d2cf88d4556847def7c3002429a25
4
- data.tar.gz: cd8b73b2bccdc1f0fd5a294d19a4e62d3f801006
3
+ metadata.gz: e86e6f8766845bd59ef91b71811575e9b0d5bf55
4
+ data.tar.gz: 3fd47988e335331bd12311fd114029393f4eaaed
5
5
  SHA512:
6
- metadata.gz: e342b5a35cba7e7d07222c444903bc45ccc87a7739a190f5f6f5d53d028a40ca59b3af7521193de00525465873c279c6d40f3ed787da3ef3ee822d7cd08de9ec
7
- data.tar.gz: f38a3dbde4ec18a9efbed51e0200effd47a54f72782274b3869d0d8655233d94e28d43249fd448e3874e5dfb3e9329a454a34a225ef4a7f0f9ebd3e05571d89f
6
+ metadata.gz: b47372970c5d75e368c2b6552d0be4eaea148105f1578cbd1ebc2202d33ca3bc07a7ff826644971aeaa2fa56bc460837fc345c0d515270aa430927215c34f288
7
+ data.tar.gz: bf308063eeb9ce9078aaa1e27f05b0e7d525c531952d467e232e1ddac5aa68be86e24c837f5eb2a0f71badbdd72193c089004a6f405ec4e33aa71ad9573f243c
data/README.md CHANGED
@@ -72,24 +72,24 @@ Now that we've created our definitions we could use them in our two cases:
72
72
  ### As seed data
73
73
  You could just load the `initial` definition running the following rake recipe after your deploy:
74
74
  ```console
75
- rake siringa:load
75
+ rake siringa:load_definition
76
76
  ```
77
77
  `initial` is the default definition this Rake task recipe will try to load, if you want to load another definition instead you could pass its name as argument:
78
78
  ```console
79
- rake 'siringa:load[another_definition]'
79
+ rake 'siringa:load_definition[another_definition]'
80
80
  ```
81
81
  This will load a definition named `:another_definition`. Please note that if you use Zsh shell you'll need to use quotes, more info [here](http://robots.thoughtbot.com/post/18129303042/how-to-use-arguments-in-a-rake-task).
82
82
 
83
83
  If you want to force a Rails environment you could just run the Sriringa recipe specifing the `RAILS_ENV` environmental variable:
84
84
  ```console
85
- RAILS_ENV=development rake siringa:load
85
+ RAILS_ENV=development rake siringa:load_definition
86
86
  ```
87
87
 
88
88
  ### During an acceptance test
89
89
  As you can see running `rake routes`, Siringa added 3 new routes to your API:
90
90
  ```console
91
91
  Routes for Siringa::Engine:
92
- POST /load/:definition(.:format) siringa/siringa#load
92
+ POST /load_definition/:definition(.:format) siringa/siringa#load_definition
93
93
  dump POST /dump(.:format) siringa/siringa#dump
94
94
  restore POST /restore(.:format) siringa/siringa#restore
95
95
  ```
@@ -100,7 +100,7 @@ The workflow I propose here is:
100
100
 
101
101
  This will create a `.dump` file in the `tmp/dumps` directory created during the install process. You could create as many dump files as you want but Siringa will keep only the latest 5 dumps created.
102
102
 
103
- 2. Load a Siringa definition performing a `POST` request to `YOURHOST/siringa/load/specific`
103
+ 2. Load a Siringa definition performing a `POST` request to `YOURHOST/siringa/load_definition/specific`
104
104
 
105
105
  This will run the code defined in a definition named `specific` on the server.
106
106
 
@@ -126,7 +126,7 @@ end
126
126
  ## Acceptance test example
127
127
  Just to get the idea, the following script will show you how to use Siringa in a acceptance test using Selenium, [rest-client](https://github.com/rest-client/rest-client) and RSpec:
128
128
  ```ruby
129
- require 'selenium-webdriver'dd
129
+ require 'selenium-webdriver'
130
130
  require 'rspec'
131
131
  require 'rest_client'
132
132
 
@@ -144,9 +144,9 @@ describe "Acceptance test using Siringa" do
144
144
  @driver.quit
145
145
  end
146
146
 
147
- it "Load a definition and test something" do
148
- # Load a definition named 'specific'
149
- RestClient.post 'YOURHOST/siringa/load', { :definition => :specific }
147
+ it "Loads a definition and test something" do
148
+ # Loads a definition named 'specific'
149
+ RestClient.post 'YOURHOST/siringa/load_definition', { definition: :specific }
150
150
 
151
151
  # Here goes your test
152
152
 
@@ -163,5 +163,5 @@ end
163
163
  ## How to collaborate
164
164
  * Fork the repo and send a pull request, thanks!
165
165
 
166
- # Licence
166
+ # License
167
167
  MIT-LICENSE 2013 Enrico Stano
@@ -1,7 +1,7 @@
1
1
  module Siringa
2
2
  class SiringaController < ApplicationController
3
3
 
4
- def load
4
+ def load_definition
5
5
  result = Siringa.load_definition(params['definition'].to_sym, options)
6
6
  render json: result, status: :created
7
7
  rescue ArgumentError => exception
@@ -1,5 +1,5 @@
1
1
  Siringa::Engine.routes.draw do
2
- post "load/:definition", :to => "siringa#load"
2
+ post "load_definition/:definition", :to => "siringa#load_definition"
3
3
  post "dump", :to => "siringa#dump"
4
4
  post "restore", :to => "siringa#restore"
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Siringa
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  namespace :siringa do
2
2
  desc "Load a definition and populate the DB with seed data"
3
- task :load, [:definition] do |t, args|
3
+ task :load_definition, [:definition] do |t, args|
4
4
  args.with_defaults :definition => :initial
5
5
  Rake::Task["environment"].invoke
6
6
  puts <<-EOS
@@ -10,18 +10,18 @@ class SiringaControllerTest < ActionController::TestCase
10
10
  def teardown
11
11
  end
12
12
 
13
- test "load action passing existing factory" do
14
- get :load, { definition: "initial", use_route: "siringa" }
13
+ test "load_definition action passing existing factory" do
14
+ get :load_definition, { definition: "initial", use_route: "siringa" }
15
15
  assert_response :success
16
16
  end
17
17
 
18
- test "load action passing a factory that doesn't exist" do
19
- get :load, { definition: "papapa", use_route: "siringa" }
18
+ test "load_definition action passing a factory that doesn't exist" do
19
+ get :load_definition, { definition: "papapa", use_route: "siringa" }
20
20
  assert_response :method_not_allowed
21
21
  end
22
22
 
23
- test "load action passing arguments" do
24
- get :load, {
23
+ test "load_definition action passing arguments" do
24
+ get :load_definition, {
25
25
  definition: "definition_with_arguments",
26
26
  siringa_args: { name: 'Robb Stark' },
27
27
  use_route: "siringa"
@@ -29,8 +29,8 @@ class SiringaControllerTest < ActionController::TestCase
29
29
  assert_response :success
30
30
  end
31
31
 
32
- test "load action returning JSON response" do
33
- get :load, {
32
+ test "load_definition action returning JSON response" do
33
+ get :load_definition, {
34
34
  definition: "definition_with_return",
35
35
  siringa_args: { name: 'Ned' },
36
36
  use_route: "siringa"
@@ -749,3 +749,44 @@ Processing by Siringa::SiringaController#load as HTML
749
749
   (0.1ms) RELEASE SAVEPOINT active_record_1
750
750
  Completed 201 Created in 8ms (Views: 0.3ms | ActiveRecord: 0.7ms)
751
751
   (0.1ms) rollback transaction
752
+  (0.3ms) begin transaction
753
+ ---------------------------------------------------------------------------------------
754
+ SiringaControllerTest: test_load_definition_action_passing_a_factory_that_doesn't_exist
755
+ ---------------------------------------------------------------------------------------
756
+ Processing by Siringa::SiringaController#load_definition as HTML
757
+ Parameters: {"definition"=>"papapa"}
758
+ Completed 405 Method Not Allowed in 0ms (Views: 0.2ms | ActiveRecord: 0.0ms)
759
+  (0.1ms) rollback transaction
760
+  (0.1ms) begin transaction
761
+ --------------------------------------------------------------------
762
+ SiringaControllerTest: test_load_definition_action_passing_arguments
763
+ --------------------------------------------------------------------
764
+ Processing by Siringa::SiringaController#load_definition as HTML
765
+ Parameters: {"definition"=>"definition_with_arguments", "siringa_args"=>{"name"=>"Robb Stark"}}
766
+  (0.0ms) SAVEPOINT active_record_1
767
+ SQL (0.2ms) INSERT INTO "users" DEFAULT VALUES
768
+  (0.1ms) RELEASE SAVEPOINT active_record_1
769
+ Completed 201 Created in 7ms (Views: 0.2ms | ActiveRecord: 0.6ms)
770
+  (0.1ms) rollback transaction
771
+  (0.0ms) begin transaction
772
+ ---------------------------------------------------------------------------
773
+ SiringaControllerTest: test_load_definition_action_passing_existing_factory
774
+ ---------------------------------------------------------------------------
775
+ Processing by Siringa::SiringaController#load_definition as HTML
776
+ Parameters: {"definition"=>"initial"}
777
+  (0.1ms) SAVEPOINT active_record_1
778
+ SQL (0.1ms) INSERT INTO "users" DEFAULT VALUES
779
+  (0.0ms) RELEASE SAVEPOINT active_record_1
780
+ Completed 201 Created in 2ms (Views: 0.2ms | ActiveRecord: 0.2ms)
781
+  (0.1ms) rollback transaction
782
+  (0.0ms) begin transaction
783
+ --------------------------------------------------------------------------
784
+ SiringaControllerTest: test_load_definition_action_returning_JSON_response
785
+ --------------------------------------------------------------------------
786
+ Processing by Siringa::SiringaController#load_definition as HTML
787
+ Parameters: {"definition"=>"definition_with_return", "siringa_args"=>{"name"=>"Ned"}}
788
+  (0.1ms) SAVEPOINT active_record_1
789
+ SQL (0.1ms) INSERT INTO "users" DEFAULT VALUES
790
+  (0.0ms) RELEASE SAVEPOINT active_record_1
791
+ Completed 201 Created in 2ms (Views: 0.2ms | ActiveRecord: 0.3ms)
792
+  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siringa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrico Stano