fig_newton 0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format Fuubar
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3-p0@data_magic --create
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'fuubar'
5
+ gem 'fuubar-cucumber'
6
+ gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
7
+ gem 'growl'
8
+ gem 'guard-rspec'
9
+ gem 'guard-cucumber'
10
+
11
+ # Specify your gem's dependencies in fig_newton.gemspec
12
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,17 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :cli => '--color --format Fuubar' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/fig_newton/#{m[1]}_spec.rb" }
7
+ watch(%r{^(.+)\.rb$}) { |m| "spec/fig_newton/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { "spec" }
9
+ end
10
+
11
+ guard 'cucumber', :notification => true, :cli => '--profile default' do
12
+ watch(%r{^features/.+\.feature$})
13
+ watch(%r{^features/support/.+$}) { 'features' }
14
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
15
+ watch(%r{^lib/.+\.rb$}) { 'features' }
16
+ watch(%r{^features/yaml/.+$}) { 'features' }
17
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jeffrey S. Morgan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # FigNewton
2
+
3
+ Manages configuration for test suites. It is common to need different configuration information for different test environments. For example, the base_url or database login information might change when you move from development to a test environment. FigNewton makes it simple to create and use this information.
4
+
5
+ ## Usage
6
+
7
+ Using FigNewton is as simple as specifying the directory to use, loading a file from that directory, and then calling methods on the module that match the keys in the file. Let's look at an example.
8
+
9
+ By default the FigNewton gem will look for files in the 'config/environments' directory. Let's assume that we have files named ci.yml, test.yml, and system_test.yml in that directory. All we need to do is call the `load` method in order to begin using a file:
10
+
11
+ ````ruby
12
+ FigNewton.load('system_test.yml')
13
+ ````
14
+
15
+ Next we simply begin calling methods on the FigNewton module that match our keys. Let's assume the system_test.yml file contains the following entries:
16
+
17
+ base_url: http://system_test.mycompany.com
18
+ database_user: cheezy
19
+ database_password: secret
20
+
21
+ In our code we can call methods that match the keys. Here is an example PageObject where we are using the `base_url` entry:
22
+
23
+ ````ruby
24
+ class MyPage
25
+ include PageObject
26
+
27
+ page_url "#{FigNewton.base_url}/my_page.html"
28
+ end
29
+ ````
30
+
31
+
32
+
33
+ ## Installation
34
+
35
+ Add this line to your application's Gemfile:
36
+
37
+ gem 'fig_newton'
38
+
39
+ And then execute:
40
+
41
+ $ bundle
42
+
43
+ Or install it yourself as:
44
+
45
+ $ gem install fig_newton
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.ruby_opts = "-I lib:spec"
10
+ spec.pattern = 'spec/**/*_spec.rb'
11
+ end
12
+ task :spec
13
+
14
+ Cucumber::Rake::Task.new(:features, "Run features") do |t|
15
+ t.profile = "default"
16
+ end
17
+
18
+ desc 'Run all specs and cukes'
19
+ task :test => ['spec', 'features']
20
+
21
+ task :lib do
22
+ $LOAD_PATH.unshift(File.expand_path("lib", File.dirname(__FILE__)))
23
+ end
24
+
25
+ task :default => :test
@@ -0,0 +1 @@
1
+ base_url: 'http://cheezyworld.com'
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --no-source --color --format Cucumber::Formatter::Fuubar
@@ -0,0 +1,12 @@
1
+ Feature: Functionality of the fig_newton gem
2
+
3
+ Scenario: Getting basic configuration data from a yml config file
4
+ Given I have read the configuration file
5
+ When I ask for the value for "base_url"
6
+ Then I should see "http://cheezyworld.com"
7
+
8
+ Scenario: Requesting data that does not exist should result in error
9
+ Given I have read the configuration file
10
+ When I ask for a value that does not exist named "does_not_exist"
11
+ Then I should raise a NoMethodError exception
12
+
@@ -0,0 +1,19 @@
1
+ Given /^I have read the configuration file$/ do
2
+ FigNewton.load 'test_config.yml'
3
+ end
4
+
5
+ When /^I ask for the value for "([^\"]*)"$/ do |key|
6
+ @value = FigNewton.send key
7
+ end
8
+
9
+ Then /^I should see "([^\"]*)"$/ do |value|
10
+ @value.should == value
11
+ end
12
+
13
+ When /^I ask for a value that does not exist named "([^\"]*)"$/ do |non_existing|
14
+ @does_not_exist = non_existing
15
+ end
16
+
17
+ Then /^I should raise a NoMethodError exception$/ do
18
+ expect{ FigNewton.send(@does_not_exist) }.to raise_error(NoMethodError)
19
+ end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
2
+
3
+ require 'rspec/expectations'
4
+ require 'fig_newton'
5
+
6
+ FigNewton.yml_directory = 'config/yaml'
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/fig_newton/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jeff Morgan"]
6
+ gem.email = ["jeff.morgan@leandog.com"]
7
+ gem.description = %q{Provides a simple mechanism to maintain and use different configurations stored in yml files.}
8
+ gem.summary = %q{Provides a simple mechanism to maintain and use different configurations stored in yml files.}
9
+ gem.homepage = "http://github.com/cheezy/fig_newton"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "fig_newton"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = FigNewton::VERSION
17
+
18
+ gem.add_dependency 'yml_reader', '>= 0.1'
19
+
20
+ gem.add_development_dependency 'rspec', '>= 2.8.0'
21
+ gem.add_development_dependency 'cucumber', '>= 1.1.0'
22
+ end
data/lib/fig_newton.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "fig_newton/version"
2
+ require 'yml_reader'
3
+
4
+ module FigNewton
5
+ extend YmlReader
6
+
7
+ def self.default_directory
8
+ 'config/environments'
9
+ end
10
+
11
+ def self.method_missing(*args, &block)
12
+ m = args.first
13
+ value = @yml[m.to_s]
14
+ super unless value
15
+ value
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module FigNewton
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe FigNewton do
4
+ context "when asking for data" do
5
+ it "should retrieve the data by a key named after the method called" do
6
+ FigNewton.yml_directory = 'conf'
7
+ yml_mock = double('yaml')
8
+ YAML.should_receive(:load_file).with('conf/test').and_return(yml_mock)
9
+ yml_mock.should_receive(:[]).with('desired_data').and_return('information')
10
+ FigNewton.load('test')
11
+ FigNewton.desired_data.should == 'information'
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+
5
+ if ENV['coverage']
6
+ raise "simplecov only works on Ruby 1.9" unless RUBY_VERSION =~ /^1\.9/
7
+
8
+ require 'simplecov'
9
+ SimpleCov.start { add_filter "spec/" }
10
+ end
11
+
12
+ require 'rspec'
13
+ require 'fig_newton'
14
+
15
+
16
+
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fig_newton
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeff Morgan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: yml_reader
16
+ requirement: &70117719454340 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70117719454340
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70117719450580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70117719450580
36
+ - !ruby/object:Gem::Dependency
37
+ name: cucumber
38
+ requirement: &70117719449760 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70117719449760
47
+ description: Provides a simple mechanism to maintain and use different configurations
48
+ stored in yml files.
49
+ email:
50
+ - jeff.morgan@leandog.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rspec
57
+ - .rvmrc
58
+ - Gemfile
59
+ - Guardfile
60
+ - LICENSE
61
+ - README.md
62
+ - Rakefile
63
+ - config/yaml/test_config.yml
64
+ - cucumber.yml
65
+ - features/fig_newton.feature
66
+ - features/step_definitions/fig_newton_steps.rb
67
+ - features/support/env.rb
68
+ - fig_newton.gemspec
69
+ - lib/fig_newton.rb
70
+ - lib/fig_newton/version.rb
71
+ - spec/fig_newton/fig_newton_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: http://github.com/cheezy/fig_newton
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.10
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Provides a simple mechanism to maintain and use different configurations
97
+ stored in yml files.
98
+ test_files:
99
+ - features/fig_newton.feature
100
+ - features/step_definitions/fig_newton_steps.rb
101
+ - features/support/env.rb
102
+ - spec/fig_newton/fig_newton_spec.rb
103
+ - spec/spec_helper.rb