Sha256: afb007e9e8dfa4371edf7b576adb306cdc67b605927eb3ee0bdd1089e27a6b0e
Contents?: true
Size: 1.89 KB
Versions: 3
Compression:
Stored size: 1.89 KB
Contents
require 'schema_dev/gem' describe SchemaDev::Gem do let(:user_name) { "My Name" } let(:user_email) { "my_name@example.com" } before(:each) do stub_request(:get, 'https://rubygems.org/api/v1/versions/schema_monkey.json').to_return body: JSON.generate([ { number: "1.0.0.pre", prerelease: true}, { number: "0.2.1"}, { number: "0.1.2"}, { number: "0.1.1" }, ]) allow_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.name").and_return user_name allow_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.email").and_return user_email end around(:each) do |example| silence_stream(STDOUT) do example.run end end it "creates gemspec" do in_tmpdir do expect{SchemaDev::Gem.build("NewGem")}.not_to raise_error gemspec = File.read "new_gem/new_gem.gemspec" expect(gemspec).to include %q{"schema_monkey", "~> 0.2", ">= 0.2.1"} expect(gemspec).to match(/authors.*#{user_name}/) expect(gemspec).to match(/email.*#{user_email}/) end end context "complains" do around(:each) do |example| silence_stream(STDERR) do example.run end end it "when no git user.name" do in_tmpdir do expect_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.name").and_return "" expect{SchemaDev::Gem.build("NewGem")}.to raise_error SystemExit, /who are you/i end end it "when in git worktree" do in_tmpdir do expect_any_instance_of(SchemaDev::Gem).to receive(:system).with(/^git rev-parse/).and_return true expect{SchemaDev::Gem.build("NewGem")}.to raise_error SystemExit, /\bgit\b/ end end it "when gem directory exists" do in_tmpdir do FileUtils.touch "new_gem" expect{SchemaDev::Gem.build("NewGem")}.to raise_error SystemExit, /exists/ end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
schema_dev-3.1.1 | spec/gem_spec.rb |
schema_dev-3.1.0 | spec/gem_spec.rb |
schema_dev-3.0.1 | spec/gem_spec.rb |