gitmethere 0.0.1 → 0.1.0

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: 13f7914789903c66d5f706790b4bb18a396174cc
4
- data.tar.gz: 6079f2bc550342a0461f4b97ca0a2ad8b6b1a07f
3
+ metadata.gz: 1a9e37922446adc92aac3e9d7f4d5757342f7399
4
+ data.tar.gz: 8d1c993adcd6089e943a82d1879395082a60f491
5
5
  SHA512:
6
- metadata.gz: b5773eb0f5b5ea6626a2498a58878fc316d875246d4fdfd1c4b5d4668c4f243479333845caac95dc22a63b9961b80f8089a68865c12e5a6eded286beee8f00dc
7
- data.tar.gz: 7d2baa766d8e5b50e9a2335c1d7e773b3a2eac7ddd97ced081dd05c2db21543861c1b1cf2691da8eb7de1fd7a80cbe8a05fbb0b66cafafd0d2828d0d7864fc06
6
+ metadata.gz: d5ad9bcd14a47774e5dcaea24dd11c43912398307794d858485e436e0842e7c4fbd0878e8077c0208891cd54c649b2cfbbeb77033b52033e7084665d278481d7
7
+ data.tar.gz: d0d3dc30f37f5aa12fec4f21702cbc978116db01245321ca789c8667bcdf57cefd89f8770e840660390cb649641581a13a2de2156dc853fa8f557a5781686adc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/README.md CHANGED
@@ -26,7 +26,7 @@ setup = {
26
26
  This repository demonstrates how merge conflicts occur."
27
27
  }
28
28
 
29
- scenario = GitMeThere::Scenario.new(setup['name'], explanation=setup['explanation'])
29
+ scenario = GitMeThere::Scenario.new(name = setup['name'], explanation = setup['explanation'])
30
30
 
31
31
  scenario.checkout_branch('feature')
32
32
 
@@ -60,6 +60,8 @@ scenario.commit('Add line to master branch')
60
60
 
61
61
  1. Fork it ( https://github.com/loranallensmith/gitmethere/fork )
62
62
  2. Create your feature branch (`git checkout -b my-new-feature`)
63
- 3. Commit your changes (`git commit -am 'Add some feature'`)
64
- 4. Push to the branch (`git push origin my-new-feature`)
65
- 5. Create a new Pull Request
63
+ 3. Write tests for your changes
64
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 5. Push to the branch (`git push origin my-new-feature`)
66
+ 6. Make sure all tests are passing
67
+ 7. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/gitmethere.gemspec CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "fakefs", "~> 0.6"
23
25
 
24
26
  spec.add_runtime_dependency "git", "~> 1.2"
25
27
 
@@ -1,3 +1,3 @@
1
1
  module Gitmethere
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/gitmethere.rb CHANGED
@@ -38,11 +38,13 @@ module GitMeThere
38
38
 
39
39
  def create_file(name="my-file.md", content="")
40
40
  File.open("#{@name}/#{name}", 'w') do | f |
41
- f.puts content
41
+ unless content.empty?
42
+ f.puts content
43
+ end
42
44
  end
43
45
  end
44
46
 
45
- def append_to_file(name="myfile.md", content="Adding a bit more content")
47
+ def append_to_file(name="my-file.md", content="Adding a bit more content")
46
48
  File.open("#{@name}/#{name}", 'a') do | f |
47
49
  f.puts content
48
50
  end
@@ -0,0 +1,159 @@
1
+ require 'gitmethere'
2
+ require 'fakefs/spec_helpers'
3
+
4
+ RSpec.describe GitMeThere::Scenario do
5
+
6
+ before(:each) do
7
+ include FakeFS::SpecHelpers
8
+ FileUtils.mkdir('spec-temp')
9
+ FileUtils.cd('spec-temp')
10
+ end
11
+
12
+ describe ".new()" do
13
+
14
+ before(:each) do
15
+ @scenario = GitMeThere::Scenario.new()
16
+ end
17
+
18
+ it "should create a default scenario directory" do
19
+ expect(File.directory?('my-scenario')).to eq(true)
20
+ end
21
+
22
+ it "should have a README.md file" do
23
+ expect(File.exist?('my-scenario/README.md')).to eq(true)
24
+ end
25
+
26
+ it "should have an empty readme file" do
27
+ expect(File.read('my-scenario/README.md')).to be_empty
28
+ end
29
+
30
+ end
31
+
32
+ describe ".new(args)" do
33
+
34
+ let(:repo) { "named-repo" }
35
+ let(:content) { "content" }
36
+
37
+ before(:each) do
38
+ @scenario = GitMeThere::Scenario.new(
39
+ name=repo,
40
+ explanation=content)
41
+ end
42
+
43
+ it "should create a directory with the specified name" do
44
+ expect(File.directory?(repo)).to eq(true)
45
+ end
46
+
47
+ it "should have a README.md file" do
48
+ expect(File.exist?("#{repo}/README.md")).to eq(true)
49
+ end
50
+
51
+ it "should have the specified content in the README.md file" do
52
+ expect(File.read("#{repo}/README.md")).to eq("#{content}\n")
53
+ end
54
+
55
+ end
56
+
57
+ describe ".create_file()" do
58
+
59
+ before(:each) do
60
+ @scenario = GitMeThere::Scenario.new()
61
+ end
62
+
63
+ it "without arguments" do
64
+ @scenario.create_file()
65
+ expect(File.exist?("my-scenario/my-file.md")).to eq(true)
66
+ end
67
+
68
+ it "with arguments" do
69
+ @scenario.create_file(name="named-file.md", content="This is the content.")
70
+ expect(File.read("my-scenario/named-file.md")).to eq("This is the content.\n")
71
+ end
72
+
73
+ end
74
+
75
+ describe ".append_to_file()" do
76
+
77
+ before(:each) do
78
+ @scenario = GitMeThere::Scenario.new()
79
+ @scenario.create_file()
80
+ end
81
+
82
+ it "without arguments" do
83
+ @scenario.append_to_file()
84
+ expect(File.read("my-scenario/my-file.md")).to include("Adding a bit more content")
85
+ end
86
+
87
+ it "with arguments" do
88
+ @scenario.append_to_file(name="appended-file.md", content="Added some content.")
89
+ expect(File.read("my-scenario/appended-file.md")).to include("Added some content.")
90
+ end
91
+
92
+ end
93
+
94
+ describe '.checkout_branch()' do
95
+ before(:each) do
96
+ @scenario = GitMeThere::Scenario.new(
97
+ name="test-checkout",
98
+ explanation="testing the checkout command"
99
+ )
100
+ end
101
+
102
+ it "with new branch" do
103
+ @scenario.checkout_branch("feature")
104
+ expect(@scenario.instance_variable_get(:@g).current_branch).to eq("feature")
105
+ end
106
+
107
+ it "with existing branch" do
108
+ @scenario.instance_variable_get(:@g).branch("test-branch")
109
+ @scenario.checkout_branch("test-branch")
110
+ expect(@scenario.instance_variable_get(:@g).current_branch).to eq("test-branch")
111
+ end
112
+
113
+ end
114
+
115
+ describe ".stage_changes()" do
116
+
117
+ before(:each) do
118
+ @scenario = GitMeThere::Scenario.new(
119
+ name = "test-staging",
120
+ explanation = "Testing the .stage_changes() method"
121
+ )
122
+ end
123
+
124
+ it "all changes" do
125
+ @scenario.create_file(
126
+ name = "test-staging-files.md",
127
+ content = "Stage this file."
128
+ )
129
+ @scenario.stage_changes
130
+ expect(@scenario.instance_variable_get(:@g).status.added.keys).to include("test-staging-files.md")
131
+ end
132
+
133
+ end
134
+
135
+ describe ".commit()" do
136
+ before(:each) do
137
+ @scenario = GitMeThere::Scenario.new(
138
+ name = "test-commit",
139
+ explanation = "Testing the commit function"
140
+ )
141
+ end
142
+
143
+ it "with message" do
144
+ @scenario.create_file(
145
+ name = "test-commit-file",
146
+ content = "commit this file."
147
+ )
148
+ @scenario.stage_changes
149
+ @scenario.commit("Testing the commit function")
150
+ expect(@scenario.instance_variable_get(:@g).log.first.message).to eq("Testing the commit function")
151
+ end
152
+ end
153
+
154
+ after(:each) do
155
+ FileUtils.cd('..')
156
+ FileUtils.rm_rf('spec-temp')
157
+ end
158
+
159
+ end
@@ -0,0 +1,91 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is
54
+ # recommended. For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ config.disable_monkey_patching!
59
+
60
+ # This setting enables warnings. It's recommended, but in some cases may
61
+ # be too noisy due to issues in dependencies.
62
+ config.warnings = true
63
+
64
+ # Many RSpec users commonly either run the entire suite or an individual
65
+ # file, and it's useful to allow more verbose output when running an
66
+ # individual spec file.
67
+ if config.files_to_run.one?
68
+ # Use the documentation formatter for detailed output,
69
+ # unless a formatter has already been configured
70
+ # (e.g. via a command-line flag).
71
+ config.default_formatter = 'doc'
72
+ end
73
+
74
+ # Print the 10 slowest examples and example groups at the
75
+ # end of the spec run, to help surface which specs are running
76
+ # particularly slow.
77
+ config.profile_examples = 10
78
+
79
+ # Run specs in random order to surface order dependencies. If you find an
80
+ # order dependency and want to debug it, you can fix the order by providing
81
+ # the seed, which is printed after each run.
82
+ # --seed 1234
83
+ config.order = :random
84
+
85
+ # Seed global randomization in this process using the `--seed` CLI option.
86
+ # Setting this allows you to use `--seed` to deterministically reproduce
87
+ # test failures related to randomization by passing the same `--seed` value
88
+ # as the one that triggered the failure.
89
+ Kernel.srand config.seed
90
+ =end
91
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitmethere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fakefs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: git
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +91,7 @@ extensions: []
63
91
  extra_rdoc_files: []
64
92
  files:
65
93
  - ".gitignore"
94
+ - ".rspec"
66
95
  - Gemfile
67
96
  - LICENSE.txt
68
97
  - README.md
@@ -70,6 +99,8 @@ files:
70
99
  - gitmethere.gemspec
71
100
  - lib/gitmethere.rb
72
101
  - lib/gitmethere/version.rb
102
+ - spec/scenario_spec.rb
103
+ - spec/spec_helper.rb
73
104
  homepage: https://github.com/loranallensmith/gitmethere
74
105
  licenses:
75
106
  - MIT
@@ -94,4 +125,6 @@ rubygems_version: 2.2.3
94
125
  signing_key:
95
126
  specification_version: 4
96
127
  summary: A tool for demonstrating Git scenarios
97
- test_files: []
128
+ test_files:
129
+ - spec/scenario_spec.rb
130
+ - spec/spec_helper.rb