Skip to content

Commit

Permalink
Rename #gather_features and #write_feature_file to #gather and #write…
Browse files Browse the repository at this point in the history
…_file
  • Loading branch information
Andrew Stewart committed Dec 4, 2012
1 parent 2c6efcb commit 4b894cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/gitnesse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def pull
name = page.name.gsub('.feature', '')
filename = "#{Gitnesse.configuration.target_directory}/#{name}.feature"
features = Wiki.extract_features(page)
Features.write_feature_file(filename, features) unless features.empty?
Features.write_file(filename, features) unless features.empty?
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/gitnesse/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class Features
# filename - the filename to use for the feature
# features - the features to write to disk
#
def self.write_feature_file(filename, features)
def self.write_file(filename, features)
File.open(filename, "w") do |file|
file.write(gather_features(features))
file.write(gather(features))
end
end

Expand All @@ -19,7 +19,7 @@ def self.write_feature_file(filename, features)
# page_features - the features
#
# Returns a string containing the
def self.gather_features(page_features)
def self.gather(page_features)
return '' if page_features.nil? || page_features.empty?

features = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
require_relative '../../test_helper'

describe Gitnesse::Features do
describe ".gather_features" do
describe ".gather" do

describe "when several features" do
let(:page_features) { {"test-feature" => "feature content", "another-test-feature" => "another feature content"} }

it { Gitnesse::Features.gather_features(page_features).must_equal "feature content" }
it { Gitnesse::Features.gather(page_features).must_equal "feature content" }
end

describe "when one single feature" do
let(:page_features) { {"test-feature" => "feature content"} }

it { Gitnesse::Features.gather_features(page_features).must_equal "feature content" }
it { Gitnesse::Features.gather(page_features).must_equal "feature content" }
end

describe "when no features" do
let(:page_features) { Hash.new }

it { Gitnesse::Features.gather_features(page_features).must_equal "" }
it { Gitnesse::Features.gather(page_features).must_equal "" }
end

describe "when nil" do
let(:page_features) { nil }

it { Gitnesse::Features.gather_features(page_features).must_equal "" }
it { Gitnesse::Features.gather(page_features).must_equal "" }
end
end
end
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require_relative '../../test_helper'

describe Gitnesse::Features do
describe ".write_feature_file" do
describe ".write_file" do
let(:file) { StringIO.new }
let(:file_path) { "#{Gitnesse.configuration.target_directory}/test.feature" }

before do
File.expects(:open).with(file_path, "w").yields(file)
Gitnesse::Features.expects(:gather_features).with({ "test-feature" => "feature content" }).returns("feature content")
Gitnesse::Features.expects(:gather).with({ "test-feature" => "feature content" }).returns("feature content")
end

it "writes to the file" do
Gitnesse::Features.write_feature_file(file_path, { "test-feature" => "feature content" })
Gitnesse::Features.write_file(file_path, { "test-feature" => "feature content" })
file.string.must_equal "feature content"
end
end
Expand Down

0 comments on commit 4b894cd

Please sign in to comment.